SDL-trunk-1.3-merge-1 SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Apr 2006 09:09:48 +0000
branchSDL-1.3
changeset 165696c2f89cc7e1
parent 1655 59227394023d
child 1657 5b0805ceb50f
SDL-trunk-1.3-merge-1
WhatsNew
include/SDL_video.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/maccommon/SDL_macgl.c
src/video/quartz/SDL_QuartzGL.m
src/video/wincommon/SDL_wingl.c
src/video/wincommon/SDL_wingl_c.h
src/video/x11/SDL_x11gl.c
src/video/x11/SDL_x11gl_c.h
test/testgl.c
     1.1 --- a/WhatsNew	Thu Apr 27 05:49:51 2006 +0000
     1.2 +++ b/WhatsNew	Thu Apr 27 09:09:48 2006 +0000
     1.3 @@ -4,6 +4,10 @@
     1.4  Version 1.0:
     1.5  
     1.6  1.2.10:
     1.7 +	Added SDL_GL_SWAP_CONTROL to wait for vsync in OpenGL applications.
     1.8 +
     1.9 +	Added SDL_GL_ACCELERATED_VISUAL to guarantee hardware acceleration.
    1.10 +
    1.11  	Added current_w and current_h to the SDL_VideoInfo structure,
    1.12  	which is set to the desktop resolution during video intialization,
    1.13  	and then set to the current resolution when a video mode is set.
     2.1 --- a/include/SDL_video.h	Thu Apr 27 05:49:51 2006 +0000
     2.2 +++ b/include/SDL_video.h	Thu Apr 27 09:09:48 2006 +0000
     2.3 @@ -213,7 +213,9 @@
     2.4      SDL_GL_ACCUM_ALPHA_SIZE,
     2.5      SDL_GL_STEREO,
     2.6      SDL_GL_MULTISAMPLEBUFFERS,
     2.7 -    SDL_GL_MULTISAMPLESAMPLES
     2.8 +    SDL_GL_MULTISAMPLESAMPLES,
     2.9 +    SDL_GL_ACCELERATED_VISUAL,
    2.10 +    SDL_GL_SWAP_CONTROL
    2.11  } SDL_GLattr;
    2.12  
    2.13  /* flags for SDL_SetPalette() */
     3.1 --- a/src/video/SDL_sysvideo.h	Thu Apr 27 05:49:51 2006 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Thu Apr 27 09:09:48 2006 +0000
     3.3 @@ -292,6 +292,8 @@
     3.4  		int stereo;
     3.5  		int multisamplebuffers;
     3.6  		int multisamplesamples;
     3.7 +		int accelerated;
     3.8 +		int swap_control;
     3.9  		int driver_loaded;
    3.10  		char driver_path[256];
    3.11  		void* dll_handle;
     4.1 --- a/src/video/SDL_video.c	Thu Apr 27 05:49:51 2006 +0000
     4.2 +++ b/src/video/SDL_video.c	Thu Apr 27 09:09:48 2006 +0000
     4.3 @@ -229,6 +229,8 @@
     4.4  	video->gl_config.stereo = 0;
     4.5  	video->gl_config.multisamplebuffers = 0;
     4.6  	video->gl_config.multisamplesamples = 0;
     4.7 +	video->gl_config.accelerated = -1; /* not known, don't set */
     4.8 +	video->gl_config.swap_control = -1; /* not known, don't set */
     4.9  	
    4.10  	/* Initialize the video subsystem */
    4.11  	SDL_memset(&vformat, 0, sizeof(vformat));
    4.12 @@ -1393,6 +1395,12 @@
    4.13  		case SDL_GL_MULTISAMPLESAMPLES:
    4.14  			video->gl_config.multisamplesamples = value;
    4.15  			break;
    4.16 +		case SDL_GL_ACCELERATED_VISUAL:
    4.17 +			video->gl_config.accelerated = value;
    4.18 +			break;
    4.19 +		case SDL_GL_SWAP_CONTROL:
    4.20 +			video->gl_config.swap_control = value;
    4.21 +			break;
    4.22  		default:
    4.23  			SDL_SetError("Unknown OpenGL attribute");
    4.24  			retval = -1;
     5.1 --- a/src/video/maccommon/SDL_macgl.c	Thu Apr 27 05:49:51 2006 +0000
     5.2 +++ b/src/video/maccommon/SDL_macgl.c	Thu Apr 27 09:09:48 2006 +0000
     5.3 @@ -34,7 +34,7 @@
     5.4  #if SDL_VIDEO_OPENGL
     5.5  	AGLPixelFormat format;
     5.6     	int i = 0;
     5.7 -	GLint attributes [ 24 ]; /* 24 is max possible in this setup */
     5.8 +	GLint attributes [ 26 ]; /* 26 is max possible in this setup */
     5.9  	GLboolean noerr;
    5.10     
    5.11  	/* load the gl driver from a default path */
    5.12 @@ -95,6 +95,11 @@
    5.13  		attributes[i++] = this->gl_config.multisamplesamples;
    5.14  	}	
    5.15  #endif
    5.16 +	if ( this->gl_config.accelerated > 0 ) {
    5.17 +		attributes[i++] = AGL_ACCELERATED;
    5.18 +		attributes[i++] = AGL_NO_RECOVERY;
    5.19 +	}
    5.20 +
    5.21  	attributes[i++] = AGL_ALL_RENDERERS;
    5.22  	attributes[i]	= AGL_NONE;
    5.23  
     6.1 --- a/src/video/quartz/SDL_QuartzGL.m	Thu Apr 27 05:49:51 2006 +0000
     6.2 +++ b/src/video/quartz/SDL_QuartzGL.m	Thu Apr 27 09:09:48 2006 +0000
     6.3 @@ -112,6 +112,10 @@
     6.4          attr[i++] = NSOpenGLPFANoRecovery;
     6.5      }
     6.6  
     6.7 +    if ( this->gl_config.accelerated > 0 ) {
     6.8 +        attr[i++] = NSOpenGLPFAAccelerated;
     6.9 +    }
    6.10 +
    6.11      attr[i++] = NSOpenGLPFAScreenMask;
    6.12      attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id);
    6.13      attr[i] = 0;
    6.14 @@ -132,6 +136,17 @@
    6.15          return 0;
    6.16      }
    6.17  
    6.18 +    /* Synchronize QZ_GL_SwapBuffers() to vertical retrace.
    6.19 +     * (Apple's documentation is not completely clear about what this setting
    6.20 +     * exactly does, IMHO - for a detailed explanation see
    6.21 +     * http://lists.apple.com/archives/mac-opengl/2006/Jan/msg00080.html )
    6.22 +     */
    6.23 +    if ( this->gl_config.swap_control >= 0 ) {
    6.24 +        long value;
    6.25 +        value = this->gl_config.swap_control;
    6.26 +        [ gl_context setValues: &value forParameter: NSOpenGLCPSwapInterval ];
    6.27 +    }
    6.28 +
    6.29      /*
    6.30       * Wisdom from Apple engineer in reference to UT2003's OpenGL performance:
    6.31       *  "You are blowing a couple of the internal OpenGL function caches. This
    6.32 @@ -231,8 +246,25 @@
    6.33              glGetIntegerv (GL_ALPHA_BITS, &component); bits += component;
    6.34  
    6.35              *value = bits;
    6.36 +            return 0;
    6.37          }
    6.38 -        return 0;
    6.39 +        case SDL_GL_ACCELERATED_VISUAL:
    6.40 +        {
    6.41 +            long val;
    6.42 +	    /* FIXME: How do we get this information here?
    6.43 +            [fmt getValues: &val forAttribute: NSOpenGLPFAAccelerated attr forVirtualScreen: 0];
    6.44 +	    */
    6.45 +	    val = (this->gl_config.accelerated != 0);;
    6.46 +            *value = val;
    6.47 +            return 0;
    6.48 +        }
    6.49 +        case SDL_GL_SWAP_CONTROL:
    6.50 +        {
    6.51 +            long val;
    6.52 +            [ gl_context getValues: &val forParameter: NSOpenGLCPSwapInterval ];
    6.53 +            *value = val;
    6.54 +            return 0;
    6.55 +        }
    6.56      }
    6.57  
    6.58      glGetIntegerv (attr, (GLint *)value);
     7.1 --- a/src/video/wincommon/SDL_wingl.c	Thu Apr 27 05:49:51 2006 +0000
     7.2 +++ b/src/video/wincommon/SDL_wingl.c	Thu Apr 27 09:09:48 2006 +0000
     7.3 @@ -177,6 +177,7 @@
     7.4  	int iAttribs[64];
     7.5  	int *iAttr;
     7.6  	float fAttribs[1] = { 0 };
     7.7 +	const char *wglext;
     7.8  
     7.9  	/* load the gl driver from a default path */
    7.10  	if ( ! this->gl_config.driver_loaded ) {
    7.11 @@ -289,6 +290,11 @@
    7.12  			*iAttr++ = this->gl_config.multisamplesamples;
    7.13  		}
    7.14  
    7.15 +		if ( this->gl_config.accelerated >= 0 ) {
    7.16 +			*iAttr++ = WGL_ACCELERATION_ARB;
    7.17 +			*iAttr++ = (this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB : WGL_NO_ACCELERATION_ARB);
    7.18 +		}
    7.19 +
    7.20  		*iAttr = 0;
    7.21  
    7.22  		/* Choose and set the closest available pixel format */
    7.23 @@ -323,7 +329,25 @@
    7.24  		SDL_SetError("Unable to create GL context");
    7.25  		return(-1);
    7.26  	}
    7.27 +	if ( WIN_GL_MakeCurrent(this) < 0 ) {
    7.28 +		return(-1);
    7.29 +	}
    7.30  	gl_active = 1;
    7.31 +
    7.32 +	/* Vsync control under Windows.  Checking glGetString here is
    7.33 +	 * somewhat a documented and reliable hack - it was originally
    7.34 +	 * as a feature added by mistake, but since so many people rely
    7.35 +	 * on it, it will not be removed.  strstr should be safe here.*/
    7.36 +	wglext = (const char *)this->glGetString(GL_EXTENSIONS);
    7.37 +	if ( !SDL_strstr(wglext, "WGL_EXT_swap_control") ) {
    7.38 +		this->gl_data->wglSwapIntervalEXT = NULL;
    7.39 +		this->gl_data->wglGetSwapIntervalEXT = NULL;
    7.40 +	}
    7.41 +	if ( this->gl_config.swap_control >= 0 ) {
    7.42 +		if ( this->gl_data->wglSwapIntervalEXT ) {
    7.43 +			this->gl_data->wglSwapIntervalEXT(this->gl_config.swap_control);
    7.44 +		}
    7.45 +	}
    7.46  #else
    7.47  	SDL_SetError("WIN driver not configured with OpenGL");
    7.48  #endif
    7.49 @@ -423,6 +447,22 @@
    7.50  		    case SDL_GL_MULTISAMPLESAMPLES:
    7.51  			wgl_attrib = WGL_SAMPLES_ARB;
    7.52  			break;
    7.53 +		    case SDL_GL_ACCELERATED_VISUAL:
    7.54 +			wgl_attrib = WGL_ACCELERATION_ARB;
    7.55 +			this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, 1, &wgl_attrib, value);
    7.56 +			if ( *value == WGL_NO_ACCELERATION_ARB ) {
    7.57 +				*value = SDL_FALSE;
    7.58 +			} else {
    7.59 +				*value = SDL_TRUE;
    7.60 +			}
    7.61 +			return 0;
    7.62 +			break;
    7.63 +		    case SDL_GL_SWAP_CONTROL:
    7.64 +			if ( this->gl_data->wglGetSwapIntervalEXT ) {
    7.65 +				return this->gl_data->wglGetSwapIntervalEXT();
    7.66 +			} else {
    7.67 +				return -1;
    7.68 +			}
    7.69  		    default:
    7.70  			return(-1);
    7.71  		}
    7.72 @@ -509,6 +549,8 @@
    7.73  		this->gl_data->wglMakeCurrent = NULL;
    7.74  		this->gl_data->wglChoosePixelFormatARB = NULL;
    7.75  		this->gl_data->wglGetPixelFormatAttribivARB = NULL;
    7.76 +		this->gl_data->wglSwapIntervalEXT = NULL;
    7.77 +		this->gl_data->wglGetSwapIntervalEXT = NULL;
    7.78  
    7.79  		this->gl_config.dll_handle = NULL;
    7.80  		this->gl_config.driver_loaded = 0;
    7.81 @@ -547,6 +589,10 @@
    7.82  		GetProcAddress(handle, "wglDeleteContext");
    7.83  	this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC))
    7.84  		GetProcAddress(handle, "wglMakeCurrent");
    7.85 +	this->gl_data->wglSwapIntervalEXT = (void (WINAPI *)(int))
    7.86 +		GetProcAddress(handle, "wglSwapIntervalEXT");
    7.87 +	this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *)(void))
    7.88 +		GetProcAddress(handle, "wglGetSwapIntervalEXT");
    7.89  
    7.90  	if ( (this->gl_data->wglGetProcAddress == NULL) ||
    7.91  	     (this->gl_data->wglCreateContext == NULL) ||
     8.1 --- a/src/video/wincommon/SDL_wingl_c.h	Thu Apr 27 05:49:51 2006 +0000
     8.2 +++ b/src/video/wincommon/SDL_wingl_c.h	Thu Apr 27 09:09:48 2006 +0000
     8.3 @@ -53,6 +53,8 @@
     8.4                                                  UINT nAttributes, 
     8.5                                                  const int *piAttributes,
     8.6                                                  int *piValues);
     8.7 +    void (WINAPI *wglSwapIntervalEXT)(int interval);
     8.8 +    int (WINAPI *wglGetSwapIntervalEXT)(void);
     8.9  #endif /* SDL_VIDEO_OPENGL */
    8.10  };
    8.11  
     9.1 --- a/src/video/x11/SDL_x11gl.c	Thu Apr 27 05:49:51 2006 +0000
     9.2 +++ b/src/video/x11/SDL_x11gl.c	Thu Apr 27 09:09:48 2006 +0000
     9.3 @@ -43,6 +43,47 @@
     9.4  #define GLX_SAMPLES_ARB                    100001
     9.5  #endif
     9.6  
     9.7 +#ifndef GLX_EXT_visual_rating
     9.8 +#define GLX_EXT_visual_rating
     9.9 +#define GLX_VISUAL_CAVEAT_EXT              0x20
    9.10 +#define GLX_SLOW_VISUAL_EXT                0x8001
    9.11 +#define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
    9.12 +#endif
    9.13 +
    9.14 +#if SDL_VIDEO_OPENGL_GLX
    9.15 +static int glXExtensionSupported(_THIS, const char *extension)
    9.16 +{
    9.17 +	const char *extensions;
    9.18 +	const char *start;
    9.19 +	const char *where, *terminator;
    9.20 +
    9.21 +	/* Extension names should not have spaces. */
    9.22 +	where = SDL_strchr(extension, ' ');
    9.23 +	if ( where || *extension == '\0' ) {
    9.24 +	      return 0;
    9.25 +	}
    9.26 +
    9.27 +	extensions = this->gl_data->glXQueryExtensionsString(GFX_Display,SDL_Screen);
    9.28 +	/* It takes a bit of care to be fool-proof about parsing the
    9.29 +	 * OpenGL extensions string. Don't be fooled by sub-strings, etc.
    9.30 +	 */
    9.31 +	
    9.32 +	start = extensions;
    9.33 +	
    9.34 +	for (;;) {
    9.35 +		where = SDL_strstr(start, extension);
    9.36 +		if (!where) break;
    9.37 +		
    9.38 +		terminator = where + strlen(extension);
    9.39 +		if (where == start || *(where - 1) == ' ')
    9.40 +	        if (*terminator == ' ' || *terminator == '\0') return 1;
    9.41 +						  
    9.42 +		start = terminator;
    9.43 +	}
    9.44 +	return 0;
    9.45 +}
    9.46 +#endif /* SDL_VIDEO_OPENGL_GLX */
    9.47 +
    9.48  XVisualInfo *X11_GL_GetVisual(_THIS)
    9.49  {
    9.50  #if SDL_VIDEO_OPENGL_GLX
    9.51 @@ -138,6 +179,12 @@
    9.52  		attribs[i++] = this->gl_config.multisamplesamples;
    9.53  	}
    9.54  
    9.55 +	if( this->gl_config.accelerated >= 0 &&
    9.56 +	    glXExtensionSupported(this, "GLX_EXT_visual_rating") ) {
    9.57 +		attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
    9.58 +		attribs[i++] = this->gl_config.accelerated ? GLX_NONE : GLX_DONT_CARE;
    9.59 +	}
    9.60 +
    9.61  #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */
    9.62  	if ( !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) {
    9.63  		attribs[i++] = GLX_X_VISUAL_TYPE;
    9.64 @@ -205,18 +252,36 @@
    9.65  {
    9.66  	int retval;
    9.67  #if SDL_VIDEO_OPENGL_GLX
    9.68 +
    9.69  	/* We do this to create a clean separation between X and GLX errors. */
    9.70  	XSync( SDL_Display, False );
    9.71  	glx_context = this->gl_data->glXCreateContext(GFX_Display, 
    9.72  				     glx_visualinfo, NULL, True);
    9.73  	XSync( GFX_Display, False );
    9.74  
    9.75 -	if (glx_context == NULL) {
    9.76 +	if ( glx_context == NULL ) {
    9.77  		SDL_SetError("Could not create GL context");
    9.78 -		return -1;
    9.79 +		return(-1);
    9.80  	}
    9.81 +	if ( X11_GL_MakeCurrent(this) < 0 ) {
    9.82 +		return(-1);
    9.83 +	}
    9.84 +	gl_active = 1;
    9.85  
    9.86 -	gl_active = 1;
    9.87 +	if ( !glXExtensionSupported(this, "SGI_swap_control") ) {
    9.88 +		this->gl_data->glXSwapIntervalSGI = NULL;
    9.89 +	}
    9.90 +	if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) {
    9.91 +		this->gl_data->glXSwapIntervalMESA = NULL;
    9.92 +		this->gl_data->glXGetSwapIntervalMESA = NULL;
    9.93 +	}
    9.94 +	if ( this->gl_config.swap_control >= 0 ) {
    9.95 +		if ( this->gl_data->glXSwapIntervalMESA ) {
    9.96 +			this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control);
    9.97 +		} else if ( this->gl_data->glXSwapIntervalSGI ) {
    9.98 +			this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control);
    9.99 +		}
   9.100 +	}
   9.101  #else
   9.102  	SDL_SetError("X11 driver not configured with OpenGL");
   9.103  #endif
   9.104 @@ -319,6 +384,27 @@
   9.105   	    case SDL_GL_MULTISAMPLESAMPLES:
   9.106   		glx_attrib = GLX_SAMPLES_ARB;
   9.107   		break;
   9.108 + 	    case SDL_GL_ACCELERATED_VISUAL:
   9.109 +		if ( glXExtensionSupported(this, "GLX_EXT_visual_rating") ) {
   9.110 +			glx_attrib = GLX_VISUAL_CAVEAT_EXT;
   9.111 +			retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
   9.112 +			if ( *value == GLX_SLOW_VISUAL_EXT ) {
   9.113 +				*value = SDL_FALSE;
   9.114 +			} else {
   9.115 +				*value = SDL_TRUE;
   9.116 +			}
   9.117 +			return retval;
   9.118 +		} else {
   9.119 +			return(-1);
   9.120 +		}
   9.121 +		break;
   9.122 +	    case SDL_GL_SWAP_CONTROL:
   9.123 +		if ( this->gl_data->glXGetSwapIntervalMESA ) {
   9.124 +			return this->gl_data->glXGetSwapIntervalMESA();
   9.125 +		} else {
   9.126 +			return(-1)/*(this->gl_config.swap_control > 0)*/;
   9.127 +		}
   9.128 +		break;
   9.129  	    default:
   9.130  		return(-1);
   9.131  	}
   9.132 @@ -348,6 +434,9 @@
   9.133  		this->gl_data->glXDestroyContext = NULL;
   9.134  		this->gl_data->glXMakeCurrent = NULL;
   9.135  		this->gl_data->glXSwapBuffers = NULL;
   9.136 +		this->gl_data->glXSwapIntervalSGI = NULL;
   9.137 +		this->gl_data->glXSwapIntervalMESA = NULL;
   9.138 +		this->gl_data->glXGetSwapIntervalMESA = NULL;
   9.139  
   9.140  		this->gl_config.dll_handle = NULL;
   9.141  		this->gl_config.driver_loaded = 0;
   9.142 @@ -400,7 +489,12 @@
   9.143  		(int (*)(Display *, XVisualInfo *, int, int *)) SDL_LoadFunction(handle, "glXGetConfig");
   9.144  	this->gl_data->glXQueryExtensionsString =
   9.145  		(const char *(*)(Display *, int)) SDL_LoadFunction(handle, "glXQueryExtensionsString");
   9.146 -	
   9.147 +	this->gl_data->glXSwapIntervalSGI =
   9.148 +		(int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI");
   9.149 +	this->gl_data->glXSwapIntervalMESA =
   9.150 +		(GLint (*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA");
   9.151 +	this->gl_data->glXGetSwapIntervalMESA =
   9.152 +		(GLint (*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA");
   9.153  
   9.154  	if ( (this->gl_data->glXChooseVisual == NULL) || 
   9.155  	     (this->gl_data->glXCreateContext == NULL) ||
    10.1 --- a/src/video/x11/SDL_x11gl_c.h	Thu Apr 27 05:49:51 2006 +0000
    10.2 +++ b/src/video/x11/SDL_x11gl_c.h	Thu Apr 27 09:09:48 2006 +0000
    10.3 @@ -71,7 +71,10 @@
    10.4  	    ( Display* dpy,
    10.5  	      int screen );
    10.6  
    10.7 -    
    10.8 +    int (*glXSwapIntervalSGI) ( int interval );
    10.9 +    GLint (*glXSwapIntervalMESA) ( unsigned interval );
   10.10 +    GLint (*glXGetSwapIntervalMESA) ( void );
   10.11 +
   10.12  #endif /* SDL_VIDEO_OPENGL_GLX */
   10.13  };
   10.14  
    11.1 --- a/test/testgl.c	Thu Apr 27 05:49:51 2006 +0000
    11.2 +++ b/test/testgl.c	Thu Apr 27 09:09:48 2006 +0000
    11.3 @@ -361,7 +361,7 @@
    11.4  }
    11.5  
    11.6  int RunGLTest( int argc, char* argv[],
    11.7 -               int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa )
    11.8 +               int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa, int sync, int accel )
    11.9  {
   11.10  	int i;
   11.11  	int rgb_size[3];
   11.12 @@ -443,6 +443,14 @@
   11.13  		SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
   11.14  		SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
   11.15  	}
   11.16 +	if ( accel ) {
   11.17 +		SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
   11.18 +	}
   11.19 +	if ( sync ) {
   11.20 +		SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
   11.21 +	} else {
   11.22 +		SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
   11.23 +	}
   11.24  	if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
   11.25  		fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
   11.26  		SDL_Quit();
   11.27 @@ -469,9 +477,17 @@
   11.28  	printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
   11.29  	if ( fsaa ) {
   11.30  		SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
   11.31 -		printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
   11.32 +		printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
   11.33  		SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
   11.34 -		printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
   11.35 +		printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
   11.36 +	}
   11.37 +	if ( accel ) {
   11.38 +		SDL_GL_GetAttribute( SDL_GL_ACCELERATED_VISUAL, &value );
   11.39 +		printf( "SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value );
   11.40 +	}
   11.41 +	if ( sync ) {
   11.42 +		SDL_GL_GetAttribute( SDL_GL_SWAP_CONTROL, &value );
   11.43 +		printf( "SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value );
   11.44  	}
   11.45  
   11.46  	/* Set the window manager title bar */
   11.47 @@ -678,6 +694,8 @@
   11.48  	float gamma = 0.0;
   11.49  	int noframe = 0;
   11.50  	int fsaa = 0;
   11.51 +	int accel = 0;
   11.52 +	int sync = 0;
   11.53  
   11.54  	logo = 0;
   11.55  	slowly = 0;
   11.56 @@ -707,6 +725,12 @@
   11.57  		if ( strcmp(argv[i], "-fsaa") == 0 ) {
   11.58   		       ++fsaa;
   11.59  		}
   11.60 +		if ( strcmp(argv[i], "-accel") == 0 ) {
   11.61 + 		       ++accel;
   11.62 +		}
   11.63 +		if ( strcmp(argv[i], "-sync") == 0 ) {
   11.64 + 		       ++sync;
   11.65 +		}
   11.66  		if ( strncmp(argv[i], "-h", 2) == 0 ) {
   11.67   		       printf(
   11.68  "Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n",
   11.69 @@ -715,7 +739,7 @@
   11.70  		}
   11.71  	}
   11.72  	for ( i=0; i<numtests; ++i ) {
   11.73 - 		RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa);
   11.74 + 		RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa, sync, accel);
   11.75  	}
   11.76  	return 0;
   11.77  }