10 static void destroy(void);
11 static void start(void);
12 static void stop(void);
13 static void draw(long tm);
14 static void mbutton(int bn, int st, int x, int y);
15 static void mmotion(int x, int y);
18 static struct demo_part part = {
29 static float cam_theta, cam_phi, cam_dist = 6;
31 static int bnstate[8];
32 static int mouse_x, mouse_y;
34 static unsigned int sdr;
35 static int uloc_aspect;
37 static struct texture *dbgtex;
38 static float dbg_alpha;
41 void reg_whitted(void)
49 if(!(sdr = create_program_load("sdr/whitted.v.glsl", "sdr/whitted.p.glsl"))) {
52 uloc_aspect = get_uniform_loc(sdr, "aspect");
54 dbgtex = load_texture("data/dbg_whitted.jpg");
59 static void destroy(void)
64 static void start(void)
68 static void stop(void)
72 static void draw(long tm)
74 static float vgn_offset = 0.47;
75 static float vgn_sharp = 3.1;
77 glDisable(GL_DEPTH_TEST);
79 glMatrixMode(GL_MODELVIEW);
82 glTranslatef(0, 0, -cam_dist);
83 glRotatef(cam_phi, 1, 0, 0);
84 glRotatef(cam_theta, 0, 1, 0);
86 glRotatef(-cam_theta, 0, 1, 0);
87 glRotatef(-cam_phi, 1, 0, 0);
88 glTranslatef(0, 0, cam_dist);
91 glUniform1f(uloc_aspect, win_aspect);
104 vignette(0.15, 0.05, 0.15, vgn_offset, vgn_sharp);
106 if(dbgtex && dbg_alpha > 0.0) {
108 glMatrixMode(GL_TEXTURE);
111 overlay_tex(dbgtex, dbg_alpha);
112 glMatrixMode(GL_TEXTURE);
120 imtk_layout_start(10, 20);
121 imtk_layout_spacing(10);
123 imtk_layout_dir(IMTK_HORIZONTAL);
125 imtk_label("offset:", IMTK_AUTO, IMTK_AUTO);
126 vgn_offset = imtk_slider(IMUID, vgn_offset, 0.0, 1.5, IMTK_AUTO, IMTK_AUTO);
127 imtk_layout_newline();
129 imtk_label("sharpness:", IMTK_AUTO, IMTK_AUTO);
130 vgn_sharp = imtk_slider(IMUID, vgn_sharp, 0, 10, IMTK_AUTO, IMTK_AUTO);
131 imtk_layout_newline();
136 static void mbutton(int bn, int st, int x, int y)
144 if(imtk_layout_contains(x, y)) {
145 imtk_inp_mouse(bn, st);
150 if(dbg_alpha > 1.0) dbg_alpha = 1.0;
154 if(dbg_alpha < 0.0) dbg_alpha = 0.0;
158 static void mmotion(int x, int y)
160 int dx = x - mouse_x;
161 int dy = y - mouse_y;
165 if(!(dx | dy)) return;
167 if(imtk_layout_contains(x, y)) {
168 imtk_inp_motion(x, y);
173 cam_theta += dx * 0.5;
175 if(cam_phi < -90) cam_phi = -90;
176 if(cam_phi > 90) cam_phi = 90;
179 cam_dist += dy * 0.1;
180 if(cam_dist < 0) cam_dist = 0;