From 9e1cc74202e594aeb4539bfa15b05a2d66390e34 Mon Sep 17 00:00:00 2001 From: Rahul Singhal Date: Wed, 11 May 2011 15:41:21 +0530 Subject: [PATCH] Remove redundant GL calls in EGLX11ApplicationExample Redundant calls to glUseProgram, attachVertexBuffer & glUniformMatrix4fv removed. Reduces GLES driver work and improves the app's per-frame time by 0.1ms. --- .../EGLX11ApplicationExample/src/gles2application.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LayerManagerExamples/EGLX11ApplicationExample/src/gles2application.cpp b/LayerManagerExamples/EGLX11ApplicationExample/src/gles2application.cpp index 14495f1..2600e9d 100644 --- a/LayerManagerExamples/EGLX11ApplicationExample/src/gles2application.cpp +++ b/LayerManagerExamples/EGLX11ApplicationExample/src/gles2application.cpp @@ -230,6 +230,8 @@ void draw(t_ilm_uint animTime) float currentAngle = 0; int i = 0; glClear(GL_COLOR_BUFFER_BIT); + glUseProgram(shader.shaderProgramId); + attachVertexBuffer(); for (i = 10; i > 0; i--) { currentAngle = angle - ((float) i) * 10.0f; @@ -237,14 +239,11 @@ void draw(t_ilm_uint animTime) IlmMatrixRotateZ(matrix, currentAngle); float color[4] = { 0.0, 1.0, 1.0, 0.5 + (0.3 / (float) i) }; float lineColor[4] = { 0.0, 0.0, 0.0, 0.5 + (0.4 / (float) i) }; - glUseProgram(shader.shaderProgramId); - attachVertexBuffer(); glUniformMatrix4fv(shader.matrixLocation, 1, GL_FALSE, &matrix.f[0]); glUniform4fv(shader.colorLocation, 1, &color[0]); glDrawArrays(GL_TRIANGLES, 0, 27); // TODO: remove hard coded values - glUniformMatrix4fv(shader.matrixLocation, 1, GL_FALSE, &matrix.f[0]); glUniform4fv(shader.colorLocation, 1, &lineColor[0]); int j = 0; for (j = 0; j < 9; j++) // TODO: remove hard coded values @@ -257,6 +256,7 @@ void draw(t_ilm_uint animTime) swapBuffers(); startTime = currentTime; } + } void destroyGlApplication() -- 2.7.4