rayfract
view src/gui.cc @ 10:1496aae2e7d4
- simplified build by including dependences in the source tree
- added make dep tracking
- added mingw cross-build rules
- added readme & licence
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 31 Jul 2023 18:58:56 +0300 |
parents | 8a9aa21b32cf |
children |
line source
1 #include <stdio.h>
2 #include <math.h>
4 #ifndef __APPLE__
5 #include <GL/glut.h>
6 #else
7 #include <GLUT/glut.h>
8 #endif
10 #include <imtk.h>
11 #include "gui.h"
12 #include "sdr.h"
13 #include "vmath.h"
15 static int show_gui = 1;
16 static float fiter = 10;
18 extern unsigned int sdr;
19 extern Vector4 seed;
20 extern int iter;
21 extern float err_thres;
22 extern float reflectivity;
23 extern Vector3 color;
25 int gui_init(int width, int height)
26 {
27 imtk_set_viewport(width, height);
28 imtk_set_alpha(0.5);
29 return 0;
30 }
32 void gui_draw()
33 {
35 if(!show_gui) {
36 return;
37 }
39 imtk_begin();
40 imtk_layout_start(10, 10);
41 imtk_layout_spacing(10);
42 imtk_layout_dir(IMTK_HORIZONTAL);
44 imtk_label("seed x", IMTK_AUTO, IMTK_AUTO);
45 seed.x = imtk_slider(IMUID, seed.x, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
46 imtk_layout_newline();
48 imtk_label("seed y", IMTK_AUTO, IMTK_AUTO);
49 seed.y = imtk_slider(IMUID, seed.y, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
50 imtk_layout_newline();
52 imtk_label("seed z", IMTK_AUTO, IMTK_AUTO);
53 seed.z = imtk_slider(IMUID, seed.z, -1.0, 1.0, IMTK_AUTO, IMTK_AUTO);
54 imtk_layout_newline();
56 imtk_label("seed w", IMTK_AUTO, IMTK_AUTO);
57 seed.w = imtk_slider(IMUID, seed.w, -2.0, 2.0, IMTK_AUTO, IMTK_AUTO);
58 imtk_layout_newline();
60 imtk_label("iterations", IMTK_AUTO, IMTK_AUTO);
61 fiter = (float)iter;
62 fiter = imtk_slider(IMUID, fiter, 0, 32, IMTK_AUTO, IMTK_AUTO);
63 iter = round(fiter);
64 imtk_layout_newline();
66 imtk_label("max error", IMTK_AUTO, IMTK_AUTO);
67 err_thres = imtk_slider(IMUID, err_thres, 0, 0.01, IMTK_AUTO, IMTK_AUTO);
69 imtk_layout_start(280, 10);
70 imtk_label("reflectivity", IMTK_AUTO, IMTK_AUTO);
71 reflectivity = imtk_slider(IMUID, reflectivity, 0, 1.0, IMTK_AUTO, IMTK_AUTO);
72 imtk_layout_newline();
74 imtk_label("diffuse", IMTK_AUTO, IMTK_AUTO);
75 color.x = color.y = color.z = imtk_slider(IMUID, color.x, 0, 1.0, IMTK_AUTO, IMTK_AUTO);
77 imtk_end();
78 }
80 void gui_set_visible(bool vis)
81 {
82 show_gui = vis;
83 }