9 static void destroy(void);
10 static void start(void);
11 static void stop(void);
12 static void draw(long tm);
13 static void mbutton(int bn, int st, int x, int y);
14 static void mmotion(int x, int y);
17 static struct demo_part part = {
28 static float cam_theta, cam_phi, cam_dist = 6;
30 static int bnstate[8];
31 static int mouse_x, mouse_y;
33 static unsigned int sdr;
34 static int uloc_aspect;
36 static struct texture *dbgtex;
37 static float dbg_alpha;
40 void reg_whitted(void)
48 if(!(sdr = create_program_load("sdr/whitted.v.glsl", "sdr/whitted.p.glsl"))) {
51 uloc_aspect = get_uniform_loc(sdr, "aspect");
53 dbgtex = load_texture("data/dbg_whitted.jpg");
58 static void destroy(void)
63 static void start(void)
67 static void stop(void)
71 static void draw(long tm)
73 glDisable(GL_DEPTH_TEST);
75 glMatrixMode(GL_MODELVIEW);
78 glTranslatef(0, 0, -cam_dist);
79 glRotatef(cam_phi, 1, 0, 0);
80 glRotatef(cam_theta, 0, 1, 0);
82 glRotatef(-cam_theta, 0, 1, 0);
83 glRotatef(-cam_phi, 1, 0, 0);
84 glTranslatef(0, 0, cam_dist);
87 glUniform1f(uloc_aspect, win_aspect);
100 vignette(0.43, 0.38, 0.45, 0.8, 1.0);
102 if(dbgtex && dbg_alpha > 0.0) {
104 glMatrixMode(GL_TEXTURE);
107 overlay_tex(dbgtex, dbg_alpha);
108 glMatrixMode(GL_TEXTURE);
113 static void mbutton(int bn, int st, int x, int y)
122 if(dbg_alpha > 1.0) dbg_alpha = 1.0;
126 if(dbg_alpha < 0.0) dbg_alpha = 0.0;
130 static void mmotion(int x, int y)
132 int dx = x - mouse_x;
133 int dy = y - mouse_y;
137 if(!(dx | dy)) return;
140 cam_theta += dx * 0.5;
142 if(cam_phi < -90) cam_phi = -90;
143 if(cam_phi > 90) cam_phi = 90;
146 cam_dist += dy * 0.1;
147 if(cam_dist < 0) cam_dist = 0;