# HG changeset patch # User John Tsiombikas # Date 1315372566 -10800 # Node ID 22dc37e3ca05e4b4424e5a91a4bb14cf68154975 # Parent aa70df4bb0e5bcd328f059ea7a9f7ccf9b52b87c what the fucking fuck diff -r aa70df4bb0e5 -r 22dc37e3ca05 src/istereo.c --- a/src/istereo.c Wed Sep 07 07:58:53 2011 +0300 +++ b/src/istereo.c Wed Sep 07 08:16:06 2011 +0300 @@ -7,25 +7,11 @@ #include "sdr.h" #include "respath.h" -float varr[] = { - -2, 1.5, 0, - 2, 1.5, 0, - 0, 4, 0 -}; - -float carr[] = { - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 -}; - void dbg_draw(void); static unsigned int get_shader_program(const char *vfile, const char *pfile); unsigned int prog; -unsigned int vbo, cbo; - int init(void) { add_resource_path("sdr"); @@ -34,17 +20,6 @@ fprintf(stderr, "failed to load shader program\n"); return -1; } - - glGenBuffers(1, &vbo); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof varr, varr, GL_STATIC_DRAW); - - glGenBuffers(1, &cbo); - glBindBuffer(GL_ARRAY_BUFFER, cbo); - glBufferData(GL_ARRAY_BUFFER, sizeof carr, carr, GL_STATIC_DRAW); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - return 0; } @@ -66,7 +41,7 @@ dbg_draw(); - gl_begin(GL_QUADS); + /*gl_begin(GL_QUADS); gl_color3f(1, 0, 0); gl_vertex3f(-1, -1, 0); gl_color3f(0, 1, 0); @@ -75,7 +50,7 @@ gl_vertex3f(1, 1, 0); gl_color3f(1, 1, 0); gl_vertex3f(-1, 1, 0); - gl_end(); + gl_end();*/ assert(glGetError() == GL_NO_ERROR); } @@ -108,25 +83,36 @@ void dbg_draw(void) { + static const GLfloat squareVertices[] = { + -0.5f, -0.33f, + 0.5f, -0.33f, + -0.5f, 0.33f, + 0.5f, 0.33f, + }; + + static const GLubyte squareColors[] = { + 255, 255, 0, 255, + 0, 255, 255, 255, + 0, 0, 0, 0, + 255, 0, 255, 255, + }; + int vloc, cloc; + glUseProgram(prog); + gl_apply_xform(prog); vloc = glGetAttribLocation(prog, "attr_vertex"); cloc = glGetAttribLocation(prog, "attr_color"); - assert(vloc != -1 && cloc != -1); + assert(vloc >= 0 && cloc >= 0); - glBindBuffer(GL_ARRAY_BUFFER, vbo); - glVertexAttribPointer(vloc, 3, GL_FLOAT, 0, 0, 0); - glEnableVertexAttribArray(vloc); + glVertexAttribPointer(vloc, 2, GL_FLOAT, 0, 0, squareVertices); + glEnableVertexAttribArray(vloc); + glVertexAttribPointer(cloc, 4, GL_UNSIGNED_BYTE, 1, 0, squareColors); + glEnableVertexAttribArray(cloc); - glBindBuffer(GL_ARRAY_BUFFER, cbo); - glVertexAttribPointer(cloc, 3, GL_FLOAT, 0, 0, 0); - glEnableVertexAttribArray(cloc); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - - glDrawArrays(GL_TRIANGLES, 0, 3); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableVertexAttribArray(vloc); glDisableVertexAttribArray(cloc);