/* Auteur: Nicolas JANEY */ /* Avril 2001 */ /* La visualisation en OpenGL */ #include "windows.h" #include #include #include #include #include static float rotx = 0.0f ; static float roty = 0.0f ; static float rotz = 0.0f ; void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,1.0,1.0); glLoadIdentity(); /*(1)*/ glTranslatef(0.0,0.0,-5.0); /*(1)*/ glRotatef(rotx,1.0f,0.0f,0.0f); /*(1)*/ glRotatef(roty,0.0f,1.0f,0.0f); /*(1)*/ glRotatef(rotz,0.0f,0.0f,1.0f); /*(1)*/ glScalef(1.0,2.0,3.0); /*(2)*/ auxWireCube(1.0); /*(2)*/ glFlush(); } void myinit(void) { glShadeModel(GL_FLAT); } void CALLBACK myReshape(int w, int h) { glMatrixMode(GL_PROJECTION); /*(3)*/ glLoadIdentity(); /*(3)*/ glFrustum(-1.,1.,-1.,1.,1.5,20.);/*(3)*/ glMatrixMode(GL_MODELVIEW); /*(2)*/ glViewport(0,0,w,h); /*(4)*/ } void CALLBACK auxX(void) { rotx += 2 ; } void CALLBACK auxx(void) { rotx -= 2 ; } void CALLBACK auxY(void) { roty += 2 ; } void CALLBACK auxy(void) { roty -= 2 ; } void CALLBACK auxZ(void) { rotz += 2 ; } void CALLBACK auxz(void) { rotz -= 2 ; } void main() { auxInitDisplayMode(AUX_SINGLE|AUX_RGB); auxInitPosition(0,0,200,200); auxInitWindow("Visualisation"); myinit(); auxKeyFunc(AUX_X,auxX) ; auxKeyFunc(AUX_x,auxx) ; auxKeyFunc(AUX_Y,auxY) ; auxKeyFunc(AUX_y,auxy) ; auxKeyFunc(AUX_Z,auxZ) ; auxKeyFunc(AUX_z,auxz) ; auxReshapeFunc(myReshape); auxMainLoop(display); }