1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| bool bufferClavier[4] = {false};
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(200,200);
glutInitWindowSize(640,480);
glutCreateWindow("window");
// Initialisation d'OpenGL
glClearColor(0.0,0.0,0.0,0.0);
glColor3f(1.0,1.0,1.0);
glEnable(GL_DEPTH_TEST);
// enregistrement des fonctions de rappel
glutReshapeFunc(Reshape);
glutDisplayFunc(Draw);
glutKeyboardFunc(ClavierKeyPress); // callback touche appuyée
glutKeyboardUpFunc(ClavierKeyRelease); // callback touche relachée
// Entree dans la boucle principale glut
glutMainLoop();
return 0;
}
void GestionClavier(unsigned char key, bool press)
{
If (key == z)
bufferClavier[0] = press;
}
void ClavierKeyPress(unsigned char key, int x, int y)
{
GestionClavier(key, true);
}
void ClavierKeyRelease(unsigned char key, int x, int y)
{
GestionClavier(key, false);
} |