istereo2

diff src/ui.cc @ 7:a3c4fcc9f8f3

- started a goatkit UI theme - font rendering with drawtext and shaders - asset manager (only used by drawtext for now, will replace respath eventually)
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 24 Sep 2015 06:49:25 +0300
parents 3bccfc7d10fe
children 64e15874f3bd
line diff
     1.1 --- a/src/ui.cc	Wed Sep 23 05:44:58 2015 +0300
     1.2 +++ b/src/ui.cc	Thu Sep 24 06:49:25 2015 +0300
     1.3 @@ -1,3 +1,4 @@
     1.4 +#include <stdio.h>
     1.5  #include "ui.h"
     1.6  #include "goatkit/goatkit.h"
     1.7  #include "opengl.h"
     1.8 @@ -64,8 +65,11 @@
     1.9  	// load the theme
    1.10  	//goatkit::add_theme_path("themes/simple");
    1.11  
    1.12 -	//goatkit::theme = new goatkit::Theme;
    1.13 -	//goatkit::theme->load("simple");
    1.14 +	goatkit::theme = new goatkit::Theme;
    1.15 +	if(!goatkit::theme->load(GOATKIT_THEME_BUILTIN)) {
    1.16 +		fprintf(stderr, "no builitn theme\n");
    1.17 +		return -1;
    1.18 +	}
    1.19  
    1.20  	return 0;
    1.21  }
    1.22 @@ -91,25 +95,28 @@
    1.23  	gl_load_identity();
    1.24  	gl_scalef(2.0 / aspect, 2.0, 1);
    1.25  	gl_translatef(-1, -1, 0);
    1.26 -	gl_scalef(1, -1, 1);
    1.27  	gl_matrix_mode(GL_MODELVIEW);
    1.28  	gl_push_matrix();
    1.29  	gl_load_identity();
    1.30  
    1.31  	glDisable(GL_CULL_FACE);
    1.32  	glDisable(GL_DEPTH_TEST);
    1.33 +	glEnable(GL_BLEND);
    1.34 +	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1.35  
    1.36 -	/*gl_begin(GL_QUADS);
    1.37 -	gl_color3f(1, 0, 0);
    1.38 +	set_uniform_float4(prog_ui, "ucolor", 0, 0, 0, 0.5);
    1.39 +
    1.40 +	gl_begin(GL_QUADS);
    1.41 +	//gl_color4f(0, 0, 0, 0.5);
    1.42  	gl_vertex3f(0, 0, 0);
    1.43 -	gl_vertex3f(0, 0.5, 0);
    1.44 -	gl_vertex3f(0.5 * aspect, 0.5, 0);
    1.45 -	gl_vertex3f(0.5 * aspect, 0, 0);
    1.46 +	gl_vertex3f(0, 1.0, 0);
    1.47 +	gl_vertex3f(1.0 * aspect, 1.0, 0);
    1.48 +	gl_vertex3f(1.0 * aspect, 0, 0);
    1.49  	gl_end();
    1.50 -	*/
    1.51  
    1.52  	scr.draw();
    1.53  
    1.54 +	glDisable(GL_BLEND);
    1.55  	glEnable(GL_CULL_FACE);
    1.56  	glEnable(GL_DEPTH_TEST);
    1.57  
    1.58 @@ -122,10 +129,10 @@
    1.59  
    1.60  void ui_button(int bn, int press, int x, int y)
    1.61  {
    1.62 -	scr.sysev_mouse_button(bn, press != 0, (float)x / (float)width, 1.0 - (float)y / (float)height);
    1.63 +	scr.sysev_mouse_button(bn, press != 0, (float)x / (float)width, (float)y / (float)height);
    1.64  }
    1.65  
    1.66  void ui_motion(int x, int y)
    1.67  {
    1.68 -	scr.sysev_mouse_motion((float)x / (float)width, 1.0 - (float)y / (float)height);
    1.69 +	scr.sysev_mouse_motion((float)x / (float)width, (float)y / (float)height);
    1.70  }
    1.71 \ No newline at end of file