6 void reg_whitted(void);
8 int win_width, win_height;
17 if(init_opengl() == -1) {
21 glEnable(GL_DEPTH_TEST);
22 glEnable(GL_CULL_FACE);
23 glEnable(GL_FRAMEBUFFER_SRGB);
24 glEnable(GL_MULTISAMPLE);
28 for(i=0; i<num_parts; i++) {
29 if(parts[i]->init() == -1) {
30 fprintf(stderr, "part %s init failed\n", parts[i]->name);
35 switch_part(parts[0]);
39 void demo_cleanup(void)
43 for(i=0; i<num_parts; i++) {
48 void demo_display(void)
52 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
56 part_time = time_msec - cur_part->start_time;
57 if(part_time < cur_part->in_time) {
58 float t = (float)part_time / cur_part->in_time;
61 long prev_part_time = time_msec - prev_part->start_time;
62 if(prev_part->draw_out) {
63 prev_part->draw_out(prev_part_time, t);
65 prev_part->draw(prev_part_time);
69 if(cur_part->draw_in) {
70 cur_part->draw_in(part_time, t);
72 cur_part->draw(part_time);
76 cur_part->draw(part_time);
80 void demo_reshape(int x, int y)
84 win_aspect = (float)x / (float)y;
86 glViewport(0, 0, x, y);
88 glMatrixMode(GL_PROJECTION);
90 gluPerspective(50.0, win_aspect, 0.5, 500.0);
93 void demo_keyboard(int key, int st)
100 if(cur_part && cur_part->keyboard) {
101 cur_part->keyboard(key, st);
106 void demo_mbutton(int bn, int st, int x, int y)
108 if(cur_part && cur_part->mbutton) {
109 cur_part->mbutton(bn, st, x, y);
113 void demo_mmotion(int x, int y)
115 if(cur_part && cur_part->mmotion) {
116 cur_part->mmotion(x, y);
120 void demo_sball_motion(int x, int y, int z)
124 void demo_sball_rotate(int x, int y, int z)
128 void demo_sball_button(int bn, int st)