Added SDL_GL_STEREO for stereoscopic OpenGL contexts
authorSam Lantinga <slouken@libsdl.org>
Mon, 19 Aug 2002 17:58:08 +0000
changeset 450 8a43e0cbf02f
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
--- a/docs.html	Mon Aug 19 03:40:44 2002 +0000
+++ b/docs.html	Mon Aug 19 17:58:08 2002 +0000
@@ -16,6 +16,7 @@
 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
--- a/include/SDL_video.h	Mon Aug 19 03:40:44 2002 +0000
+++ b/include/SDL_video.h	Mon Aug 19 17:58:08 2002 +0000
@@ -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() */
--- a/src/video/SDL_sysvideo.h	Mon Aug 19 03:40:44 2002 +0000
+++ b/src/video/SDL_sysvideo.h	Mon Aug 19 17:58:08 2002 +0000
@@ -295,13 +295,14 @@
 		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;
--- a/src/video/SDL_video.c	Mon Aug 19 03:40:44 2002 +0000
+++ b/src/video/SDL_video.c	Mon Aug 19 17:58:08 2002 +0000
@@ -226,6 +226,7 @@
 	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));
@@ -1370,18 +1371,21 @@
 		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;
--- a/src/video/maccommon/SDL_macgl.c	Mon Aug 19 03:40:44 2002 +0000
+++ b/src/video/maccommon/SDL_macgl.c	Mon Aug 19 17:58:08 2002 +0000
@@ -46,6 +46,9 @@
 	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;
--- a/src/video/quartz/SDL_QuartzVideo.m	Mon Aug 19 03:40:44 2002 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.m	Mon Aug 19 17:58:08 2002 +0000
@@ -1157,6 +1157,10 @@
         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;
@@ -1245,6 +1249,7 @@
         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;
--- a/src/video/wincommon/SDL_wingl.c	Mon Aug 19 03:40:44 2002 +0000
+++ b/src/video/wincommon/SDL_wingl.c	Mon Aug 19 17:58:08 2002 +0000
@@ -106,6 +106,9 @@
 		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;
@@ -242,6 +245,13 @@
 	    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;
--- a/src/video/x11/SDL_x11gl.c	Mon Aug 19 03:40:44 2002 +0000
+++ b/src/video/x11/SDL_x11gl.c	Mon Aug 19 17:58:08 2002 +0000
@@ -67,8 +67,8 @@
 	}
 
         /* 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;
@@ -82,8 +82,8 @@
 	}
 
 	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 ) {
@@ -99,25 +99,30 @@
 	}
 
 	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;
@@ -288,6 +293,9 @@
 	    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);
 	}