istereo2
view src/ui.cc @ 6:3bccfc7d10fe
goatkit is drawing
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 23 Sep 2015 05:44:58 +0300 |
parents | |
children | a3c4fcc9f8f3 |
line source
1 #include "ui.h"
2 #include "goatkit/goatkit.h"
3 #include "opengl.h"
4 #include "sdr.h"
6 static goatkit::Screen scr;
7 static int width, height;
9 extern unsigned int prog_color, prog_ui;
11 int ui_init(void)
12 {
13 float ypos = 0;
14 float vsep = 0.1;
16 goatkit::Label *label = new goatkit::Label;
17 label->set_position(0.5, ypos += vsep);
18 label->set_size(0.1, 0.1);
19 label->set_text("Stereoscopic rendering");
20 scr.add_widget(label);
22 /*
23 goatkit::Button *button = new goatkit::Button;
24 button->set_position(300, ypos += vsep);
25 button->set_size(200, 40);
26 button->set_text("a button!");
27 button->set_callback(goatkit::EV_CLICK, callback);
28 scr.add_widget(button);
30 goatkit::TextBox *text = new goatkit::TextBox;
31 text->set_position(300, ypos += vsep);
32 text->set_size(200, 30);
33 text->set_text("foo");
34 text->set_callback(goatkit::EV_CHANGE, callback);
35 scr.add_widget(text);
37 goatkit::CheckBox *cbox = new goatkit::CheckBox;
38 cbox->set_position(300, ypos += vsep);
39 cbox->set_size(200, 20);
40 cbox->set_text("a checkbox!");
41 cbox->set_callback(goatkit::EV_CHANGE, callback);
42 scr.add_widget(cbox);
44 goatkit::Slider *slider = new goatkit::Slider;
45 slider->set_position(300, ypos += vsep);
46 slider->set_size(200, 40);
47 slider->set_callback(goatkit::EV_CHANGE, callback);
48 slider->set_continuous_change(false);
49 slider->set_range(0, 100.0);
50 scr.add_widget(slider);
52 goatkit::Slider *intslider = new goatkit::Slider;
53 intslider->set_position(300, ypos += vsep);
54 intslider->set_size(200, 40);
55 intslider->set_callback(goatkit::EV_CHANGE, callback);
56 intslider->set_continuous_change(false);
57 intslider->set_range(0, 100.0);
58 intslider->set_step(10);
59 scr.add_widget(intslider);
60 */
62 scr.show();
64 // load the theme
65 //goatkit::add_theme_path("themes/simple");
67 //goatkit::theme = new goatkit::Theme;
68 //goatkit::theme->load("simple");
70 return 0;
71 }
73 void ui_shutdown(void)
74 {
75 }
77 void ui_reshape(int x, int y)
78 {
79 width = x;
80 height = y;
81 }
83 void ui_draw(void)
84 {
85 float aspect = (float)width / (float)height;
87 bind_program(prog_ui);
89 gl_matrix_mode(GL_PROJECTION);
90 gl_push_matrix();
91 gl_load_identity();
92 gl_scalef(2.0 / aspect, 2.0, 1);
93 gl_translatef(-1, -1, 0);
94 gl_scalef(1, -1, 1);
95 gl_matrix_mode(GL_MODELVIEW);
96 gl_push_matrix();
97 gl_load_identity();
99 glDisable(GL_CULL_FACE);
100 glDisable(GL_DEPTH_TEST);
102 /*gl_begin(GL_QUADS);
103 gl_color3f(1, 0, 0);
104 gl_vertex3f(0, 0, 0);
105 gl_vertex3f(0, 0.5, 0);
106 gl_vertex3f(0.5 * aspect, 0.5, 0);
107 gl_vertex3f(0.5 * aspect, 0, 0);
108 gl_end();
109 */
111 scr.draw();
113 glEnable(GL_CULL_FACE);
114 glEnable(GL_DEPTH_TEST);
117 gl_matrix_mode(GL_PROJECTION);
118 gl_pop_matrix();
119 gl_matrix_mode(GL_MODELVIEW);
120 gl_pop_matrix();
121 }
123 void ui_button(int bn, int press, int x, int y)
124 {
125 scr.sysev_mouse_button(bn, press != 0, (float)x / (float)width, 1.0 - (float)y / (float)height);
126 }
128 void ui_motion(int x, int y)
129 {
130 scr.sysev_mouse_motion((float)x / (float)width, 1.0 - (float)y / (float)height);
131 }