istereo2
diff src/ui.cc @ 14:018f997dc646
button done
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 29 Sep 2015 01:11:54 +0300 |
parents | ea928c313344 |
children | 7bd4264bf74a |
line diff
1.1 --- a/src/ui.cc Mon Sep 28 19:04:50 2015 +0300 1.2 +++ b/src/ui.cc Tue Sep 29 01:11:54 2015 +0300 1.3 @@ -15,24 +15,25 @@ 1.4 static goatkit::Screen scr; 1.5 static float aspect; 1.6 static int width, height; 1.7 +static int virt_width, virt_height; 1.8 1.9 extern unsigned int prog_color, prog_ui; 1.10 1.11 int ui_init(void) 1.12 { 1.13 - float xpos = 0.25; 1.14 - float ypos = 0.8; 1.15 - float vsep = 0.1; 1.16 + float xpos = 100; 1.17 + float ypos = 50; 1.18 + float vsep = 50; 1.19 1.20 /*goatkit::Label *label = new goatkit::Label; 1.21 label->set_position(xpos, ypos); 1.22 - label->set_size(0.1, 0.1); 1.23 + label->set_size(20, 20); 1.24 label->set_text("Stereoscopic rendering"); 1.25 scr.add_widget(label);*/ 1.26 1.27 goatkit::Button *button = new goatkit::Button; 1.28 button->set_position(xpos, ypos); 1.29 - button->set_size(0.2, 0.1); 1.30 + button->set_size(80, 30); 1.31 button->set_text("Done"); 1.32 button->set_callback(goatkit::EV_CLICK, done_bn_handler); 1.33 scr.add_widget(button); 1.34 @@ -91,6 +92,9 @@ 1.35 width = x; 1.36 height = y; 1.37 aspect = (float)width / (float)height; 1.38 + 1.39 + virt_width = 500.0 * aspect; 1.40 + virt_height = 500.0; 1.41 } 1.42 1.43 void ui_draw(void) 1.44 @@ -100,8 +104,7 @@ 1.45 gl_matrix_mode(GL_PROJECTION); 1.46 gl_push_matrix(); 1.47 gl_load_identity(); 1.48 - gl_scalef(2.0 / aspect, 2.0, 1); 1.49 - gl_translatef(-1, -1, 0); 1.50 + gl_ortho(0, virt_width, 0, virt_height, -1, 1); 1.51 gl_matrix_mode(GL_MODELVIEW); 1.52 gl_push_matrix(); 1.53 gl_load_identity(); 1.54 @@ -116,9 +119,9 @@ 1.55 gl_begin(GL_QUADS); 1.56 //gl_color4f(0, 0, 0, 0.5); 1.57 gl_vertex3f(0, 0, 0); 1.58 - gl_vertex3f(0, 1.0, 0); 1.59 - gl_vertex3f(1.0 * aspect, 1.0, 0); 1.60 - gl_vertex3f(1.0 * aspect, 0, 0); 1.61 + gl_vertex3f(0, virt_height, 0); 1.62 + gl_vertex3f(virt_width, virt_height, 0); 1.63 + gl_vertex3f(virt_width, 0, 0); 1.64 gl_end(); 1.65 1.66 scr.draw(); 1.67 @@ -136,16 +139,16 @@ 1.68 1.69 void ui_button(int bn, int press, int x, int y) 1.70 { 1.71 - float normx = aspect * (float)x / (float)width; 1.72 - float normy = 1.0 - (float)y / (float)height; 1.73 + float normx = virt_width * (float)x / (float)width; 1.74 + float normy = virt_height - virt_height * (float)y / (float)height; 1.75 1.76 scr.sysev_mouse_button(bn, press != 0, normx, normy); 1.77 } 1.78 1.79 void ui_motion(int x, int y) 1.80 { 1.81 - float normx = aspect * (float)x / (float)width; 1.82 - float normy = 1.0 - (float)y / (float)height; 1.83 + float normx = virt_width * (float)x / (float)width; 1.84 + float normy = virt_height - virt_height * (float)y / (float)height; 1.85 1.86 scr.sysev_mouse_motion(normx, normy); 1.87 }