Skip to content

Commit

Permalink
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 19, 2002
1 parent 250f5cb commit 11d0bc4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs.html
Expand Up @@ -16,6 +16,7 @@ <H2>
Major changes since SDL 1.0.0:
</H2>
<UL>
<LI> 1.2.5: Added SDL_GL_STEREO for stereoscopic OpenGL contexts
<LI> 1.2.5: Fixed VidMode error when running on XFree86 3.3
<LI> 1.2.5: Added initial support for PicoGUI (thanks Micah!)
<LI> 1.2.5: Fixed SDL_DisplayFormatAlpha() on RGB surfaces with alpha
Expand Down
3 changes: 2 additions & 1 deletion include/SDL_video.h
Expand Up @@ -215,7 +215,8 @@ typedef enum {
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() */
Expand Down
11 changes: 6 additions & 5 deletions src/video/SDL_sysvideo.h
Expand Up @@ -295,13 +295,14 @@ struct SDL_VideoDevice {
int blue_size;
int alpha_size;
int depth_size;
int buffer_size;
int buffer_size;
int stencil_size;
int double_buffer;
int accum_red_size;
int accum_green_size;
int accum_blue_size;
int accum_alpha_size;
int accum_red_size;
int accum_green_size;
int accum_blue_size;
int accum_alpha_size;
int stereo;
int driver_loaded;
char driver_path[256];
void* dll_handle;
Expand Down
12 changes: 8 additions & 4 deletions src/video/SDL_video.c
Expand Up @@ -226,6 +226,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
video->gl_config.accum_green_size = 0;
video->gl_config.accum_blue_size = 0;
video->gl_config.accum_alpha_size = 0;
video->gl_config.stereo = 0;

/* Initialize the video subsystem */
memset(&vformat, 0, sizeof(vformat));
Expand Down Expand Up @@ -1370,18 +1371,21 @@ int SDL_GL_SetAttribute( SDL_GLattr attr, int value )
case SDL_GL_STENCIL_SIZE:
video->gl_config.stencil_size = value;
break;
case SDL_GL_ACCUM_RED_SIZE:
case SDL_GL_ACCUM_RED_SIZE:
video->gl_config.accum_red_size = value;
break;
case SDL_GL_ACCUM_GREEN_SIZE:
case SDL_GL_ACCUM_GREEN_SIZE:
video->gl_config.accum_green_size = value;
break;
case SDL_GL_ACCUM_BLUE_SIZE:
case SDL_GL_ACCUM_BLUE_SIZE:
video->gl_config.accum_blue_size = value;
break;
case SDL_GL_ACCUM_ALPHA_SIZE:
case SDL_GL_ACCUM_ALPHA_SIZE:
video->gl_config.accum_alpha_size = value;
break;
case SDL_GL_STEREO:
video->gl_config.stereo = value;
break;
default:
SDL_SetError("Unknown OpenGL attribute");
retval = -1;
Expand Down
3 changes: 3 additions & 0 deletions src/video/maccommon/SDL_macgl.c
Expand Up @@ -46,6 +46,9 @@ int Mac_GL_Init(_THIS)
if ( this->gl_config.double_buffer ) {
attributes[i++] = AGL_DOUBLEBUFFER;
}
if ( this->gl_config.stereo ) {
attributes[i++] = AGL_STEREO;
}
if ( this->gl_config.depth_size != 0 ) {
attributes[i++] = AGL_DEPTH_SIZE;
attributes[i++] = this->gl_config.depth_size;
Expand Down
5 changes: 5 additions & 0 deletions src/video/quartz/SDL_QuartzVideo.m
Expand Up @@ -1157,6 +1157,10 @@ static int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) {
attr[i++] = NSOpenGLPFADoubleBuffer;
}

if ( this->gl_config.stereo ) {
attr[i++] = NSOpenGLPFAStereo;
}

if ( this->gl_config.stencil_size != 0 ) {
attr[i++] = NSOpenGLPFAStencilSize;
attr[i++] = this->gl_config.stencil_size;
Expand Down Expand Up @@ -1245,6 +1249,7 @@ static int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) {
case SDL_GL_ACCUM_GREEN_SIZE: attr = GL_ACCUM_GREEN_BITS; break;
case SDL_GL_ACCUM_BLUE_SIZE: attr = GL_ACCUM_BLUE_BITS; break;
case SDL_GL_ACCUM_ALPHA_SIZE: attr = GL_ACCUM_ALPHA_BITS; break;
case SDL_GL_STEREO: attr = GL_STEREO; break;
case SDL_GL_BUFFER_SIZE:
{
GLint bits = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/video/wincommon/SDL_wingl.c
Expand Up @@ -106,6 +106,9 @@ int WIN_GL_SetupWindow(_THIS)
if ( this->gl_config.double_buffer ) {
GL_pfd.dwFlags |= PFD_DOUBLEBUFFER;
}
if ( this->gl_config.stereo ) {
GL_pfd.dwFlags |= PFD_STEREO;
}
GL_pfd.iPixelType = PFD_TYPE_RGBA;
GL_pfd.cColorBits = this->gl_config.buffer_size;
GL_pfd.cRedBits = this->gl_config.red_size;
Expand Down Expand Up @@ -242,6 +245,13 @@ int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
case SDL_GL_ACCUM_ALPHA_SIZE:
*value = GL_pfd.cAccumAlphaBits;
break;
case SDL_GL_STEREO:
if ( GL_pfd.dwFlags & PFD_STEREO ) {
*value = 1;
} else {
*value = 0;
}
break;
default:
retval = -1;
break;
Expand Down
24 changes: 16 additions & 8 deletions src/video/x11/SDL_x11gl.c
Expand Up @@ -67,8 +67,8 @@ XVisualInfo *X11_GL_GetVisual(_THIS)
}

/* Setup our GLX attributes according to the gl_config. */
i = 0;
attribs[i++] = GLX_RGBA;
i = 0;
attribs[i++] = GLX_RGBA;
attribs[i++] = GLX_RED_SIZE;
attribs[i++] = this->gl_config.red_size;
attribs[i++] = GLX_GREEN_SIZE;
Expand All @@ -82,8 +82,8 @@ XVisualInfo *X11_GL_GetVisual(_THIS)
}

if( this->gl_config.buffer_size ) {
attribs[i++] = GLX_BUFFER_SIZE;
attribs[i++] = this->gl_config.buffer_size;
attribs[i++] = GLX_BUFFER_SIZE;
attribs[i++] = this->gl_config.buffer_size;
}

if( this->gl_config.double_buffer ) {
Expand All @@ -99,25 +99,30 @@ XVisualInfo *X11_GL_GetVisual(_THIS)
}

if( this->gl_config.accum_red_size ) {
attribs[i++] = GLX_ACCUM_RED_SIZE;
attribs[i++] = GLX_ACCUM_RED_SIZE;
attribs[i++] = this->gl_config.accum_red_size;
}

if( this->gl_config.accum_green_size ) {
attribs[i++] = GLX_ACCUM_GREEN_SIZE;
attribs[i++] = GLX_ACCUM_GREEN_SIZE;
attribs[i++] = this->gl_config.accum_green_size;
}

if( this->gl_config.accum_blue_size ) {
attribs[i++] = GLX_ACCUM_BLUE_SIZE;
attribs[i++] = GLX_ACCUM_BLUE_SIZE;
attribs[i++] = this->gl_config.accum_blue_size;
}

if( this->gl_config.accum_alpha_size ) {
attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
attribs[i++] = this->gl_config.accum_alpha_size;
}

if( this->gl_config.stereo ) {
attribs[i++] = GLX_STEREO;
attribs[i++] = this->gl_config.stereo;
}

#ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */
attribs[i++] = GLX_X_VISUAL_TYPE;
attribs[i++] = GLX_DIRECT_COLOR;
Expand Down Expand Up @@ -288,6 +293,9 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
case SDL_GL_ACCUM_ALPHA_SIZE:
glx_attrib = GLX_ACCUM_ALPHA_SIZE;
break;
case SDL_GL_STEREO:
glx_attrib = GLX_STEREO;
break;
default:
return(-1);
}
Expand Down

0 comments on commit 11d0bc4

Please sign in to comment.