Index: gpu/command_buffer/client/gles2_demo_cc.cc |
=================================================================== |
--- gpu/command_buffer/client/gles2_demo_cc.cc (revision 37846) |
+++ gpu/command_buffer/client/gles2_demo_cc.cc (working copy) |
@@ -124,33 +124,6 @@ |
CheckGLError(); |
} |
-void Draw() { |
- // Note: the viewport is automatically set up to cover the entire Canvas. |
- // Clear the color buffer |
- glClear(GL_COLOR_BUFFER_BIT); |
- CheckGLError(); |
- // Use the program object |
- glUseProgram(g_programObject); |
- CheckGLError(); |
- // Load the vertex data |
- glBindBuffer(GL_ARRAY_BUFFER, g_vbo); |
- glEnableVertexAttribArray(0); |
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); |
- glEnableVertexAttribArray(1); |
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, |
- reinterpret_cast<const void*>(g_texCoordOffset)); |
- CheckGLError(); |
- // Bind the texture to texture unit 0 |
- glBindTexture(GL_TEXTURE_2D, g_texture); |
- CheckGLError(); |
- // Point the uniform sampler to texture unit 0 |
- glUniform1i(g_textureLoc, 0); |
- CheckGLError(); |
- glDrawArrays(GL_TRIANGLES, 0, 6); |
- CheckGLError(); |
- glFlush(); |
-} |
- |
GLuint CreateCheckerboardTexture() { |
static unsigned char pixels[] = { |
255, 255, 255, |
@@ -171,19 +144,38 @@ |
return texture; |
} |
-void Init() { |
+} // anonymous namespace. |
+ |
+void GLFromCPPInit() { |
glClearColor(0.f, 0.f, .7f, 1.f); |
g_texture = CreateCheckerboardTexture(); |
InitShaders(); |
} |
-} // anonymous namespace. |
- |
-void GLFromCPPTestFunction() { |
- static bool initialized = false; |
- if (!initialized) { |
- initialized = true; |
- Init(); |
- } |
- Draw(); |
+void GLFromCPPDraw() { |
+ // Note: the viewport is automatically set up to cover the entire Canvas. |
+ // Clear the color buffer |
+ glClear(GL_COLOR_BUFFER_BIT); |
+ CheckGLError(); |
+ // Use the program object |
+ glUseProgram(g_programObject); |
+ CheckGLError(); |
+ // Load the vertex data |
+ glBindBuffer(GL_ARRAY_BUFFER, g_vbo); |
+ glEnableVertexAttribArray(0); |
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); |
+ glEnableVertexAttribArray(1); |
+ glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, |
+ reinterpret_cast<const void*>(g_texCoordOffset)); |
+ CheckGLError(); |
+ // Bind the texture to texture unit 0 |
+ glBindTexture(GL_TEXTURE_2D, g_texture); |
+ CheckGLError(); |
+ // Point the uniform sampler to texture unit 0 |
+ glUniform1i(g_textureLoc, 0); |
+ CheckGLError(); |
+ glDrawArrays(GL_TRIANGLES, 0, 6); |
+ CheckGLError(); |
+ glFlush(); |
} |
+ |