/* Auteur: Nicolas JANEY */ /* Avril 2001 */ /* Une sphere blanche illuminee en OpenGL */ #include #include #include #include void myinit(void) { GLfloat specular[] = { 1.0,1.0,1.0,1.0 }; GLfloat shinines[] = { 50.0 }; GLfloat l_pos[] = { 1.0,1.0,1.0,0.0 }; glClearColor(0.5,0.5,1.0,1.0) ; glMaterialfv(GL_FRONT,GL_SPECULAR,specular); glMaterialfv(GL_FRONT,GL_SHININESS,shinines); glLightfv(GL_LIGHT0,GL_POSITION,l_pos); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); } void CALLBACK display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); auxSolidSphere(1.0); glFlush(); } void CALLBACK myReshape(int w,int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) glOrtho(-1.5,1.5,-1.5*(float)h/(float)w,1.5*(float)h/(float)w,-10.,10.); else glOrtho(-1.5*(float)w/(float)h,1.5*(float)w/(float)h,-1.5,1.5,-10.,10.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void main(void) { auxInitDisplayMode(AUX_SINGLE|AUX_RGB|AUX_DEPTH); auxInitPosition(0,0,250,250); auxInitWindow("Sphère blanche"); myinit(); auxReshapeFunc(myReshape); auxMainLoop(display); }