diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-31 19:44:57 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-31 19:44:57 -0700 |
commit | 2bd993afcec9212ac8071b3cc89a67b12e9558a9 (patch) | |
tree | d704eb291aa4d2f5d2059456d9c2e187deca133b | |
parent | 08c5da62a0cbccd4f4d51987269bd078ab5fd89e (diff) |
almost working first glbook test
-rw-r--r-- | tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle.c b/tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle.c index fd4c506a..5d4e0bd9 100644 --- a/tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle.c +++ b/tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle.c @@ -157,7 +157,13 @@ void Draw ( ESContext *esContext ) GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f }; - + + // No clientside arrays, so do this in a webgl-friendly manner + GLuint vertexPosObject; + glGenBuffers(1, &vertexPosObject); + glBindBuffer(GL_ARRAY_BUFFER, vertexPosObject); + glBufferData(GL_ARRAY_BUFFER, 9*4, vVertices, GL_STATIC_DRAW); + // Set the viewport glViewport ( 0, 0, esContext->width, esContext->height ); @@ -168,8 +174,9 @@ void Draw ( ESContext *esContext ) glUseProgram ( userData->programObject ); // Load the vertex data - glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE, 0, vVertices ); - glEnableVertexAttribArray ( 0 ); + glBindBuffer(GL_ARRAY_BUFFER, vertexPosObject); + glVertexAttribPointer(0 /* ? */, 3, GL_FLOAT, 0, 0, 0); + glEnableVertexAttribArray(0); glDrawArrays ( GL_TRIANGLES, 0, 3 ); } |