istereo2
diff src/istereo.c @ 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 | 661bf09db398 |
line diff
1.1 --- a/src/istereo.c Wed Sep 23 05:44:58 2015 +0300 1.2 +++ b/src/istereo.c Thu Sep 24 06:49:25 2015 +0300 1.3 @@ -31,6 +31,7 @@ 1.4 #include "vmath.h" 1.5 #include "config.h" 1.6 #include "ui.h" 1.7 +#include "drawtext.h" 1.8 1.9 static void render(float t); 1.10 static void draw_tunnel(float t); 1.11 @@ -41,8 +42,9 @@ 1.12 static unsigned int get_shader_program(const char *vfile, const char *pfile); 1.13 static float get_sec(void); 1.14 1.15 -unsigned int prog, prog_simple, prog_tunnel, prog_text, prog_color, prog_ui; 1.16 +unsigned int prog, prog_simple, prog_tunnel, prog_text, prog_color, prog_ui, prog_font; 1.17 unsigned int tex, tex_stones, tex_normal, tex_text; 1.18 +struct dtx_font *font; 1.19 1.20 int view_xsz, view_ysz; 1.21 1.22 @@ -80,6 +82,9 @@ 1.23 if(!(prog_ui = get_shader_program("ui.v.glsl", "ui.p.glsl"))) { 1.24 return -1; 1.25 } 1.26 + if(!(prog_font = get_shader_program("ui.v.glsl", "font.p.glsl"))) { 1.27 + return -1; 1.28 + } 1.29 1.30 if(!(tex = load_texture(find_resource("tiles.jpg", 0, 0)))) { 1.31 return -1; 1.32 @@ -94,6 +99,13 @@ 1.33 return -1; 1.34 } 1.35 1.36 + if(!(font = dtx_open_font_glyphmap(find_resource("linux-libertine_s24.glyphmap", 0, 0)))) { 1.37 + fprintf(stderr, "failed to load font\n"); 1.38 + return -1; 1.39 + } 1.40 + dtx_vertex_attribs(get_attrib_loc(prog_ui, "attr_vertex"), get_attrib_loc(prog_ui, "attr_texcoord")); 1.41 + dtx_use_font(font, 24); 1.42 + 1.43 glEnable(GL_DEPTH_TEST); 1.44 glEnable(GL_CULL_FACE); 1.45 1.46 @@ -114,6 +126,8 @@ 1.47 free_program(prog_tunnel); 1.48 free_program(prog_color); 1.49 free_program(prog_ui); 1.50 + free_program(prog_font); 1.51 + dtx_close_font(font); 1.52 } 1.53 1.54 void redraw(void) 1.55 @@ -184,6 +198,20 @@ 1.56 render(tsec); 1.57 } 1.58 1.59 + /* TEST */ 1.60 + /*bind_program(prog_ui); 1.61 + 1.62 + gl_matrix_mode(GL_PROJECTION); 1.63 + gl_load_identity(); 1.64 + gl_ortho(0, view_xsz, 0, view_ysz, -1, 1); 1.65 + gl_matrix_mode(GL_MODELVIEW); 1.66 + gl_load_identity(); 1.67 + gl_apply_xform(prog_ui); 1.68 + 1.69 + glDisable(GL_DEPTH_TEST); 1.70 + dtx_printf("hello world\n"); 1.71 + glEnable(GL_DEPTH_TEST);*/ 1.72 + 1.73 assert(glGetError() == GL_NO_ERROR); 1.74 } 1.75