7 static void idle(void);
8 static void keydown(unsigned char key, int x, int y);
9 static void keyup(unsigned char key, int x, int y);
10 static void skeydown(int key, int x, int y);
11 static void skeyup(int key, int x, int y);
12 static void mouse(int bn, int st, int x, int y);
13 static int translate_skey(int key);
16 int main(int argc, char **argv)
18 glutInit(&argc, argv);
19 glutInitWindowSize(640, 480);
20 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
21 glutCreateWindow("deeprace");
23 glutDisplayFunc(game_display);
25 glutReshapeFunc(game_reshape);
26 glutKeyboardFunc(keydown);
27 glutKeyboardUpFunc(keyup);
28 glutSpecialFunc(skeydown);
29 glutSpecialUpFunc(skeyup);
31 glutMotionFunc(game_motion);
33 if(game_init() == -1) {
36 atexit(game_shutdown);
41 void game_swap_buffers(void)
44 assert(glGetError() == GL_NO_ERROR);
53 static void idle(void)
58 static void keydown(unsigned char key, int x, int y)
60 game_keyboard(key, 1);
63 static void keyup(unsigned char key, int x, int y)
65 game_keyboard(key, 0);
68 static void skeydown(int key, int x, int y)
70 int k = translate_skey(key);
76 static void skeyup(int key, int x, int y)
78 int k = translate_skey(key);
84 static void mouse(int bn, int st, int x, int y)
86 game_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
89 static int translate_skey(int key)
100 case GLUT_KEY_PAGE_UP:
102 case GLUT_KEY_PAGE_DOWN:
108 case GLUT_KEY_INSERT:
111 if(key >= GLUT_KEY_F1 && key <= GLUT_KEY_F12) {
112 return key - (GLUT_KEY_F1 + GKEY_F1);