[patch] OpenGL stereo support

Hi,

Please Cc: me, I’m not subscribed to this mailing list.

attached is a patch to add support for OpenGL stereo. That is, GLX
stereo. For the other OpenGL glue APIs (AGL, QZ, WGL, …) I’ve
touched some files here and there, but the actual translation code (SDL
to glue API and back) is missing because I lack the expertise. It
should be a matter of looking in the documentation, searching for the
code that deals with double buffering or aux buffers or something like
that and adding the corresponding stereo bits.

There are no new functions and there’s a little change in the gl_config
structure used by the GL drivers. I added the new field at the end
just in case something depends on the ordering of the other fields.

Thanks,

Marcelo
-------------- next part --------------
diff -ruN SDL-1.2.4.orig/include/SDL_video.h SDL-1.2.4/include/SDL_video.h
— SDL-1.2.4.orig/include/SDL_video.h 2002-04-11 16:35:13.000000000 +0200
+++ SDL-1.2.4/include/SDL_video.h 2003-01-28 09:08:40.000000000 +0100
@@ -215,7 +215,8 @@
SDL_GL_ACCUM_RED_SIZE,
SDL_GL_ACCUM_GREEN_SIZE,
SDL_GL_ACCUM_BLUE_SIZE,

  • SDL_GL_ACCUM_ALPHA_SIZE
  • SDL_GL_ACCUM_ALPHA_SIZE,
  • SDL_GL_STEREO
    } SDL_GLattr;

/* flags for SDL_SetPalette() /
diff -ruN SDL-1.2.4.orig/src/video/SDL_sysvideo.h SDL-1.2.4/src/video/SDL_sysvideo.h
— SDL-1.2.4.orig/src/video/SDL_sysvideo.h 2002-03-06 12:23:03.000000000 +0100
+++ SDL-1.2.4/src/video/SDL_sysvideo.h 2003-01-28 09:19:16.000000000 +0100
@@ -305,6 +305,7 @@
int driver_loaded;
char driver_path[256];
void
dll_handle;

  •   int stereo;
    

    } gl_config;

    /* * * */
    diff -ruN SDL-1.2.4.orig/src/video/SDL_video.c SDL-1.2.4/src/video/SDL_video.c
    — SDL-1.2.4.orig/src/video/SDL_video.c 2002-03-20 03:37:44.000000000 +0100
    +++ SDL-1.2.4/src/video/SDL_video.c 2003-01-28 09:22:15.000000000 +0100
    @@ -216,6 +216,7 @@
    video->gl_config.depth_size = 16;
    video->gl_config.stencil_size = 0;
    video->gl_config.double_buffer = 1;

  • video->gl_config.stereo = 0;
    video->gl_config.accum_red_size = 0;
    video->gl_config.accum_green_size = 0;
    video->gl_config.accum_blue_size = 0;
    @@ -1346,6 +1347,9 @@
    case SDL_GL_DOUBLEBUFFER:
    video->gl_config.double_buffer = value;
    break;

  •   case SDL_GL_STEREO:
    
  •   	video->gl_config.stereo = value;
    
  •   	break;
       	case SDL_GL_BUFFER_SIZE:
          	video->gl_config.buffer_size = value;
      	break;
    

diff -ruN SDL-1.2.4.orig/src/video/cybergfx/SDL_cgxgl.c SDL-1.2.4/src/video/cybergfx/SDL_cgxgl.c
— SDL-1.2.4.orig/src/video/cybergfx/SDL_cgxgl.c 2002-03-06 12:23:03.000000000 +0100
+++ SDL-1.2.4/src/video/cybergfx/SDL_cgxgl.c 2003-01-28 09:14:05.000000000 +0100
@@ -174,6 +174,9 @@
case SDL_GL_DOUBLEBUFFER:
mesa_attrib = GL_DOUBLEBUFFER;
break;

  •   case SDL_GL_STEREO:
    
  •   	mesa_attrib = GL_STEREO;
    
  •   	break;
      case SDL_GL_DEPTH_SIZE:
      	mesa_attrib = GL_DEPTH_BITS;
      	break;
    

diff -ruN SDL-1.2.4.orig/src/video/quartz/SDL_QuartzVideo.m SDL-1.2.4/src/video/quartz/SDL_QuartzVideo.m
— SDL-1.2.4.orig/src/video/quartz/SDL_QuartzVideo.m 2002-04-13 22:33:21.000000000 +0200
+++ SDL-1.2.4/src/video/quartz/SDL_QuartzVideo.m 2003-01-28 09:13:35.000000000 +0100
@@ -1218,6 +1218,7 @@
case SDL_GL_GREEN_SIZE: attr = GL_GREEN_BITS; break;
case SDL_GL_ALPHA_SIZE: attr = GL_ALPHA_BITS; break;
case SDL_GL_DOUBLEBUFFER: attr = GL_DOUBLEBUFFER; break;

  • case SDL_GL_STEREO: attr = GL_STEREO; break;
    case SDL_GL_DEPTH_SIZE: attr = GL_DEPTH_BITS; break;
    case SDL_GL_STENCIL_SIZE: attr = GL_STENCIL_BITS; break;
    case SDL_GL_ACCUM_RED_SIZE: attr = GL_ACCUM_RED_BITS; break;
    diff -ruN SDL-1.2.4.orig/src/video/x11/SDL_x11gl.c SDL-1.2.4/src/video/x11/SDL_x11gl.c
    — SDL-1.2.4.orig/src/video/x11/SDL_x11gl.c 2002-03-06 12:23:08.000000000 +0100
    +++ SDL-1.2.4/src/video/x11/SDL_x11gl.c 2003-01-28 09:25:21.000000000 +0100
    @@ -90,6 +90,10 @@
    attribs[i++] = GLX_DOUBLEBUFFER;
    }

  • if( this->gl_config.stereo ) {

  •   attribs[i++] = GLX_STEREO;
    
  • }+
    attribs[i++] = GLX_DEPTH_SIZE;
    attribs[i++] = this->gl_config.depth_size;

@@ -267,6 +271,9 @@
case SDL_GL_DOUBLEBUFFER:
glx_attrib = GLX_DOUBLEBUFFER;
break;

  •   case SDL_GL_STEREO:
    
  •   glx_attrib = GLX_STEREO;
    
  •   break;
      case SDL_GL_BUFFER_SIZE:
      glx_attrib = GLX_BUFFER_SIZE;
      break;

Thanks for the patch, but stereo support went into the SDL 1.2.5 release.
Go ahead and download the latest version of SDL and see if it works for you.

Enjoy!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Thanks for the patch, but stereo support went into the SDL 1.2.5
release. Go ahead and download the latest version of SDL and see if
it works for you.

Oh, great! I managed to miss the fact that 1.2.4 is not the latest
version.

Thanks (and keep the great work),

MarceloOn Tue, Feb 04, 2003 at 09:22:38AM -0800, Sam Lantinga wrote: