istereo2
diff src/istereo.c @ 6:3bccfc7d10fe
goatkit is drawing
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 23 Sep 2015 05:44:58 +0300 |
parents | d4fed8aac9a6 |
children | a3c4fcc9f8f3 |
line diff
1.1 --- a/src/istereo.c Tue Sep 22 07:13:47 2015 +0300 1.2 +++ b/src/istereo.c Wed Sep 23 05:44:58 2015 +0300 1.3 @@ -1,6 +1,6 @@ 1.4 /* 1.5 Stereoscopic tunnel for iOS. 1.6 -Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org> 1.7 +Copyright (C) 2011-2015 John Tsiombikas <nuclear@member.fsf.org> 1.8 1.9 This program is free software: you can redistribute it and/or modify 1.10 it under the terms of the GNU General Public License as published by 1.11 @@ -30,6 +30,7 @@ 1.12 #include "cam.h" 1.13 #include "vmath.h" 1.14 #include "config.h" 1.15 +#include "ui.h" 1.16 1.17 static void render(float t); 1.18 static void draw_tunnel(float t); 1.19 @@ -40,13 +41,14 @@ 1.20 static unsigned int get_shader_program(const char *vfile, const char *pfile); 1.21 static float get_sec(void); 1.22 1.23 -unsigned int prog, prog_simple, prog_tunnel, prog_text; 1.24 +unsigned int prog, prog_simple, prog_tunnel, prog_text, prog_color, prog_ui; 1.25 unsigned int tex, tex_stones, tex_normal, tex_text; 1.26 1.27 int view_xsz, view_ysz; 1.28 1.29 int stereo = 0; 1.30 int use_bump = 0; 1.31 +int show_opt = 1; 1.32 1.33 /* construction parameters */ 1.34 int sides = 24; 1.35 @@ -72,6 +74,12 @@ 1.36 if(!(prog_text = get_shader_program("text.v.glsl", "text.p.glsl"))) { 1.37 return -1; 1.38 } 1.39 + if(!(prog_color = get_shader_program("color.v.glsl", "color.p.glsl"))) { 1.40 + return -1; 1.41 + } 1.42 + if(!(prog_ui = get_shader_program("ui.v.glsl", "ui.p.glsl"))) { 1.43 + return -1; 1.44 + } 1.45 1.46 if(!(tex = load_texture(find_resource("tiles.jpg", 0, 0)))) { 1.47 return -1; 1.48 @@ -89,6 +97,10 @@ 1.49 glEnable(GL_DEPTH_TEST); 1.50 glEnable(GL_CULL_FACE); 1.51 1.52 + if(ui_init() == -1) { 1.53 + return -1; 1.54 + } 1.55 + 1.56 cam_fov(42.5); 1.57 cam_clip(0.5, 250.0); 1.58 1.59 @@ -97,7 +109,11 @@ 1.60 1.61 void cleanup(void) 1.62 { 1.63 - free_program(prog); 1.64 + ui_shutdown(); 1.65 + free_program(prog_simple); 1.66 + free_program(prog_tunnel); 1.67 + free_program(prog_color); 1.68 + free_program(prog_ui); 1.69 } 1.70 1.71 void redraw(void) 1.72 @@ -187,6 +203,10 @@ 1.73 } 1.74 glDepthMask(1); 1.75 } 1.76 + 1.77 + if(show_opt) { 1.78 + ui_draw(); 1.79 + } 1.80 } 1.81 1.82 static void draw_tunnel(float t) 1.83 @@ -360,6 +380,22 @@ 1.84 1.85 view_xsz = x; 1.86 view_ysz = y; 1.87 + 1.88 + ui_reshape(x, y); 1.89 +} 1.90 + 1.91 +void mouse_button(int bn, int press, int x, int y) 1.92 +{ 1.93 + if(show_opt) { 1.94 + ui_button(bn, press, x, y); 1.95 + } 1.96 +} 1.97 + 1.98 +void mouse_motion(int x, int y) 1.99 +{ 1.100 + if(show_opt) { 1.101 + ui_motion(x, y); 1.102 + } 1.103 } 1.104 1.105 static unsigned int get_shader_program(const char *vfile, const char *pfile)