From 2e622547c5b693ea81ab5ea30653824a0f8096f9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 24 Jun 2006 02:48:55 +0000 Subject: [PATCH] Merged SDL_GL_SWAP_CONTROL fix from SDL 1.2 --- src/video/wincommon/SDL_wingl.c | 33 ++++++++++++++++++++++++--------- src/video/x11/SDL_x11gl.c | 7 +++++-- test/testgl.c | 2 +- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/video/wincommon/SDL_wingl.c b/src/video/wincommon/SDL_wingl.c index 783b9e564..85d60b13b 100644 --- a/src/video/wincommon/SDL_wingl.c +++ b/src/video/wincommon/SDL_wingl.c @@ -150,8 +150,8 @@ Init_WGL_ARB_extensions(_THIS) this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *) (HDC, const int *, const FLOAT *, UINT, int *, - UINT *)) this->gl_data-> - wglGetProcAddress("wglChoosePixelFormatARB"); + UINT *)) + this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB"); this->gl_data->wglGetPixelFormatAttribivARB = (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *)) this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB"); @@ -357,7 +357,12 @@ WIN_GL_SetupWindow(_THIS) /* Uh oh, something is seriously wrong here... */ wglext = NULL; } - if (!wglext || !SDL_strstr(wglext, "WGL_EXT_swap_control")) { + if (wglext && SDL_strstr(wglext, "WGL_EXT_swap_control")) { + this->gl_data->wglSwapIntervalEXT = + WIN_GL_GetProcAddress(this, "wglSwapIntervalEXT"); + this->gl_data->wglGetSwapIntervalEXT = + WIN_GL_GetProcAddress(this, "wglGetSwapIntervalEXT"); + } else { this->gl_data->wglSwapIntervalEXT = NULL; this->gl_data->wglGetSwapIntervalEXT = NULL; } @@ -470,9 +475,8 @@ WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) break; case SDL_GL_ACCELERATED_VISUAL: wgl_attrib = WGL_ACCELERATION_ARB; - this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, - pixel_format, 0, - 1, &wgl_attrib, + this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, + 0, 1, &wgl_attrib, value); if (*value == WGL_NO_ACCELERATION_ARB) { *value = SDL_FALSE; @@ -483,15 +487,17 @@ WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) break; case SDL_GL_SWAP_CONTROL: if (this->gl_data->wglGetSwapIntervalEXT) { - return this->gl_data->wglGetSwapIntervalEXT(); + *value = this->gl_data->wglGetSwapIntervalEXT(); + return 0; } else { return -1; } + break; default: return (-1); } - this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, - 0, 1, &wgl_attrib, value); + this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, + 1, &wgl_attrib, value); return 0; } @@ -551,6 +557,14 @@ WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) case SDL_GL_MULTISAMPLESAMPLES: *value = 1; break; + case SDL_GL_SWAP_CONTROL: + if (this->gl_data->wglGetSwapIntervalEXT) { + *value = this->gl_data->wglGetSwapIntervalEXT(); + return 0; + } else { + return -1; + } + break; default: retval = -1; break; @@ -653,4 +667,5 @@ WIN_GL_GetProcAddress(_THIS, const char *proc) } #endif /* SDL_VIDEO_OPENGL */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c index 25e59f79c..f049857d8 100644 --- a/src/video/x11/SDL_x11gl.c +++ b/src/video/x11/SDL_x11gl.c @@ -411,9 +411,10 @@ X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) break; case SDL_GL_SWAP_CONTROL: if (this->gl_data->glXGetSwapIntervalMESA) { - return this->gl_data->glXGetSwapIntervalMESA(); + *value = this->gl_data->glXGetSwapIntervalMESA(); + return (0); } else { - return (-1) /*(this->gl_config.swap_control > 0) */ ; + return (-1); } break; default: @@ -567,3 +568,5 @@ X11_GL_GetProcAddress(_THIS, const char *proc) } #endif /* SDL_VIDEO_OPENGL_GLX */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testgl.c b/test/testgl.c index a5a5c9bec..6b3254647 100644 --- a/test/testgl.c +++ b/test/testgl.c @@ -746,7 +746,7 @@ main(int argc, char *argv[]) } if (strncmp(argv[i], "-h", 2) == 0) { printf - ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n", + ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n", argv[0]); exit(0); }