[MPlayer-cvslog] r34142 - trunk/libvo/matrixview.c

reimar subversion at mplayerhq.hu
Tue Sep 27 23:42:47 CEST 2011


Author: reimar
Date: Tue Sep 27 23:42:46 2011
New Revision: 34142

Log:
Change silly matrixview code to not needlessly change state on every frame
(in addition to it making the code confusing this is a sure way to make
OpenGL code really slow).

Modified:
   trunk/libvo/matrixview.c

Modified: trunk/libvo/matrixview.c
==============================================================================
--- trunk/libvo/matrixview.c	Tue Sep 27 18:39:36 2011	(r34141)
+++ trunk/libvo/matrixview.c	Tue Sep 27 23:42:46 2011	(r34142)
@@ -297,6 +297,13 @@ void matrixview_init(int w, int h)
     // Allow adjusting of texture color via glColor
     mpglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
+    mpglEnable(GL_BLEND);
+    mpglEnable(GL_TEXTURE_2D);
+
+    mpglDisable(GL_LIGHTING);
+    mpglBlendFunc(GL_SRC_ALPHA, GL_ONE);
+    mpglDisable(GL_DEPTH_TEST);
+
     matrixview_reshape(w, h);
 }
 
@@ -310,23 +317,14 @@ void matrixview_reshape(int w, int h)
     mpglFrustum(-_text_x, _text_x, -_text_y, _text_y, -Z_Off - Z_Depth, -Z_Off);
 
     mpglMatrixMode(GL_MODELVIEW);
+    mpglLoadIdentity();
+    mpglTranslated(0.0f, 0.0f, Z_Off);
 }
 
 
 void matrixview_draw(int w, int h, double currentTime, float frameTime,
                      uint8_t *data)
 {
-    mpglEnable(GL_BLEND);
-    mpglEnable(GL_TEXTURE_2D);
-
-    mpglDisable(GL_LIGHTING);
-    mpglBlendFunc(GL_SRC_ALPHA, GL_ONE);
-    mpglDisable(GL_DEPTH_TEST);
-
-    mpglMatrixMode(GL_MODELVIEW);
-    mpglLoadIdentity();
-    mpglTranslated(0.0f, 0.0f, Z_Off);
-
     // Clear the color and depth buffers.
     mpglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
@@ -342,9 +340,6 @@ void matrixview_draw(int w, int h, doubl
     mpglBindTexture(GL_TEXTURE_2D, 0);
 
     make_change(currentTime);
-
-    mpglLoadIdentity();
-    mpglMatrixMode(GL_PROJECTION);
 }
 
 void matrixview_contrast_set(float contrast)


More information about the MPlayer-cvslog mailing list