9 void reg_whitted(void);
11 int win_width, win_height;
15 static int reshape_pending;
16 static unsigned int sdr_gamma;
22 if(init_opengl() == -1) {
26 glEnable(GL_DEPTH_TEST);
27 glEnable(GL_CULL_FACE);
29 glEnable(GL_FRAMEBUFFER_SRGB);
32 glEnable(GL_MULTISAMPLE);
37 if(!(sdr_gamma = create_program_load("sdr/post.v.glsl", "sdr/gamma.p.glsl"))) {
38 fprintf(stderr, "Warning: failed to load the gamma correction shader\n");
43 for(i=0; i<num_parts; i++) {
44 if(parts[i]->init() == -1) {
45 fprintf(stderr, "part %s init failed\n", parts[i]->name);
50 switch_part(parts[0]);
54 void demo_cleanup(void)
59 glDeleteProgram(sdr_gamma);
63 for(i=0; i<num_parts; i++) {
68 void demo_display(void)
73 post_reshape(win_width, win_height);
77 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
81 part_time = time_msec - cur_part->start_time;
82 if(part_time < cur_part->in_time) {
83 float t = (float)part_time / cur_part->in_time;
86 long prev_part_time = time_msec - prev_part->start_time;
87 if(prev_part->draw_out) {
88 prev_part->draw_out(prev_part_time, t);
90 prev_part->draw(prev_part_time);
94 if(cur_part->draw_in) {
95 cur_part->draw_in(part_time, t);
97 cur_part->draw(part_time);
101 cur_part->draw(part_time);
104 /* no-srgb gamma correction fallback */
106 glBindTexture(GL_TEXTURE_2D, post_fbtex[0].id);
107 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, win_width, win_height);
109 glUseProgram(sdr_gamma);
110 overlay_tex(post_fbtex, 1.0);
114 void demo_reshape(int x, int y)
120 win_aspect = (float)x / (float)y;
122 glViewport(0, 0, x, y);
124 glMatrixMode(GL_PROJECTION);
126 gluPerspective(50.0, win_aspect, 0.5, 500.0);
129 void demo_keyboard(int key, int st)
131 if(st && key == 27) {
136 if(cur_part && cur_part->keyboard) {
137 cur_part->keyboard(key, st);
142 void demo_mbutton(int bn, int st, int x, int y)
144 if(cur_part && cur_part->mbutton) {
145 cur_part->mbutton(bn, st, x, y);
149 void demo_mmotion(int x, int y)
151 if(cur_part && cur_part->mmotion) {
152 cur_part->mmotion(x, y);
156 void demo_sball_motion(int x, int y, int z)
160 void demo_sball_rotate(int x, int y, int z)
164 void demo_sball_button(int bn, int st)