9 static void display(void);
10 static void keypress(unsigned char key, int x, int y);
11 static void skeypress(int key, int x, int y);
12 static void mouse(int bn, int st, int x, int y);
13 static int translate_key(int key);
15 static int prev_xsz, prev_ysz;
18 int main(int argc, char **argv)
20 glutInit(&argc, argv);
22 load_config("demo.cfg");
23 if(parse_args(argc, argv) == -1) {
27 glutInitWindowSize(1280, 800);
28 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
29 glutCreateWindow("Mindlapse");
31 glutDisplayFunc(display);
32 glutIdleFunc(glutPostRedisplay);
33 glutReshapeFunc(demo_reshape);
34 glutKeyboardFunc(keypress);
35 glutSpecialFunc(skeypress);
37 glutMotionFunc(demo_motion);
40 prev_xsz = glutGet(GLUT_WINDOW_WIDTH);
41 prev_ysz = glutGet(GLUT_WINDOW_HEIGHT);
45 if(demo_init() == -1) {
50 start_time = glutGet(GLUT_ELAPSED_TIME);
56 void swap_buffers(void)
61 static void display(void)
63 sys_time = glutGet(GLUT_ELAPSED_TIME);
68 assert(glGetError() == GL_NO_ERROR);
71 static void keypress(unsigned char key, int x, int y)
82 prev_xsz = glutGet(GLUT_WINDOW_WIDTH);
83 prev_ysz = glutGet(GLUT_WINDOW_HEIGHT);
86 glutReshapeWindow(prev_xsz, prev_ysz);
91 demo_keyboard(key, 1);
95 static void skeypress(int key, int x, int y)
97 if((key = translate_key(key))) {
98 demo_keyboard(key, 1);
102 static void mouse(int bn, int st, int x, int y)
104 int bidx = bn - GLUT_LEFT_BUTTON;
105 int press = st == GLUT_DOWN;
107 demo_mouse(bidx, press, x, y);
110 static int translate_key(int key)
112 if(key >= GLUT_KEY_F1 && key <= GLUT_KEY_F12) {
113 return key - GLUT_KEY_F1 + KEY_F1;
124 case GLUT_KEY_PAGE_UP:
126 case GLUT_KEY_PAGE_DOWN: