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 glMatrixMode(GL_MODELVIEW);
76 glTranslatef(0, 0, -cam_dist);
77 glRotatef(cam_phi, 1, 0, 0);
78 glRotatef(cam_theta, 0, 1, 0);
80 glRotatef(-cam_theta, 0, 1, 0);
81 glRotatef(-cam_phi, 1, 0, 0);
82 glTranslatef(0, 0, cam_dist);
85 glUniform1f(uloc_aspect, win_aspect);
100 overlay_tex(dbgtex, dbg_alpha);
104 static void mbutton(int bn, int st, int x, int y)
113 if(dbg_alpha > 1.0) dbg_alpha = 1.0;
117 if(dbg_alpha < 0.0) dbg_alpha = 0.0;
121 static void mmotion(int x, int y)
123 int dx = x - mouse_x;
124 int dy = y - mouse_y;
128 if(!(dx | dy)) return;
131 cam_theta += dx * 0.5;
133 if(cam_phi < -90) cam_phi = -90;
134 if(cam_phi > 90) cam_phi = 90;
137 cam_dist += dy * 0.1;
138 if(cam_dist < 0) cam_dist = 0;