rayfract

annotate src/gui.cc @ 5:48e0e7d33d9e

foo
author John Tsiombikas <nuclear@siggraph.org>
date Sat, 28 May 2011 22:31:07 +0300
parents e4349f5804b9
children 8a9aa21b32cf
rev   line source
nuclear@2 1 #include <stdio.h>
nuclear@5 2 #include <math.h>
nuclear@2 3
nuclear@2 4 #ifndef __APPLE__
nuclear@2 5 #include <GL/glut.h>
nuclear@2 6 #else
nuclear@2 7 #include <GLUT/glut.h>
nuclear@2 8 #endif
nuclear@2 9
nuclear@4 10 #include <imtk.h>
nuclear@2 11 #include "gui.h"
nuclear@2 12 #include "sdr.h"
nuclear@3 13 #include "vmath.h"
nuclear@3 14
nuclear@4 15 static int show_gui = 1;
nuclear@5 16 static float fiter = 10;
nuclear@2 17
nuclear@2 18 extern unsigned int sdr;
nuclear@2 19 extern Vector4 seed;
nuclear@2 20 extern int iter;
nuclear@2 21 extern float err_thres;
nuclear@2 22 extern float reflectivity;
nuclear@5 23 extern Vector3 color;
nuclear@2 24
nuclear@2 25 int gui_init(int width, int height)
nuclear@2 26 {
nuclear@4 27 imtk_set_viewport(width, height);
nuclear@5 28 imtk_set_alpha(0.5);
nuclear@2 29 return 0;
nuclear@2 30 }
nuclear@2 31
nuclear@2 32 void gui_draw()
nuclear@2 33 {
nuclear@5 34
nuclear@4 35 if(!show_gui) {
nuclear@4 36 return;
nuclear@4 37 }
nuclear@2 38
nuclear@4 39 imtk_begin();
nuclear@5 40 imtk_layout_start(10, 10, 10, IMTK_HORIZONTAL);
nuclear@2 41
nuclear@5 42 imtk_label("seed x", IMTK_AUTO, IMTK_AUTO);
nuclear@5 43 seed.x = imtk_slider(IMUID, seed.x, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 44 imtk_layout_newline();
nuclear@2 45
nuclear@5 46 imtk_label("seed y", IMTK_AUTO, IMTK_AUTO);
nuclear@5 47 seed.y = imtk_slider(IMUID, seed.y, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 48 imtk_layout_newline();
nuclear@2 49
nuclear@5 50 imtk_label("seed z", IMTK_AUTO, IMTK_AUTO);
nuclear@5 51 seed.z = imtk_slider(IMUID, seed.z, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 52 imtk_layout_newline();
nuclear@2 53
nuclear@5 54 imtk_label("seed w", IMTK_AUTO, IMTK_AUTO);
nuclear@5 55 seed.w = imtk_slider(IMUID, seed.w, -2.0, 2.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 56 imtk_layout_newline();
nuclear@4 57
nuclear@5 58 imtk_label("iterations", IMTK_AUTO, IMTK_AUTO);
nuclear@5 59 fiter = imtk_slider(IMUID, fiter, 0, 32, IMTK_AUTO, IMTK_AUTO);
nuclear@5 60 iter = round(fiter);
nuclear@5 61 imtk_layout_newline();
nuclear@4 62
nuclear@5 63 imtk_label("max error", IMTK_AUTO, IMTK_AUTO);
nuclear@5 64 err_thres = imtk_slider(IMUID, err_thres, 0, 0.075, IMTK_AUTO, IMTK_AUTO);
nuclear@4 65
nuclear@5 66 imtk_layout_start(280, 10, 10, IMTK_HORIZONTAL);
nuclear@5 67 imtk_label("reflectivity", IMTK_AUTO, IMTK_AUTO);
nuclear@5 68 reflectivity = imtk_slider(IMUID, reflectivity, 0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 69 imtk_layout_newline();
nuclear@5 70
nuclear@5 71 imtk_label("diffuse", IMTK_AUTO, IMTK_AUTO);
nuclear@5 72 color.x = color.y = color.z = imtk_slider(IMUID, color.x, 0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@4 73
nuclear@4 74 imtk_end();
nuclear@2 75 }
nuclear@2 76
nuclear@2 77 void gui_set_visible(bool vis)
nuclear@2 78 {
nuclear@4 79 show_gui = vis;
nuclear@2 80 }