Added SDL_GL_STEREO for stereoscopic OpenGL contexts
authorSam Lantinga <slouken@libsdl.org>
Mon, 19 Aug 2002 17:58:08 +0000
changeset 4508a43e0cbf02f
parent 449 8a687496061f
child 451 24edec3cafe4
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
docs.html
include/SDL_video.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/maccommon/SDL_macgl.c
src/video/quartz/SDL_QuartzVideo.m
src/video/wincommon/SDL_wingl.c
src/video/x11/SDL_x11gl.c
     1.1 --- a/docs.html	Mon Aug 19 03:40:44 2002 +0000
     1.2 +++ b/docs.html	Mon Aug 19 17:58:08 2002 +0000
     1.3 @@ -16,6 +16,7 @@
     1.4  Major changes since SDL 1.0.0:
     1.5  </H2>
     1.6  <UL>
     1.7 +	<LI> 1.2.5: Added SDL_GL_STEREO for stereoscopic OpenGL contexts
     1.8  	<LI> 1.2.5: Fixed VidMode error when running on XFree86 3.3
     1.9  	<LI> 1.2.5: Added initial support for PicoGUI (thanks Micah!)
    1.10  	<LI> 1.2.5: Fixed SDL_DisplayFormatAlpha() on RGB surfaces with alpha
     2.1 --- a/include/SDL_video.h	Mon Aug 19 03:40:44 2002 +0000
     2.2 +++ b/include/SDL_video.h	Mon Aug 19 17:58:08 2002 +0000
     2.3 @@ -215,7 +215,8 @@
     2.4      SDL_GL_ACCUM_RED_SIZE,
     2.5      SDL_GL_ACCUM_GREEN_SIZE,
     2.6      SDL_GL_ACCUM_BLUE_SIZE,
     2.7 -    SDL_GL_ACCUM_ALPHA_SIZE
     2.8 +    SDL_GL_ACCUM_ALPHA_SIZE,
     2.9 +	SDL_GL_STEREO
    2.10  } SDL_GLattr;
    2.11  
    2.12  /* flags for SDL_SetPalette() */
     3.1 --- a/src/video/SDL_sysvideo.h	Mon Aug 19 03:40:44 2002 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Mon Aug 19 17:58:08 2002 +0000
     3.3 @@ -295,13 +295,14 @@
     3.4  		int blue_size;
     3.5  		int alpha_size;
     3.6  		int depth_size;
     3.7 -	        int buffer_size;
     3.8 +		int buffer_size;
     3.9  		int stencil_size;
    3.10  		int double_buffer;
    3.11 -                int accum_red_size;
    3.12 -                int accum_green_size;
    3.13 -                int accum_blue_size;
    3.14 -                int accum_alpha_size;
    3.15 +		int accum_red_size;
    3.16 +		int accum_green_size;
    3.17 +		int accum_blue_size;
    3.18 +		int accum_alpha_size;
    3.19 +		int stereo;
    3.20  		int driver_loaded;
    3.21  		char driver_path[256];
    3.22  		void* dll_handle;
     4.1 --- a/src/video/SDL_video.c	Mon Aug 19 03:40:44 2002 +0000
     4.2 +++ b/src/video/SDL_video.c	Mon Aug 19 17:58:08 2002 +0000
     4.3 @@ -226,6 +226,7 @@
     4.4  	video->gl_config.accum_green_size = 0;
     4.5  	video->gl_config.accum_blue_size = 0;
     4.6  	video->gl_config.accum_alpha_size = 0;
     4.7 +	video->gl_config.stereo = 0;
     4.8  	
     4.9  	/* Initialize the video subsystem */
    4.10  	memset(&vformat, 0, sizeof(vformat));
    4.11 @@ -1370,18 +1371,21 @@
    4.12  		case SDL_GL_STENCIL_SIZE:
    4.13  			video->gl_config.stencil_size = value;
    4.14  			break;
    4.15 -	        case SDL_GL_ACCUM_RED_SIZE:
    4.16 +		case SDL_GL_ACCUM_RED_SIZE:
    4.17  			video->gl_config.accum_red_size = value;
    4.18  			break;
    4.19 -	        case SDL_GL_ACCUM_GREEN_SIZE:
    4.20 +		case SDL_GL_ACCUM_GREEN_SIZE:
    4.21  			video->gl_config.accum_green_size = value;
    4.22  			break;
    4.23 -	        case SDL_GL_ACCUM_BLUE_SIZE:
    4.24 +		case SDL_GL_ACCUM_BLUE_SIZE:
    4.25  			video->gl_config.accum_blue_size = value;
    4.26  			break;
    4.27 -	        case SDL_GL_ACCUM_ALPHA_SIZE:
    4.28 +		case SDL_GL_ACCUM_ALPHA_SIZE:
    4.29  			video->gl_config.accum_alpha_size = value;
    4.30  			break;
    4.31 +		case SDL_GL_STEREO:
    4.32 +			video->gl_config.stereo = value;
    4.33 +			break;
    4.34  		default:
    4.35  			SDL_SetError("Unknown OpenGL attribute");
    4.36  			retval = -1;
     5.1 --- a/src/video/maccommon/SDL_macgl.c	Mon Aug 19 03:40:44 2002 +0000
     5.2 +++ b/src/video/maccommon/SDL_macgl.c	Mon Aug 19 17:58:08 2002 +0000
     5.3 @@ -46,6 +46,9 @@
     5.4  	if ( this->gl_config.double_buffer ) {
     5.5  		attributes[i++] = AGL_DOUBLEBUFFER;
     5.6  	}
     5.7 +	if ( this->gl_config.stereo ) {
     5.8 +		attributes[i++] = AGL_STEREO;
     5.9 +	}
    5.10  	if ( this->gl_config.depth_size != 0 ) {
    5.11  		attributes[i++] = AGL_DEPTH_SIZE;
    5.12  		attributes[i++] = this->gl_config.depth_size;
     6.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Mon Aug 19 03:40:44 2002 +0000
     6.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Mon Aug 19 17:58:08 2002 +0000
     6.3 @@ -1157,6 +1157,10 @@
     6.4          attr[i++] = NSOpenGLPFADoubleBuffer;
     6.5      }
     6.6  
     6.7 +    if ( this->gl_config.stereo ) {
     6.8 +        attr[i++] = NSOpenGLPFAStereo;
     6.9 +    }
    6.10 +
    6.11      if ( this->gl_config.stencil_size != 0 ) {
    6.12          attr[i++] = NSOpenGLPFAStencilSize;
    6.13          attr[i++] = this->gl_config.stencil_size;
    6.14 @@ -1245,6 +1249,7 @@
    6.15          case SDL_GL_ACCUM_GREEN_SIZE: attr = GL_ACCUM_GREEN_BITS; break;
    6.16          case SDL_GL_ACCUM_BLUE_SIZE: attr = GL_ACCUM_BLUE_BITS; break;
    6.17          case SDL_GL_ACCUM_ALPHA_SIZE: attr = GL_ACCUM_ALPHA_BITS; break;
    6.18 +        case SDL_GL_STEREO: attr = GL_STEREO; break;
    6.19          case SDL_GL_BUFFER_SIZE:
    6.20          {
    6.21              GLint bits = 0;
     7.1 --- a/src/video/wincommon/SDL_wingl.c	Mon Aug 19 03:40:44 2002 +0000
     7.2 +++ b/src/video/wincommon/SDL_wingl.c	Mon Aug 19 17:58:08 2002 +0000
     7.3 @@ -106,6 +106,9 @@
     7.4  		if ( this->gl_config.double_buffer ) {
     7.5  			GL_pfd.dwFlags |= PFD_DOUBLEBUFFER;
     7.6  		}
     7.7 +		if ( this->gl_config.stereo ) {
     7.8 +			GL_pfd.dwFlags |= PFD_STEREO;
     7.9 +		}
    7.10  		GL_pfd.iPixelType = PFD_TYPE_RGBA;
    7.11  		GL_pfd.cColorBits = this->gl_config.buffer_size;
    7.12  		GL_pfd.cRedBits = this->gl_config.red_size;
    7.13 @@ -242,6 +245,13 @@
    7.14  	    case SDL_GL_ACCUM_ALPHA_SIZE:
    7.15  		*value = GL_pfd.cAccumAlphaBits;
    7.16  		break;
    7.17 +	    case SDL_GL_STEREO:
    7.18 +		if ( GL_pfd.dwFlags & PFD_STEREO ) {
    7.19 +			*value = 1;
    7.20 +		} else {
    7.21 +			*value = 0;
    7.22 +		}
    7.23 +		break;
    7.24  	    default:
    7.25  		retval = -1;
    7.26  		break;
     8.1 --- a/src/video/x11/SDL_x11gl.c	Mon Aug 19 03:40:44 2002 +0000
     8.2 +++ b/src/video/x11/SDL_x11gl.c	Mon Aug 19 17:58:08 2002 +0000
     8.3 @@ -67,8 +67,8 @@
     8.4  	}
     8.5  
     8.6          /* Setup our GLX attributes according to the gl_config. */
     8.7 -        i = 0;
     8.8 -        attribs[i++] = GLX_RGBA;
     8.9 +	i = 0;
    8.10 +	attribs[i++] = GLX_RGBA;
    8.11  	attribs[i++] = GLX_RED_SIZE;
    8.12  	attribs[i++] = this->gl_config.red_size;
    8.13  	attribs[i++] = GLX_GREEN_SIZE;
    8.14 @@ -82,8 +82,8 @@
    8.15  	}
    8.16  
    8.17  	if( this->gl_config.buffer_size ) {
    8.18 -                attribs[i++] = GLX_BUFFER_SIZE;
    8.19 -	        attribs[i++] = this->gl_config.buffer_size;
    8.20 +		attribs[i++] = GLX_BUFFER_SIZE;
    8.21 +		attribs[i++] = this->gl_config.buffer_size;
    8.22  	}
    8.23  
    8.24  	if( this->gl_config.double_buffer ) {
    8.25 @@ -99,25 +99,30 @@
    8.26  	}
    8.27  
    8.28  	if( this->gl_config.accum_red_size ) {
    8.29 -	        attribs[i++] = GLX_ACCUM_RED_SIZE;
    8.30 +		attribs[i++] = GLX_ACCUM_RED_SIZE;
    8.31  		attribs[i++] = this->gl_config.accum_red_size;
    8.32  	}
    8.33  
    8.34  	if( this->gl_config.accum_green_size ) {
    8.35 -	        attribs[i++] = GLX_ACCUM_GREEN_SIZE;
    8.36 +		attribs[i++] = GLX_ACCUM_GREEN_SIZE;
    8.37  		attribs[i++] = this->gl_config.accum_green_size;
    8.38  	}
    8.39  
    8.40  	if( this->gl_config.accum_blue_size ) {
    8.41 -	        attribs[i++] = GLX_ACCUM_BLUE_SIZE;
    8.42 +		attribs[i++] = GLX_ACCUM_BLUE_SIZE;
    8.43  		attribs[i++] = this->gl_config.accum_blue_size;
    8.44  	}
    8.45  
    8.46  	if( this->gl_config.accum_alpha_size ) {
    8.47 -	        attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
    8.48 +		attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
    8.49  		attribs[i++] = this->gl_config.accum_alpha_size;
    8.50  	}
    8.51  
    8.52 +	if( this->gl_config.stereo ) {
    8.53 +		attribs[i++] = GLX_STEREO;
    8.54 +		attribs[i++] = this->gl_config.stereo;
    8.55 +	}
    8.56 +
    8.57  #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */
    8.58  	attribs[i++] = GLX_X_VISUAL_TYPE;
    8.59  	attribs[i++] = GLX_DIRECT_COLOR;
    8.60 @@ -288,6 +293,9 @@
    8.61  	    case SDL_GL_ACCUM_ALPHA_SIZE:
    8.62  		glx_attrib = GLX_ACCUM_ALPHA_SIZE;
    8.63  		break;
    8.64 +	    case SDL_GL_STEREO:
    8.65 +		glx_attrib = GLX_STEREO;
    8.66 +		break;
    8.67  	    default:
    8.68  		return(-1);
    8.69  	}