7 static void destroy(void);
8 static void start(void);
9 static void stop(void);
10 static void draw(long tm);
11 static void mbutton(int bn, int st, int x, int y);
12 static void mmotion(int x, int y);
15 static struct demo_part part = {
26 static float cam_theta, cam_phi, cam_dist = 8;
28 static int bnstate[8];
29 static int mouse_x, mouse_y;
31 static unsigned int sdr;
32 static int uloc_aspect;
35 void reg_whitted(void)
43 if(!(sdr = create_program_load("sdr/whitted.v.glsl", "sdr/whitted.p.glsl"))) {
46 uloc_aspect = get_uniform_loc(sdr, "aspect");
50 static void destroy(void)
54 static void start(void)
58 static void stop(void)
62 static void draw(long tm)
64 glMatrixMode(GL_MODELVIEW);
67 glTranslatef(0, 0, -cam_dist);
68 glRotatef(cam_phi, 1, 0, 0);
69 glRotatef(cam_theta, 0, 1, 0);
71 glRotatef(-cam_theta, 0, 1, 0);
72 glRotatef(-cam_phi, 1, 0, 0);
73 glTranslatef(0, 0, cam_dist);
76 glUniform1f(uloc_aspect, win_aspect);
90 static void mbutton(int bn, int st, int x, int y)
97 static void mmotion(int x, int y)
100 int dy = y - mouse_y;
104 if(!(dx | dy)) return;
107 cam_theta += dx * 0.5;
109 if(cam_phi < -90) cam_phi = -90;
110 if(cam_phi > 90) cam_phi = 90;
113 cam_dist += dy * 0.1;
114 if(cam_dist < 0) cam_dist = 0;