[MPlayer-dev-eng] patch for quadbuffered stereo using "-vo gl2:stereo"

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Nov 28 20:59:23 CET 2007


Hello,
On Wed, Nov 28, 2007 at 12:35:22PM -0600, Stuart Levy wrote:
[...]
> -static void drawTextureDisplay (void)
> +static void drawTextureDisplay ( float tex0, float tex1 )
>  {
>    struct TexSquare *square = texgrid;
>    int x, y;
> +  int itx0, itx1;
> +  GLfloat fxoff = tex0;
> +  GLfloat fxscale = 1.0f / (tex1 - tex0);
>  
> +
>    glColor3f(1.0,1.0,1.0);
>  
> +  itx0 = (int) (tex0 * texnumx);
> +  itx1 = (int) ceilf(tex1 * texnumx);
> +

Instead of this "mess", why not just adding a proper transformation
matrix? You wouldn't even have to change drawTextureDisplay, just change
the matrix one level above. In addition this would be much easier to
adjust for e.g. left image above right image and similar things.

>  static void resize(int *x,int *y){
>    mp_msg(MSGT_VO,MSGL_V,"[gl2] Resize: %dx%d\n",*x,*y);
>    if( vo_fs ) {
> +    if ( quadbuffer_stereo )
> +	glDrawBuffer(GL_BACK);
>      glClear(GL_COLOR_BUFFER_BIT);

Please make any code that uses glDrawBuffer revert it to GL_BACK
instead immediately afterwards.

>      vinfo = choose_glx_visual(mDisplay,mScreen,&vinfo_buf) < 0 ? NULL : &vinfo_buf;
>      if (vinfo == NULL) {
> -      mp_msg(MSGT_VO, MSGL_FATAL, "[gl2] no GLX support present\n");
> +      if (quadbuffer_stereo)
> +	  mp_msg(MSGT_VO, MSGL_FATAL, "[gl2] no Quadbuffered Stereo GLX support present\n");
> +      else
> +	  mp_msg(MSGT_VO, MSGL_FATAL, "[gl2] no GLX support present\n");

The old message was wrong anyway, and the one you add might not be right
either, there can well be quadbuffer stereo support and it still will fail, e.g. because
there is no doublebuffer support.
It should just be replaced by something like "no suitable GLX visual found", and that is independent
of this patch.

>        return -1;
>      }
>  
> @@ -592,9 +623,18 @@
>    resize(&d_width, &d_height);
>  
>    glClearColor( 0.0f,0.0f,0.0f,0.0f );
> -  glClear( GL_COLOR_BUFFER_BIT );

Just make GL_BACK the "default" and you can leave glClear as it is
(outside the if).

> +#if 0
> +  if (quadbuffer_stereo) {
> +    /* v. Winckler's patch had just d_width /= 2, but that doesn't seem right either.
> +     * Mplayer experts please help!  Meanwhile, leave this section out.
> +     * Then users must still give explicit -x and -y options as in
> +     *   mplayer -vo gl2:stereo -x <SCREENWIDTH> -y <SCREENHEIGHT>  movie...
> +     * At least *that* works.  But default window doesn't, nor does -fs,
> +     * both apparently confused by double-wide aspect ratio of stereo anim files.
> +     */
> +    width /= 2;
> +    d_width /= 2;
> +  }
> +#endif

I guess you give the wrong -monitoraspect. If you want it automated you
probably at least have to hack VOCTRL_UPDATE_SCREENINFO

>  //  glFlush();
>    if (use_glFinish)
> -  glFinish();
> +    glFinish();

Cosmetic.

> @@ -859,6 +924,8 @@
>              "    3: use fragment program with gamma correction.\n"
>              "    4: use fragment program with gamma correction via lookup.\n"
>              "    5: use ATI-specific method (for older cards).\n"
> +	    "  stereo\n"
> +	    "    use quadbuffered stereo: left-half image to left eye, etc.\n"

No tabs please (unless the surrounding code uses them).

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list