/* Une scene OpenGL */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Octobre 2009 */ #include #include #include /* Fonction de modelisation de la scene */ static void element(GLfloat *c1,GLfloat *c2,GLfloat *c3) { glPushMatrix(); glMaterialfv(GL_FRONT,GL_DIFFUSE,c1); glutSolidTorus(0.75,10.0,90,90); glPushMatrix(); glMaterialfv(GL_FRONT,GL_DIFFUSE,c2); glTranslatef(6.0F,0.0F,0.0F); glScalef(12.0F,1.5F,1.5F); glutSolidCube(1.0); glPopMatrix(); glPushMatrix(); glMaterialfv(GL_FRONT,GL_DIFFUSE,c3); glTranslatef(-6.0F,0.0F,0.0F); glScalef(12.0F,1.5F,1.5F); glutSolidCube(1.0); glPopMatrix(); glPopMatrix(); } void scene(void) { const GLfloat l_pos0[] = { 1.0F,1.0F,1.0F,0.0F }; const GLfloat l_pos1[] = { -1.0F,1.0F,1.0F,0.0F }; const GLfloat blanc[4] = { 1.0F,1.0F,1.0F,1.0F }; const GLfloat gris[4] = { 0.6F,0.6F,0.6F,1.0F }; const GLfloat rouge[4] = { 1.0F,0.0F,0.0F,1.0F }; const GLfloat vert[4] = { 0.0F,1.0F,0.0F,1.0F }; const GLfloat bleu[4] = { 0.0F,0.0F,1.0F,1.0F }; const GLfloat jaune[4] = { 1.0F,1.0F,0.0F,1.0F }; const GLfloat cyan[4] = { 0.0F,1.0F,1.0F,1.0F }; const GLfloat magenta[4] = { 1.0F,0.0F,1.0F,1.0F }; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glLightfv(GL_LIGHT0,GL_POSITION,l_pos0); glLightfv(GL_LIGHT1,GL_POSITION,l_pos1); glLightfv(GL_LIGHT0,GL_DIFFUSE,gris); glLightfv(GL_LIGHT1,GL_DIFFUSE,gris); glPushMatrix(); element((GLfloat *) blanc,(GLfloat *) rouge,(GLfloat *) jaune); glPopMatrix(); glPushMatrix(); glRotatef(90.0F,1.0F,0.0F,0.0F); glRotatef(90.0F,0.0F,0.0F,1.0F); element((GLfloat *) blanc,(GLfloat *) vert,(GLfloat *) cyan); glPopMatrix(); glPushMatrix(); glRotatef(90.0F,0.0F,1.0F,0.0F); glRotatef(90.0F,0.0F,0.0F,1.0F); element((GLfloat *) blanc,(GLfloat *) bleu,(GLfloat *) magenta); glPopMatrix(); }