/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Novembre 2005 */ /* Parametrage d'une camera de visualisation */ #include #include #include #include "ModuleCouleurs.h" #include "ModuleMenus.h" #include "ModuleReshape.h" #include "ModuleManipulateur.h" void myinit(void) { GLfloat shinines[] = { 50.0 }; GLfloat l_pos[] = { 1.0,1.0,1.0,0.0 }; glClearColor(0.5F,0.5F,1.0F,1.0F) ; glMaterialfv(GL_FRONT,GL_SPECULAR,couleurBlanc()); glMaterialfv(GL_FRONT,GL_SHININESS,shinines); glLightfv(GL_LIGHT0,GL_POSITION,l_pos); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); } void reshape(int w,int h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(24.0,(float) w/h,750.0,1250.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(-300.0, 200.0,-100.0, 300.0,-400.0, 400.0, 0.0, 0.0, 1.0); } void objet(void) { glPushMatrix(); glPushMatrix(); glTranslatef(0.0F,0.0F,-150.0F); glutSolidCone(20.0F,300.0F,36,36); glPopMatrix(); glutSolidTorus(10.0,190.0,36,36); glRotatef(90.0F,1.0F,0.0F,0.0F); glutSolidTorus(10.0,190.0,36,36); glRotatef(90.0F,0.0F,1.0F,0.0F); glutSolidTorus(10.0,190.0,36,36); glPopMatrix(); } void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(300.0F,-400.0F, 400.0F); manipulateurSouris(); manipulateurClavier(); objet(); glPopMatrix(); glFlush(); glutSwapBuffers(); } int main(int argc,char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE); glutInitWindowSize(250,250); glutInitWindowPosition(50,50); glutCreateWindow("Gestion caméra"); myinit(); creationMenuBasique(); glutReshapeFunc(reshape); glutKeyboardFunc(keyBasique); glutSpecialFunc(specialBasique); glutMotionFunc(motionBasique); glutMouseFunc(sourisBasique); glutDisplayFunc(display); glutMainLoop(); return(0); }