rayfract

annotate src/gui.cc @ 6:8a9aa21b32cf

added spaceball support through GLUT
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 18 Jun 2011 01:04:25 +0300
parents 48e0e7d33d9e
children 1496aae2e7d4
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@6 40 imtk_layout_start(10, 10);
nuclear@6 41 imtk_layout_spacing(10);
nuclear@6 42 imtk_layout_dir(IMTK_HORIZONTAL);
nuclear@2 43
nuclear@5 44 imtk_label("seed x", IMTK_AUTO, IMTK_AUTO);
nuclear@5 45 seed.x = imtk_slider(IMUID, seed.x, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 46 imtk_layout_newline();
nuclear@2 47
nuclear@5 48 imtk_label("seed y", IMTK_AUTO, IMTK_AUTO);
nuclear@5 49 seed.y = imtk_slider(IMUID, seed.y, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 50 imtk_layout_newline();
nuclear@2 51
nuclear@5 52 imtk_label("seed z", IMTK_AUTO, IMTK_AUTO);
nuclear@5 53 seed.z = imtk_slider(IMUID, seed.z, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 54 imtk_layout_newline();
nuclear@2 55
nuclear@5 56 imtk_label("seed w", IMTK_AUTO, IMTK_AUTO);
nuclear@5 57 seed.w = imtk_slider(IMUID, seed.w, -2.0, 2.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 58 imtk_layout_newline();
nuclear@4 59
nuclear@5 60 imtk_label("iterations", IMTK_AUTO, IMTK_AUTO);
nuclear@6 61 fiter = (float)iter;
nuclear@5 62 fiter = imtk_slider(IMUID, fiter, 0, 32, IMTK_AUTO, IMTK_AUTO);
nuclear@5 63 iter = round(fiter);
nuclear@5 64 imtk_layout_newline();
nuclear@4 65
nuclear@5 66 imtk_label("max error", IMTK_AUTO, IMTK_AUTO);
nuclear@5 67 err_thres = imtk_slider(IMUID, err_thres, 0, 0.075, IMTK_AUTO, IMTK_AUTO);
nuclear@4 68
nuclear@6 69 imtk_layout_start(280, 10);
nuclear@5 70 imtk_label("reflectivity", IMTK_AUTO, IMTK_AUTO);
nuclear@5 71 reflectivity = imtk_slider(IMUID, reflectivity, 0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@5 72 imtk_layout_newline();
nuclear@5 73
nuclear@5 74 imtk_label("diffuse", IMTK_AUTO, IMTK_AUTO);
nuclear@5 75 color.x = color.y = color.z = imtk_slider(IMUID, color.x, 0, 1.0, IMTK_AUTO, IMTK_AUTO);
nuclear@4 76
nuclear@4 77 imtk_end();
nuclear@2 78 }
nuclear@2 79
nuclear@2 80 void gui_set_visible(bool vis)
nuclear@2 81 {
nuclear@4 82 show_gui = vis;
nuclear@2 83 }