# HG changeset patch # User John Tsiombikas # Date 1315371533 -10800 # Node ID aa70df4bb0e5bcd328f059ea7a9f7ccf9b52b87c # Parent 557d86c8d7ed67223dc635ffeb0f03d49f17fe00 added vbo test diff -r 557d86c8d7ed -r aa70df4bb0e5 src/istereo.c --- a/src/istereo.c Wed Sep 07 07:43:22 2011 +0300 +++ b/src/istereo.c Wed Sep 07 07:58:53 2011 +0300 @@ -24,6 +24,8 @@ unsigned int prog; +unsigned int vbo, cbo; + int init(void) { add_resource_path("sdr"); @@ -33,6 +35,16 @@ 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; } @@ -104,11 +116,16 @@ cloc = glGetAttribLocation(prog, "attr_color"); assert(vloc != -1 && cloc != -1); - glVertexAttribPointer(vloc, 3, GL_FLOAT, 0, 0, varr); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glVertexAttribPointer(vloc, 3, GL_FLOAT, 0, 0, 0); glEnableVertexAttribArray(vloc); - glVertexAttribPointer(cloc, 3, GL_FLOAT, 0, 0, carr); + + 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); glDisableVertexAttribArray(vloc);