diff src/video/wincommon/SDL_wingl.c @ 1703:a51dfda0ff33 SDL-1.3

Merged SDL_GL_SWAP_CONTROL fix from SDL 1.2
author Sam Lantinga <slouken@libsdl.org>
date Sat, 24 Jun 2006 02:48:55 +0000
parents 4da1ee79c9af
children
line wrap: on
line diff
--- a/src/video/wincommon/SDL_wingl.c	Fri Jun 23 09:01:08 2006 +0000
+++ b/src/video/wincommon/SDL_wingl.c	Sat Jun 24 02:48:55 2006 +0000
@@ -150,8 +150,8 @@
         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 @@
         /* 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 @@
             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 @@
             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 @@
     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 @@
 }
 
 #endif /* SDL_VIDEO_OPENGL */
+
 /* vi: set ts=4 sw=4 expandtab: */