changeset 13660:b34c5aa5f798

OSD variant for vo_gl.c that behaves more like the one of other vos.
author reimar
date Sun, 17 Oct 2004 19:32:47 +0000
parents b43e5e6430e6
children 07dc40f25068
files DOCS/man/en/mplayer.1 libvo/vo_gl.c
diffstat 2 files changed, 30 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Sun Oct 17 18:49:19 2004 +0000
+++ b/DOCS/man/en/mplayer.1	Sun Oct 17 19:32:47 2004 +0000
@@ -2539,6 +2539,12 @@
 .IPs (no)osd
 Enable or disable support for OSD rendering via OpenGL (default: enabled).
 Mostly for testing, you should use \-osdlevel 0 to disable OSD.
+.IPs (no)scaled-osd
+Changes the way the OSD behaves when the size of the 
+window changes (default: disabled).
+When enabled behaves more like the other vos, better for fixed-size fonts.
+Disabled looks much better with freetype fonts and uses the
+borders in fullscreen mode.
 .IPs (no)aspect
 Enable or disable aspect scaling and pan and scan support (default: enabled).
 Disabling might increase speed.
--- a/libvo/vo_gl.c	Sun Oct 17 18:49:19 2004 +0000
+++ b/libvo/vo_gl.c	Sun Oct 17 19:32:47 2004 +0000
@@ -44,6 +44,7 @@
                                        None };
 
 static int use_osd;
+static int scaled_osd;
 #define MAX_OSD_PARTS 20
 static GLuint osdtex[MAX_OSD_PARTS];
 #ifndef FAST_OSD
@@ -90,11 +91,13 @@
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
 
+  if (!scaled_osd) {
 #ifdef HAVE_FREETYPE
   // adjust font size to display size
   force_load_font = 1;
 #endif
-  vo_osd_changed(1);
+  vo_osd_changed(OSDTYPE_OSD);
+  }
 }
 
 static int find_gl_format (uint32_t format)
@@ -325,6 +328,7 @@
   // initialize to 8 to avoid special-casing on alignment
   int sx = 8, sy = 8;
   GLfloat xcov, ycov;
+  GLint scale_type = (scaled_osd) ? GL_LINEAR : GL_NEAREST;
   char *clearTexture;
   while (sx < w) sx *= 2;
   while (sy < h) sy *= 2;
@@ -345,8 +349,8 @@
   glBindTexture(GL_TEXTURE_2D, osdtex[osdtexCnt]);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, sx, sy, 0,
                  GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
-  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, scale_type);
+  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, scale_type);
   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_LUMINANCE,
                     GL_UNSIGNED_BYTE, src);
 
@@ -355,8 +359,8 @@
   glBindTexture(GL_TEXTURE_2D, osdatex[osdtexCnt]);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, sx, sy, 0,
                  GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
-  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, scale_type);
+  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, scale_type);
   glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA,
                     GL_UNSIGNED_BYTE, srca);
 #endif
@@ -405,6 +409,7 @@
 static void draw_osd(void)
 {
   int i;
+  int osd_h, osd_w;
   if (!use_osd) return;
   if (vo_osd_changed(0)) {
     for (i = 0; i < osdtexCnt; i++) {
@@ -415,8 +420,10 @@
       glDeleteLists(osdDispList[i], 1);
     }
     osdtexCnt = 0;
-    // draw OSD with full resolution
-    vo_draw_text(vo_dwidth, vo_dheight, create_osd_texture);
+
+    osd_w = (scaled_osd) ? image_width : vo_dwidth;
+    osd_h = (scaled_osd) ? image_height : vo_dheight;
+    vo_draw_text(osd_w, osd_h, create_osd_texture);
   }
 }
 
@@ -437,15 +444,18 @@
 
   if (osdtexCnt > 0) {
     // set special rendering parameters
+    if (!scaled_osd) {
     glMatrixMode(GL_PROJECTION);
     glPushMatrix();
     glLoadIdentity();
     glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
+    }
     glEnable(GL_BLEND);
     // draw OSD
     glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList);
     // set rendering parameters back to defaults
     glDisable (GL_BLEND);
+    if (!scaled_osd)
     glPopMatrix();
     glBindTexture(GL_TEXTURE_2D, 0);
   }
@@ -518,6 +528,7 @@
     unsigned int parse_pos = 0;
     many_fmts = 0;
     use_osd = 1;
+    scaled_osd = 0;
     use_aspect = 1;
     slice_height = 4;
     if(arg) 
@@ -535,6 +546,12 @@
             } else if (strncmp (&arg[parse_pos], "noosd", 5) == 0) {
                 parse_pos += 5;
                 use_osd = 0;
+            } else if (strncmp (&arg[parse_pos], "scaled-osd", 10) == 0) {
+                parse_pos += 10;
+                scaled_osd = 1;
+            } else if (strncmp (&arg[parse_pos], "noscaled-osd", 12) == 0) {
+                parse_pos += 12;
+                scaled_osd = 0;
             } else if (strncmp (&arg[parse_pos], "aspect", 6) == 0) {
                 parse_pos += 6;
                 use_aspect = 1;