/* Auteur: Nicolas JANEY */ /* Avril 2001 */ /* Illustration des ombrages plat */ /* et lisses en solid et fil de fer */ #include #include #include #include #include #include static int mode = 0 ; static int aff = 1 ; void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); if ( mode ) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); glPushMatrix() ; glTranslatef(-0.8F,0.0F,0.0F); glRotatef(50.0F,1.0F,1.0F,1.0F); if ( aff ) auxSolidSphere(1.1) ; else auxWireSphere(1.1) ; glPopMatrix() ; glPushMatrix() ; glTranslatef(0.9F,-0.9F,0.0F); glRotatef(-70.0F,1.0F,0.0F,0.0F); if ( aff ) auxSolidCone(0.9,2.0) ; else auxWireCone(0.9,2.0) ; glPopMatrix() ; glPushMatrix() ; glTranslatef(0.8F,0.1F,0.0F); glRotatef(-70.0F,1.0F,0.0F,0.0F); if ( aff ) auxSolidTorus(0.35,0.8) ; else auxWireTorus(0.35,0.8) ; glPopMatrix() ; glFlush(); auxSwapBuffers(); } void myinit (void) { glClearColor(1.0,1.0,1.0,1.0); glEnable(GL_DEPTH_TEST) ; glEnable(GL_LIGHTING) ; glEnable(GL_LIGHT0) ; float dir[] = {0.1F,0.8F,1.6F,0.0F} ; glLightfv(GL_LIGHT0,GL_POSITION,dir) ; } void CALLBACK myReshape(int w, int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.0,2.0,-2.0/w*h,2.0/w*h,-2.0,2.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void CALLBACK auxSpace(void) { mode = 1 - mode ; } void CALLBACK auxReturn(void) { aff = 1 - aff ; } void main(void) { auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA|AUX_DEPTH); auxInitPosition(0,0,300,200); auxInitWindow("Affichages flat et smooth en solide et fil de fer") ; myinit(); auxKeyFunc(AUX_SPACE,auxSpace) ; auxKeyFunc(AUX_RETURN,auxReturn) ; auxReshapeFunc(myReshape); auxMainLoop(display); }