1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <iostream>
#include <Producer/Window3D>
#include <GL/gl.h>
#include <GL/glu.h>
#include "MyGraphics"
using namespace Producer;
#if 0
// Handle to an OpenGL display list that draws a cube
static void draw( Window3D &w3d, GLuint object )
{
// Set up the viewport
glViewport( 0, 0, w3d.width(), w3d.height() );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Set up the Projection matrix
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
double aspect = double(w3d.width())/double(w3d.height());
gluPerspective( 45, aspect, 0.1, 100.0 );
// Set up the model view matrix
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt( 0, 0, 7, 0, 0, 0, 0, 1, 0 );
// Transform the sceen by the trackball matrix and
// draw.
glPushMatrix();
glMultMatrixf( w3d.getTrackballMatrix() );
glCallList( object );
glPopMatrix();
}
#endif
class kb : public Window3D::KeyboardCallback {
public:
kb() : Window3D::KeyboardCallback() {}
void operator() (KeySymbol key )
{
std::cout << "Key: " << key << std::endl;
};
};
int main()
{
Window3D w3d( "Testing Window 3D - with OpenGL", 20, 20, 800, 600 );
w3d.enableTrackball();
w3d.setKeyboardCallback( new kb );
MyGraphics gfx;
/*
glEnable( GL_DEPTH_TEST );
glEnable( GL_CULL_FACE );
glEnable( GL_LIGHTING );
GLfloat position[] = { 0.0, 0.0, 1.0, 0.0 };
glEnable( GL_LIGHT0 );
glLightfv( GL_LIGHT0, GL_POSITION, position );
glClearColor( 0.2f, 0.2f, 0.4f, 1.0f );
cube = MakeCube();
*/
while( !w3d.done() )
{
w3d.sync();
gfx.draw( w3d );
w3d.swapBuffers();
}
return 0;
}
|