[MPlayer-dev-eng] gl & distorted fisheye for dome projection

Reimar Doeffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Jul 4 10:33:30 CEST 2006


Hi,
On Tue, Jul 04, 2006 at 10:15:29AM +0200, Reimar Doeffinger wrote:
> I don't like that too much. I'll try to add support for 16 bit ppms and
> textures.

Try this with a 16 bits per component ppm (those have a maxval > 255 to
indicate this fact).
It is untested though (didn't even try to compile, but at least you
should be able to get what I have in mind) :-)

Greetings,
Reimar Doeffinger
-------------- next part --------------
Index: libvo/vo_gl.c
===================================================================
--- libvo/vo_gl.c	(revision 18896)
+++ libvo/vo_gl.c	(working copy)
@@ -187,7 +187,7 @@
     else {
       int width, height, maxval;
       ActiveTexture(GL_TEXTURE3);
-      if (glCreatePPMTex(GL_TEXTURE_2D, 3,
+      if (glCreatePPMTex(GL_TEXTURE_2D, 0,
                      custom_tlin?GL_LINEAR:GL_NEAREST,
                      f, &width, &height, &maxval))
         ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 1,
Index: libvo/gl_common.c
===================================================================
--- libvo/gl_common.c	(revision 18896)
+++ libvo/gl_common.c	(working copy)
@@ -370,7 +370,7 @@
 /**
  * \brief creates a texture from a PPM file
  * \param target texture taget, usually GL_TEXTURE_2D
- * \param fmt internal texture format
+ * \param fmt internal texture format, 0 for default
  * \param filter filter used for scaling, e.g. GL_LINEAR
  * \param f file to read PPM from
  * \param width [out] width of texture
@@ -381,7 +381,7 @@
  */
 int glCreatePPMTex(GLenum target, GLenum fmt, GLint filter,
                    FILE *f, int *width, int *height, int *maxval) {
-  unsigned w, h, m, val;
+  unsigned w, h, m, val, bpp;
   char *data;
   ppm_skip(f);
   if (fgetc(f) != 'P' || fgetc(f) != '6')
@@ -400,11 +400,15 @@
     return 0;
   if (w > MAXDIM || h > MAXDIM)
     return 0;
-  data = malloc(w * h * 3);
-  if (fread(data, w * 3, h, f) != h)
+  bpp = (m > 255) ? 6 : 3;
+  data = malloc(w * h * bpp);
+  if (fread(data, w * bpp, h, f) != h)
     return 0;
+  if (!fmt)
+    fmt = (m > 255) ? GL_RGB16 : 3;
   glCreateClearTex(target, fmt, filter, w, h, 0);
-  glUploadTex(target, GL_RGB, GL_UNSIGNED_BYTE, data, w * 3, 0, 0, w, h, 0);
+  glUploadTex(target, GL_RGB, (m > 255) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
+              data, w * bpp, 0, 0, w, h, 0);
   free(data);
   if (width) *width = w;
   if (height) *height = h;


More information about the MPlayer-dev-eng mailing list