[vlc-commits] opengl.c: refactor texture enabling and uniform setting

Ilkka Ollakka git at videolan.org
Sun Jul 8 21:50:19 CEST 2012


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Thu Jul  5 18:21:00 2012 +0300| [d7f669675704b62500959d9782320ce1810c3c91] | committer: Ilkka Ollakka

opengl.c: refactor texture enabling and uniform setting

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d7f669675704b62500959d9782320ce1810c3c91
---

 modules/video_output/opengl.c |   46 ++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
index 667e937..110e6cf 100644
--- a/modules/video_output/opengl.c
+++ b/modules/video_output/opengl.c
@@ -779,35 +779,38 @@ static void draw_without_shaders( vout_display_opengl_t *vgl, float *left, float
         right[0], top[0]
     };
 
-    glEnableClientState(GL_VERTEX_ARRAY);
-    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-    glEnable(GL_VERTEX_ARRAY);
-    glEnable(GL_TEXTURE_COORD_ARRAY);
+    for (unsigned j = 0; j < vgl->chroma->plane_count; j++) {
+       vgl->ActiveTexture( GL_TEXTURE0 + j );
+       vgl->ClientActiveTexture( GL_TEXTURE0 + j );
+
+       glEnableClientState(GL_VERTEX_ARRAY);
+       glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+       glEnable(vgl->tex_target);
 
-    vgl->ActiveTexture( GL_TEXTURE0);
-    vgl->ClientActiveTexture( GL_TEXTURE0);
+       glBindTexture(vgl->tex_target, vgl->texture[0][j]);
+       glTexCoordPointer(2, GL_FLOAT, 0, textureCoord);
+    }
+    vgl->ActiveTexture( GL_TEXTURE0 );
+    vgl->ClientActiveTexture( GL_TEXTURE0 );
 
-    glEnable(vgl->tex_target);
-    glBindTexture(vgl->tex_target, vgl->texture[0][0]);
     glVertexPointer(2, GL_FLOAT, 0, vertexCoord);
-    glTexCoordPointer(2, GL_FLOAT, 0, textureCoord);
 
     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
-    glDisable(vgl->tex_target);
-    glDisable(GL_TEXTURE_COORD_ARRAY);
-    glDisable(GL_VERTEX_ARRAY);
-    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-    glDisableClientState(GL_VERTEX_ARRAY);
+    for (unsigned j = 0; j < vgl->chroma->plane_count; j++) {
+       vgl->ActiveTexture( GL_TEXTURE0 + j );
+       vgl->ClientActiveTexture( GL_TEXTURE0 + j );
+       glDisable(vgl->tex_target);
+       glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+       glDisableClientState(GL_VERTEX_ARRAY);
+    }
+    vgl->ActiveTexture( GL_TEXTURE0 );
+    vgl->ClientActiveTexture( GL_TEXTURE0 );
 }
 
 static void draw_with_shaders( vout_display_opengl_t *vgl, float *left, float *top, float *right, float *bottom )
 {
-    vgl->UseProgram(vgl->program[0]);
-    vgl->Uniform4fv( vgl->GetUniformLocation( vgl->program[0], "coefficient" ), 4, vgl->local_value);
-    vgl->Uniform1i( vgl->GetUniformLocation( vgl->program[0], "Texture0" ), 0);
-    vgl->Uniform1i( vgl->GetUniformLocation( vgl->program[0], "Texture1" ), 1);
-    vgl->Uniform1i( vgl->GetUniformLocation( vgl->program[0], "Texture2" ), 2);
 
     const GLfloat vertexCoord[] = {
         -1.0, 1.0,
@@ -887,6 +890,11 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
 
     if( vgl->program[0] )
     {
+        vgl->UseProgram(vgl->program[0]);
+        vgl->Uniform4fv( vgl->GetUniformLocation( vgl->program[0], "coefficient" ), 4, vgl->local_value);
+        vgl->Uniform1i( vgl->GetUniformLocation( vgl->program[0], "Texture0" ), 0);
+        vgl->Uniform1i( vgl->GetUniformLocation( vgl->program[0], "Texture1" ), 1);
+        vgl->Uniform1i( vgl->GetUniformLocation( vgl->program[0], "Texture2" ), 2);
         draw_with_shaders( vgl, left, top ,right, bottom );
         // Change the program for overlays
         vgl->UseProgram(vgl->program[1]);



More information about the vlc-commits mailing list