From f0c110f75ad53f489639e08aed056db000bf4980 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 10 Oct 2009 06:38:02 +0000 Subject: [PATCH] Cache the swap control setting, even on Mesa. --HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%404002 --- src/video/x11/SDL_x11gl.c | 22 +++++++++------------- src/video/x11/SDL_x11gl_c.h | 4 +--- src/video/x11/SDL_x11video.c | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c index 95e72a60e..a2aa54dfb 100644 --- a/src/video/x11/SDL_x11gl.c +++ b/src/video/x11/SDL_x11gl.c @@ -283,15 +283,16 @@ int X11_GL_CreateContext(_THIS) } if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) { this->gl_data->glXSwapIntervalMESA = NULL; - this->gl_data->glXGetSwapIntervalMESA = NULL; } if ( this->gl_config.swap_control >= 0 ) { + int rc = -1; if ( this->gl_data->glXSwapIntervalMESA ) { - this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); + rc = this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); } else if ( this->gl_data->glXSwapIntervalSGI ) { - if (this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control) == 0) { - this->gl_data->sgi_swap_interval = this->gl_config.swap_control; - } + rc = this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control); + } + if (rc == 0) { + this->gl_data->swap_interval = this->gl_config.swap_control; } } #else @@ -412,11 +413,9 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) } break; case SDL_GL_SWAP_CONTROL: - if ( this->gl_data->glXGetSwapIntervalMESA ) { - *value = this->gl_data->glXGetSwapIntervalMESA(); - return 0; - } else if ( this->gl_data->glXSwapIntervalSGI ) { - *value = this->gl_data->sgi_swap_interval; + if ( ( this->gl_data->glXSwapIntervalMESA ) || + ( this->gl_data->glXSwapIntervalSGI ) ) { + *value = this->gl_data->swap_interval; return 0; } else { unsupported = 1; @@ -469,7 +468,6 @@ void X11_GL_UnloadLibrary(_THIS) 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; @@ -530,8 +528,6 @@ int X11_GL_LoadLibrary(_THIS, const char* path) (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI"); this->gl_data->glXSwapIntervalMESA = (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA"); - this->gl_data->glXGetSwapIntervalMESA = - (GLint (*)(void)) GL_LoadFunction(handle, "glXGetSwapIntervalMESA"); if ( (this->gl_data->glXChooseVisual == NULL) || (this->gl_data->glXCreateContext == NULL) || diff --git a/src/video/x11/SDL_x11gl_c.h b/src/video/x11/SDL_x11gl_c.h index 48143abe6..e72801322 100644 --- a/src/video/x11/SDL_x11gl_c.h +++ b/src/video/x11/SDL_x11gl_c.h @@ -73,9 +73,7 @@ struct SDL_PrivateGLData { int (*glXSwapIntervalSGI) ( int interval ); GLint (*glXSwapIntervalMESA) ( unsigned interval ); - GLint (*glXGetSwapIntervalMESA) ( void ); - - int sgi_swap_interval; + int swap_interval; #endif /* SDL_VIDEO_OPENGL_GLX */ }; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index e22839280..e1f2106a3 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -122,7 +122,7 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex) SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); #if SDL_VIDEO_OPENGL_GLX - device->gl_data->sgi_swap_interval = -1; + device->gl_data->swap_interval = -1; #endif /* Set the driver flags */