changeset 34054:a70e8abec089

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).
author reimar
date Tue, 27 Sep 2011 21:42:46 +0000
parents 77c1b5736020
children 5bd7e92fb132
files libvo/matrixview.c
diffstat 1 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/matrixview.c	Tue Sep 27 16:39:36 2011 +0000
+++ b/libvo/matrixview.c	Tue Sep 27 21:42:46 2011 +0000
@@ -297,6 +297,13 @@
     // 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 @@
     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 @@
     mpglBindTexture(GL_TEXTURE_2D, 0);
 
     make_change(currentTime);
-
-    mpglLoadIdentity();
-    mpglMatrixMode(GL_PROJECTION);
 }
 
 void matrixview_contrast_set(float contrast)