13 static void display();
15 static void reshape(int x, int y);
16 static void key_press(unsigned char key, int x, int y);
17 static void key_release(unsigned char key, int x, int y);
18 static void mouse(int bn, int st, int x, int y);
19 static void proc_modkeys();
21 static unsigned int start_time;
22 static unsigned int modkeys;
24 int main(int argc, char **argv)
26 glutInitWindowSize(1024, 768);
27 glutInit(&argc, argv);
28 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | GLUT_MULTISAMPLE);
29 glutCreateWindow("demo");
31 glutDisplayFunc(display);
33 glutReshapeFunc(reshape);
34 glutKeyboardFunc(key_press);
35 glutKeyboardUpFunc(key_release);
37 glutMotionFunc(app_mouse_motion);
38 glutPassiveMotionFunc(app_mouse_motion);
49 void app_swap_buffers()
59 unsigned int app_get_modifiers()
72 start_time = glutGet(GLUT_ELAPSED_TIME);
78 time_msec = glutGet(GLUT_ELAPSED_TIME) - start_time;
87 static void reshape(int x, int y)
95 static void key_press(unsigned char key, int x, int y)
98 app_keyboard(key, true);
101 static void key_release(unsigned char key, int x, int y)
104 app_keyboard(key, false);
107 static void mouse(int bn, int st, int x, int y)
109 int bidx = bn - GLUT_LEFT_BUTTON;
110 bool down = st == GLUT_DOWN;
113 app_mouse_button(bidx, down, x, y);
116 static void proc_modkeys()
118 int glutmod = glutGetModifiers();
121 if(glutmod & GLUT_ACTIVE_SHIFT) {
122 modkeys |= MOD_SHIFT;
124 if(glutmod & GLUT_ACTIVE_CTRL) {
127 if(glutmod & GLUT_ACTIVE_ALT) {