Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11gl.c @ 1736:3b2a92126f4d
Implemented bug #2, 117:
Date: Mon, 21 Mar 2005 12:06:14 +0100
From: Per Inge Mathisen
Subject: Re: [SDL] Outstanding patches?
The patch adds support for setting SDL_GL_SWAP_CONTROL to Windows and
X11. In Windows you can also query this enum to check that it is
working, or see what the default is - such functionality does not
exist in GLX. For more information on the standards implemented:
http://oss.sgi.com/projects/ogl-sample/registry/SGI/swap_control.txt
http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 27 Apr 2006 07:59:16 +0000 |
parents | d75c2d78e87d |
children | eacc5bc01d1c |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11gl.c Wed Apr 26 23:17:39 2006 +0000 +++ b/src/video/x11/SDL_x11gl.c Thu Apr 27 07:59:16 2006 +0000 @@ -205,18 +205,39 @@ { int retval; #if SDL_VIDEO_OPENGL_GLX + const char *glXext; + /* We do this to create a clean separation between X and GLX errors. */ XSync( SDL_Display, False ); glx_context = this->gl_data->glXCreateContext(GFX_Display, glx_visualinfo, NULL, True); XSync( GFX_Display, False ); - if (glx_context == NULL) { + if ( glx_context == NULL ) { SDL_SetError("Could not create GL context"); - return -1; + return(-1); + } + if ( X11_GL_MakeCurrent(this) < 0 ) { + return(-1); + } + gl_active = 1; + + /* The use of strstr here should be safe */ + glXext = this->gl_data->glXQueryExtensionsString(GFX_Display, DefaultScreen(GFX_Display)); + if ( !SDL_strstr(glXext, "SGI_swap_control") ) { + this->gl_data->glXSwapIntervalSGI = NULL; } - - gl_active = 1; + if ( !SDL_strstr(glXext, "GLX_MESA_swap_control") ) { + this->gl_data->glXSwapIntervalMESA = NULL; + this->gl_data->glXGetSwapIntervalMESA = NULL; + } + if ( this->gl_config.swap_control >= 0 ) { + if ( this->gl_data->glXSwapIntervalMESA ) { + this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); + } else if ( this->gl_data->glXSwapIntervalSGI ) { + this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control); + } + } #else SDL_SetError("X11 driver not configured with OpenGL"); #endif @@ -319,6 +340,13 @@ case SDL_GL_MULTISAMPLESAMPLES: glx_attrib = GLX_SAMPLES_ARB; break; + case SDL_GL_SWAP_CONTROL: + if ( this->gl_data->glXGetSwapIntervalMESA ) { + return this->gl_data->glXGetSwapIntervalMESA(); + } else { + return -1 /*(this->gl_config.swap_control > 0)*/; + } + break; default: return(-1); } @@ -348,6 +376,9 @@ this->gl_data->glXDestroyContext = NULL; this->gl_data->glXMakeCurrent = NULL; this->gl_data->glXSwapBuffers = NULL; + this->gl_data->glXSwapIntervalSGI = NULL; + this->gl_data->glXSwapIntervalMESA = NULL; + this->gl_data->glXGetSwapIntervalMESA = NULL; this->gl_config.dll_handle = NULL; this->gl_config.driver_loaded = 0; @@ -400,7 +431,12 @@ (int (*)(Display *, XVisualInfo *, int, int *)) SDL_LoadFunction(handle, "glXGetConfig"); this->gl_data->glXQueryExtensionsString = (const char *(*)(Display *, int)) SDL_LoadFunction(handle, "glXQueryExtensionsString"); - + this->gl_data->glXSwapIntervalSGI = + (int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI"); + this->gl_data->glXSwapIntervalMESA = + (GLint (*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA"); + this->gl_data->glXGetSwapIntervalMESA = + (GLint (*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA"); if ( (this->gl_data->glXChooseVisual == NULL) || (this->gl_data->glXCreateContext == NULL) ||