Remove redundant GL calls in EGLX11ApplicationExample
authorRahul Singhal <rasinghal@nvidia.com>
Wed, 11 May 2011 10:11:21 +0000 (15:41 +0530)
committerMichael Schuldt <michael.schuldt@bmw-carit.de>
Mon, 4 Jul 2011 07:42:17 +0000 (09:42 +0200)
Redundant calls to glUseProgram, attachVertexBuffer & glUniformMatrix4fv
removed. Reduces GLES driver work and improves the app's per-frame time by 0.1ms.

LayerManagerExamples/EGLX11ApplicationExample/src/gles2application.cpp

index 14495f1..2600e9d 100644 (file)
@@ -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()