# HG changeset patch # User John Tsiombikas # Date 1306611067 -10800 # Node ID 48e0e7d33d9e00b90a9ec92753c1ee080b02c93e # Parent e4349f5804b93ff8ce443c9e14b3ec3eaeac0679 foo diff -r e4349f5804b9 -r 48e0e7d33d9e src/gui.cc --- a/src/gui.cc Fri Apr 29 07:30:31 2011 +0300 +++ b/src/gui.cc Sat May 28 22:31:07 2011 +0300 @@ -1,4 +1,5 @@ #include +#include #ifndef __APPLE__ #include @@ -11,55 +12,64 @@ #include "sdr.h" #include "vmath.h" - -int xsz, ysz; static int show_gui = 1; +static float fiter = 10; extern unsigned int sdr; extern Vector4 seed; extern int iter; extern float err_thres; extern float reflectivity; +extern Vector3 color; int gui_init(int width, int height) { - xsz = width; - ysz = height; - imtk_set_viewport(width, height); - - /*imtk_set_alpha(0.5);*/ + imtk_set_alpha(0.5); return 0; } void gui_draw() { + if(!show_gui) { return; } imtk_begin(); + imtk_layout_start(10, 10, 10, IMTK_HORIZONTAL); - imtk_label("seed x", 10, 20); - seed.x = imtk_slider(IMUID, seed.x, -1.0, 1.0, 80, 20); + imtk_label("seed x", IMTK_AUTO, IMTK_AUTO); + seed.x = imtk_slider(IMUID, seed.x, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO); + imtk_layout_newline(); - imtk_label("seed y", 10, 50); - seed.y = imtk_slider(IMUID, seed.y, -1.0, 1.0, 80, 50); + imtk_label("seed y", IMTK_AUTO, IMTK_AUTO); + seed.y = imtk_slider(IMUID, seed.y, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO); + imtk_layout_newline(); - imtk_label("seed z", 10, 80); - seed.z = imtk_slider(IMUID, seed.z, -1.0, 1.0, 80, 80); + imtk_label("seed z", IMTK_AUTO, IMTK_AUTO); + seed.z = imtk_slider(IMUID, seed.z, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO); + imtk_layout_newline(); - imtk_label("seed w", 10, 110); - seed.w = imtk_slider(IMUID, seed.w, -1.0, 1.0, 80, 110); + imtk_label("seed w", IMTK_AUTO, IMTK_AUTO); + seed.w = imtk_slider(IMUID, seed.w, -2.0, 2.0, IMTK_AUTO, IMTK_AUTO); + imtk_layout_newline(); - imtk_label("iterations", 10, 140); - iter = imtk_slider(IMUID, iter, 0, 32, 80, 140); + imtk_label("iterations", IMTK_AUTO, IMTK_AUTO); + fiter = imtk_slider(IMUID, fiter, 0, 32, IMTK_AUTO, IMTK_AUTO); + iter = round(fiter); + imtk_layout_newline(); - imtk_label("max error", 10, 170); - err_thres = imtk_slider(IMUID, err_thres, 0, 0.075, 80, 170); + imtk_label("max error", IMTK_AUTO, IMTK_AUTO); + err_thres = imtk_slider(IMUID, err_thres, 0, 0.075, IMTK_AUTO, IMTK_AUTO); - imtk_label("reflectivity", 280, 20); - reflectivity = imtk_slider(IMUID, reflectivity, 0, 1.0, 350, 20); + imtk_layout_start(280, 10, 10, IMTK_HORIZONTAL); + imtk_label("reflectivity", IMTK_AUTO, IMTK_AUTO); + reflectivity = imtk_slider(IMUID, reflectivity, 0, 1.0, IMTK_AUTO, IMTK_AUTO); + imtk_layout_newline(); + + imtk_label("diffuse", IMTK_AUTO, IMTK_AUTO); + color.x = color.y = color.z = imtk_slider(IMUID, color.x, 0, 1.0, IMTK_AUTO, IMTK_AUTO); imtk_end(); } diff -r e4349f5804b9 -r 48e0e7d33d9e src/rayfract.cc --- a/src/rayfract.cc Fri Apr 29 07:30:31 2011 +0300 +++ b/src/rayfract.cc Sat May 28 22:31:07 2011 +0300 @@ -31,7 +31,7 @@ float err_thres = 0.0075; int iter = 10; float reflectivity = 0.2; -Vector3 color(0.9, 0.95, 1.0); +Vector3 color(0.75, 0.75, 0.75); int main(int argc, char **argv) { @@ -109,6 +109,7 @@ set_uniform_float(sdr, "reflectivity", reflectivity); set_uniform_int(sdr, "iter", iter); set_uniform_float(sdr, "err_thres", err_thres); + set_uniform_float3(sdr, "diffuse_color", color.x, color.y, color.z); glMatrixMode(GL_TEXTURE); glPushMatrix(); @@ -145,6 +146,8 @@ glLoadIdentity(); gluPerspective(45.0, (float)x / (float)y, 1.0, 1000.0); + imtk_set_viewport(x, y); + if(ray_tex) { glDeleteTextures(1, &ray_tex); } @@ -207,6 +210,12 @@ glutPostRedisplay(); } break; + + case '\n': + case '\r': + printf("(%.3f %+.3fi %+.3fj %+.3fk) i:%d err: %.4f cam(theta: %.2f phi: %.2f rad: %.2f)\n", seed.w, + seed.x, seed.y, seed.z, iter, err_thres, cam_theta, cam_phi, cam_dist); + break; } imtk_inp_key(key, 1);