kaloskagatos  |  
   j'essaie de me familiariser avec glut mais je n'arrive pas à afficher les touches que j'enfonce. Est-ce que quelqu'un peut compiler ça et me dire si ça marche pour lui? (je suis sous windows mais c'est pour linux à terme). C'est un fichier de tutorial que je modifie pour tester.
    
 
 Code :
 - #include <gl/glut.h>
 - #include <stdio.h>
 - #define WIDTH 640
 - #define HEIGHT 480
 - void Display();
 - void Reshape(int,int);
 - void Init();
 - void Clavier( unsigned char key, int x, int y );
 - ////////////////////////////////////////////////////////////////////////////
 - int main( int argc, char *argv[ ])
 - {
 - 	glutInit(&argc,argv);
 - 	glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH);
 -     glutInitWindowSize(WIDTH,HEIGHT);
 - 	glutInitWindowPosition(50,50);
 - 	glutCreateWindow("Scène 3D" );
 - 	Init();
 - 	glutDisplayFunc(Display);
 - 	glutReshapeFunc(Reshape);
 - 	glutKeyboardFunc (Clavier);
 - 	glutMainLoop();
 - 	return 0;
 - }
 - void Init()
 - {
 - 	glEnable(GL_DEPTH_TEST);
 - }
 - void Display()
 - {
 - 	glClearColor(0,0,0,0); // selectionne la couleur noire (qui est celle par défaut)
 - 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 - 	glMatrixMode(GL_MODELVIEW);
 - 	glLoadIdentity();
 - 	gluLookAt(4,3,3,0,0,0,0,1,0);
 - 	glBegin(GL_QUADS);
 - 	glColor3d(1,0,0);
 - 	glVertex3i(1,1,1);
 - 	glVertex3i(1,-1,1);
 - 	glVertex3i(-1,-1,1);
 - 	glVertex3i(-1,1,1);
 - 	glColor3d(0,1,0);
 - 	glVertex3i(1,1,-1);
 - 	glVertex3i(1,-1,-1);
 - 	glVertex3i(-1,-1,-1);
 - 	glVertex3i(-1,1,-1);
 - 	glColor3d(0,0,1);
 - 	glVertex3i(1,1,1);
 - 	glVertex3i(1,-1,1);
 - 	glVertex3i(1,-1,-1);
 - 	glVertex3i(1,1,-1);
 - 	glColor3d(0,1,1);
 - 	glVertex3i(-1,1,1);
 - 	glVertex3i(-1,-1,1);
 - 	glVertex3i(-1,-1,-1);
 - 	glVertex3i(-1,1,-1);
 - 	glColor3d(1,1,0);
 - 	glVertex3i(-1,1,-1);
 - 	glVertex3i(-1,1,1);
 - 	glVertex3i(1,1,1);
 - 	glVertex3i(1,1,-1);
 - 	glColor3d(1,0,1);
 - 	glVertex3i(-1,-1,-1);
 - 	glVertex3i(-1,-1,1);
 - 	glVertex3i(1,-1,1);
 - 	glVertex3i(1,-1,-1);
 - 	glEnd();
 - 	glFlush();
 - }
 - void Reshape(int w, int h)
 - {
 - 	glViewport(0,0,w,h);
 - 	glMatrixMode(GL_PROJECTION); // Choisit la matrice de projection
 - 	glLoadIdentity();
 - 	gluPerspective(45.0,(float) w/h,1.,10.);
 - 	printf("reshape\n" );
 - }
 - void Clavier( unsigned char key, int x, int y )
 - {
 -      printf("touche %c (ASCII:%d)\n",key,key);
 - }
 
  |  
    |