istereo
changeset 6:f72c585aec26
blah
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Wed, 07 Sep 2011 07:41:24 +0300 |
parents | 76ad575d72d0 |
children | 557d86c8d7ed |
files | src/istereo.c |
diffstat | 1 files changed, 36 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/src/istereo.c Wed Sep 07 07:29:51 2011 +0300 1.2 +++ b/src/istereo.c Wed Sep 07 07:41:24 2011 +0300 1.3 @@ -7,6 +7,19 @@ 1.4 #include "sdr.h" 1.5 #include "respath.h" 1.6 1.7 +float varr[] = { 1.8 + -5, 0.5, 0, 1.9 + -3, 0.5, 0, 1.10 + -4, 3, 0 1.11 +}; 1.12 + 1.13 +float carr[] = { 1.14 + 1, 0, 0, 1.15 + 0, 1, 0, 1.16 + 0, 0, 1 1.17 +}; 1.18 + 1.19 +void dbg_draw(void); 1.20 static unsigned int get_shader_program(const char *vfile, const char *pfile); 1.21 1.22 unsigned int prog; 1.23 @@ -39,6 +52,8 @@ 1.24 gl_load_identity(); 1.25 gl_translatef(0, 0, -8); 1.26 1.27 + dbg_draw(); 1.28 + 1.29 gl_begin(GL_QUADS); 1.30 gl_color3f(1, 0, 0); 1.31 gl_vertex3f(-1, -1, 0); 1.32 @@ -78,3 +93,24 @@ 1.33 } 1.34 return prog; 1.35 } 1.36 + 1.37 +void dbg_draw(void) 1.38 +{ 1.39 + int vloc, cloc; 1.40 + 1.41 + gl_apply_xform(prog); 1.42 + 1.43 + vloc = glGetAttribLocation(prog, "attr_vertex"); 1.44 + cloc = glGetAttribLocation(prog, "attr_color"); 1.45 + assert(vloc != -1 && cloc != -1); 1.46 + 1.47 + glVertexAttribPointer(vloc, 3, GL_FLOAT, 0, 0, varr); 1.48 + glEnableVertexAttribArray(vloc); 1.49 + glVertexAttribPointer(cloc, 3, GL_FLOAT, 0, 0, carr); 1.50 + glEnableVertexAttribArray(cloc); 1.51 + 1.52 + glDrawArrays(GL_TRIANGLES, 0, 3); 1.53 + 1.54 + glDisableVertexAttribArray(vloc); 1.55 + glDisableVertexAttribArray(cloc); 1.56 +}