/* Auteur: Nicolas JANEY */ /* Avril 2001 */ /* Illustration de l'utilisation */ /* du reshape en OpenGL + Aux */ #include #include #include #include #include #include static int proj = 0 ; static int ww ; static int hh ; void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if ( proj ) glOrtho(-10.0,10.0,-10.0,10.0,-10.0,10.0); else glOrtho(-10.0,10.0,-10.0*(double) hh/ww,10.0*(double) hh/ww,-10.0,10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); auxWireSphere(7.0) ; glPopMatrix(); glFlush(); } void myinit (void) { glClearColor(0.0,0.0,0.0,1.0); } void CALLBACK myReshape(int w,int h) { glViewport(0,0,w,h); ww = w ; hh = h ; } void CALLBACK keyP(void) { proj++; proj %= 2; } void CALLBACK keyp(void) { proj++; proj %= 2; } void main(void) { auxInitDisplayMode(AUX_SINGLE|AUX_RGB); auxInitPosition(0,0,200,200); auxInitWindow("Reshape homothétique"); myinit(); auxKeyFunc(AUX_P,keyP); auxKeyFunc(AUX_p,keyp); auxReshapeFunc(myReshape); auxMainLoop(display); }