[MPlayer-cvslog] r34425 - in trunk/libvo: gl_common.c gl_common.h matrixview.c vo_gl.c vo_gl2.c

reimar subversion at mplayerhq.hu
Sat Dec 10 21:21:51 CET 2011


Author: reimar
Date: Sat Dec 10 21:21:50 2011
New Revision: 34425

Log:
Use glLoadMatrixf. This makes it easier to support OpenGL ES.

Modified:
   trunk/libvo/gl_common.c
   trunk/libvo/gl_common.h
   trunk/libvo/matrixview.c
   trunk/libvo/vo_gl.c
   trunk/libvo/vo_gl2.c

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Sat Dec 10 15:31:28 2011	(r34424)
+++ trunk/libvo/gl_common.c	Sat Dec 10 21:21:50 2011	(r34425)
@@ -49,10 +49,7 @@ void (GLAPIENTRY *mpglEnd)(void);
 void (GLAPIENTRY *mpglViewport)(GLint, GLint, GLsizei, GLsizei);
 void (GLAPIENTRY *mpglMatrixMode)(GLenum);
 void (GLAPIENTRY *mpglLoadIdentity)(void);
-void (GLAPIENTRY *mpglTranslated)(double, double, double);
-void (GLAPIENTRY *mpglScaled)(double, double, double);
-void (GLAPIENTRY *mpglOrtho)(double, double, double, double, double, double);
-void (GLAPIENTRY *mpglFrustum)(double, double, double, double, double, double);
+void (GLAPIENTRY *mpglLoadMatrixf)(float *);
 void (GLAPIENTRY *mpglPushMatrix)(void);
 void (GLAPIENTRY *mpglPopMatrix)(void);
 void (GLAPIENTRY *mpglClear)(GLbitfield);
@@ -396,10 +393,7 @@ static const extfunc_desc_t extfuncs[] =
   DEF_FUNC_DESC(Viewport),
   DEF_FUNC_DESC(MatrixMode),
   DEF_FUNC_DESC(LoadIdentity),
-  DEF_FUNC_DESC(Translated),
-  DEF_FUNC_DESC(Scaled),
-  DEF_FUNC_DESC(Ortho),
-  DEF_FUNC_DESC(Frustum),
+  DEF_FUNC_DESC(LoadMatrixf),
   DEF_FUNC_DESC(PushMatrix),
   DEF_FUNC_DESC(PopMatrix),
   DEF_FUNC_DESC(Clear),

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Sat Dec 10 15:31:28 2011	(r34424)
+++ trunk/libvo/gl_common.h	Sat Dec 10 21:21:50 2011	(r34425)
@@ -441,10 +441,7 @@ extern void (GLAPIENTRY *mpglEnd)(void);
 extern void (GLAPIENTRY *mpglViewport)(GLint, GLint, GLsizei, GLsizei);
 extern void (GLAPIENTRY *mpglMatrixMode)(GLenum);
 extern void (GLAPIENTRY *mpglLoadIdentity)(void);
-extern void (GLAPIENTRY *mpglTranslated)(double, double, double);
-extern void (GLAPIENTRY *mpglScaled)(double, double, double);
-extern void (GLAPIENTRY *mpglOrtho)(double, double, double, double, double, double);
-extern void (GLAPIENTRY *mpglFrustum)(double, double, double, double, double, double);
+extern void (GLAPIENTRY *mpglLoadMatrixf)(float *);
 extern void (GLAPIENTRY *mpglPushMatrix)(void);
 extern void (GLAPIENTRY *mpglPopMatrix)(void);
 extern void (GLAPIENTRY *mpglClear)(GLbitfield);

Modified: trunk/libvo/matrixview.c
==============================================================================
--- trunk/libvo/matrixview.c	Sat Dec 10 15:31:28 2011	(r34424)
+++ trunk/libvo/matrixview.c	Sat Dec 10 21:21:50 2011	(r34425)
@@ -310,15 +310,23 @@ void matrixview_init(int w, int h)
 
 void matrixview_reshape(int w, int h)
 {
+    double nearplane = -Z_Off - Z_Depth;
+    // perspective projection, also adjusting vertex position
+    // by Z_Off and with simplified Z equation since the absolute
+    // Z value does not matter, only relative to other pixels
+    float matrix[16] = {
+      nearplane / _text_x, 0, 0, 0,
+      0, nearplane / _text_y, 0, 0,
+      0, 0,  1, -1,
+      0, 0,  0, -Z_Off
+    };
     mpglViewport(0, 0, w, h);
 
     mpglMatrixMode(GL_PROJECTION);
-    mpglLoadIdentity();
-    mpglFrustum(-_text_x, _text_x, -_text_y, _text_y, -Z_Off - Z_Depth, -Z_Off);
+    mpglLoadMatrixf(matrix);
 
     mpglMatrixMode(GL_MODELVIEW);
     mpglLoadIdentity();
-    mpglTranslated(0.0f, 0.0f, Z_Off);
 }
 
 

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	Sat Dec 10 15:31:28 2011	(r34424)
+++ trunk/libvo/vo_gl.c	Sat Dec 10 21:21:50 2011	(r34425)
@@ -172,6 +172,13 @@ static unsigned int slice_height = 1;
 static void redraw(void);
 
 static void resize(int x,int y){
+  // simple orthogonal projection for 0-image_width;0-image_height
+  float matrix[16] = {
+    2.0/image_width,   0, 0, 0,
+    0, -2.0/image_height, 0, 0,
+    0, 0, 0, 0,
+    -1, 1, 0, 1
+  };
   mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
   if (WinID >= 0) {
     int left = 0, top = 0, w = x, h = y;
@@ -182,7 +189,6 @@ static void resize(int x,int y){
     mpglViewport( 0, 0, x, y );
 
   mpglMatrixMode(GL_PROJECTION);
-  mpglLoadIdentity();
   ass_border_x = ass_border_y = 0;
   if (aspect_scaling() && use_aspect) {
     int new_w, new_h;
@@ -193,11 +199,14 @@ static void resize(int x,int y){
     new_h += vo_panscan_y;
     scale_x = (GLdouble)new_w / (GLdouble)x;
     scale_y = (GLdouble)new_h / (GLdouble)y;
-    mpglScaled(scale_x, scale_y, 1);
+    matrix[0]  *= scale_x;
+    matrix[12] *= scale_x;
+    matrix[5]  *= scale_y;
+    matrix[13] *= scale_y;
     ass_border_x = (vo_dwidth - new_w) / 2;
     ass_border_y = (vo_dheight - new_h) / 2;
   }
-  mpglOrtho(0, image_width, image_height, 0, -1,1);
+  mpglLoadMatrixf(matrix);
 
   mpglMatrixMode(GL_MODELVIEW);
   mpglLoadIdentity();
@@ -775,10 +784,16 @@ static void do_render_osd(int type) {
     return;
   // set special rendering parameters
   if (!scaled_osd) {
+    // simple orthogonal projection for 0-vo_dwidth;0-vo_dheight
+    float matrix[16] = {
+      2.0/vo_dwidth,   0, 0, 0,
+      0, -2.0/vo_dheight, 0, 0,
+      0,  0, 0, 0,
+      -1, 1, 0, 1
+    };
     mpglMatrixMode(GL_PROJECTION);
     mpglPushMatrix();
-    mpglLoadIdentity();
-    mpglOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
+    mpglLoadMatrixf(matrix);
   }
   mpglEnable(GL_BLEND);
   if (draw_eosd) {

Modified: trunk/libvo/vo_gl2.c
==============================================================================
--- trunk/libvo/vo_gl2.c	Sat Dec 10 15:31:28 2011	(r34424)
+++ trunk/libvo/vo_gl2.c	Sat Dec 10 21:21:50 2011	(r34425)
@@ -423,6 +423,13 @@ static void drawTextureDisplay (void)
 
 
 static void resize(int x,int y){
+  // simple orthogonal projection for 0-1;0-1
+  static const float matrix[16] = {
+     2,  0, 0, 0,
+     0, -2, 0, 0,
+     0,  0, 0, 0,
+    -1,  1, 0, 1,
+  };
   mp_msg(MSGT_VO,MSGL_V,"[gl2] Resize: %dx%d\n",x,y);
   if(aspect_scaling()) {
     glClear(GL_COLOR_BUFFER_BIT);
@@ -443,8 +450,7 @@ static void resize(int x,int y){
   }
 
   glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glOrtho (0, 1, 1, 0, -1.0, 1.0);
+  glLoadMatrixf(matrix);
 
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();


More information about the MPlayer-cvslog mailing list