src/video/win32/SDL_win32opengl.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 22 Jul 2006 21:58:17 +0000
changeset 1926 307355678142
parent 1913 83420da906a5
child 1936 83946ee0ff1f
permissions -rw-r--r--
Added SDL_GL_ExtensionSupported()
Use GL_ARB_texture_rectangle in the OpenGL renderer, if supported.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_win32video.h"
    25 
    26 /* WGL implementation of SDL OpenGL support */
    27 
    28 #if SDL_VIDEO_OPENGL
    29 #include "SDL_opengl.h"
    30 
    31 #define DEFAULT_GL_DRIVER_PATH "OPENGL32.DLL"
    32 
    33 
    34 int
    35 WIN_GL_LoadLibrary(_THIS, const char *path)
    36 {
    37     LPTSTR wpath;
    38     HANDLE handle;
    39 
    40     if (_this->gl_config.driver_loaded) {
    41         if (path) {
    42             SDL_SetError("OpenGL library already loaded");
    43             return -1;
    44         } else {
    45             ++_this->gl_config.driver_loaded;
    46             return 0;
    47         }
    48     }
    49     if (path == NULL) {
    50         path = DEFAULT_GL_DRIVER_PATH;
    51     }
    52     wpath = WIN_UTF8ToString(path);
    53     handle = LoadLibrary(wpath);
    54     SDL_free(wpath);
    55     if (!handle) {
    56         char message[1024];
    57         SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
    58                      path);
    59         WIN_SetError(message);
    60         return -1;
    61     }
    62 
    63     /* Load function pointers */
    64     _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
    65         GetProcAddress(handle, "wglGetProcAddress");
    66     _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
    67         GetProcAddress(handle, "wglCreateContext");
    68     _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
    69         GetProcAddress(handle, "wglDeleteContext");
    70     _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
    71         GetProcAddress(handle, "wglMakeCurrent");
    72     _this->gl_data->wglSwapIntervalEXT = (void (WINAPI *) (int))
    73         GetProcAddress(handle, "wglSwapIntervalEXT");
    74     _this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *) (void))
    75         GetProcAddress(handle, "wglGetSwapIntervalEXT");
    76 
    77     if (!_this->gl_data->wglGetProcAddress ||
    78         !_this->gl_data->wglCreateContext ||
    79         !_this->gl_data->wglDeleteContext ||
    80         !_this->gl_data->wglMakeCurrent) {
    81         SDL_SetError("Could not retrieve OpenGL functions");
    82         FreeLibrary(handle);
    83         return -1;
    84     }
    85 
    86     _this->gl_config.dll_handle = handle;
    87     SDL_strlcpy(_this->gl_config.driver_path, path,
    88                 SDL_arraysize(_this->gl_config.driver_path));
    89     _this->gl_config.driver_loaded = 1;
    90     return 0;
    91 }
    92 
    93 void *
    94 WIN_GL_GetProcAddress(_THIS, const char *proc)
    95 {
    96     void *func;
    97 
    98     /* This is to pick up extensions */
    99     func = _this->gl_data->wglGetProcAddress(proc);
   100     if (!func) {
   101         /* This is probably a normal GL function */
   102         func = GetProcAddress(_this->gl_config.dll_handle, proc);
   103     }
   104     return func;
   105 }
   106 
   107 static void
   108 WIN_GL_UnloadLibrary(_THIS)
   109 {
   110     if (_this->gl_config.driver_loaded > 0) {
   111         if (--_this->gl_config.driver_loaded > 0) {
   112             return;
   113         }
   114         FreeLibrary((HMODULE) _this->gl_config.dll_handle);
   115         _this->gl_config.dll_handle = NULL;
   116     }
   117 }
   118 
   119 static void
   120 WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR * pfd)
   121 {
   122     SDL_zerop(pfd);
   123     pfd->nSize = sizeof(*pfd);
   124     pfd->nVersion = 1;
   125     pfd->dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL);
   126     if (_this->gl_config.double_buffer) {
   127         pfd->dwFlags |= PFD_DOUBLEBUFFER;
   128     }
   129     if (_this->gl_config.stereo) {
   130         pfd->dwFlags |= PFD_STEREO;
   131     }
   132     pfd->iLayerType = PFD_MAIN_PLANE;
   133     pfd->iPixelType = PFD_TYPE_RGBA;
   134     pfd->cRedBits = _this->gl_config.red_size;
   135     pfd->cGreenBits = _this->gl_config.green_size;
   136     pfd->cBlueBits = _this->gl_config.blue_size;
   137     pfd->cAlphaBits = _this->gl_config.alpha_size;
   138     if (_this->gl_config.buffer_size) {
   139         pfd->cColorBits =
   140             _this->gl_config.buffer_size - _this->gl_config.alpha_size;
   141     } else {
   142         pfd->cColorBits = (pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits);
   143     }
   144     pfd->cAccumRedBits = _this->gl_config.accum_red_size;
   145     pfd->cAccumGreenBits = _this->gl_config.accum_green_size;
   146     pfd->cAccumBlueBits = _this->gl_config.accum_blue_size;
   147     pfd->cAccumAlphaBits = _this->gl_config.accum_alpha_size;
   148     pfd->cAccumBits =
   149         (pfd->cAccumRedBits + pfd->cAccumGreenBits + pfd->cAccumBlueBits +
   150          pfd->cAccumAlphaBits);
   151     pfd->cDepthBits = _this->gl_config.depth_size;
   152     pfd->cStencilBits = _this->gl_config.stencil_size;
   153 }
   154 
   155 static SDL_bool
   156 HasExtension(const char *extension, const char *extensions)
   157 {
   158     const char *start;
   159     const char *where, *terminator;
   160 
   161     /* Extension names should not have spaces. */
   162     where = SDL_strchr(extension, ' ');
   163     if (where || *extension == '\0')
   164         return SDL_FALSE;
   165 
   166     if (!extensions)
   167         return SDL_FALSE;
   168 
   169     /* It takes a bit of care to be fool-proof about parsing the
   170      * OpenGL extensions string. Don't be fooled by sub-strings,
   171      * etc. */
   172 
   173     start = extensions;
   174 
   175     for (;;) {
   176         where = SDL_strstr(start, extension);
   177         if (!where)
   178             break;
   179 
   180         terminator = where + SDL_strlen(extension);
   181         if (where == start || *(where - 1) == ' ')
   182             if (*terminator == ' ' || *terminator == '\0')
   183                 return SDL_TRUE;
   184 
   185         start = terminator;
   186     }
   187     return SDL_FALSE;
   188 }
   189 
   190 static void
   191 WIN_GL_InitExtensions(_THIS)
   192 {
   193     HWND hwnd;
   194     HDC hdc;
   195     PIXELFORMATDESCRIPTOR pfd;
   196     int pixel_format;
   197     HGLRC hglrc;
   198     const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0;
   199     const char *extensions;
   200 
   201     hwnd =
   202         CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0,
   203                      10, 10, NULL, NULL, SDL_Instance, NULL);
   204     WIN_PumpEvents(_this);
   205 
   206     hdc = GetDC(hwnd);
   207 
   208     WIN_GL_SetupPixelFormat(_this, &pfd);
   209     pixel_format = ChoosePixelFormat(hdc, &pfd);
   210     SetPixelFormat(hdc, pixel_format, &pfd);
   211 
   212     hglrc = _this->gl_data->wglCreateContext(hdc);
   213     if (hglrc) {
   214         _this->gl_data->wglMakeCurrent(hdc, hglrc);
   215     }
   216 
   217     wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
   218         _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
   219     if (wglGetExtensionsStringARB) {
   220         extensions = wglGetExtensionsStringARB(hdc);
   221     } else {
   222         extensions = NULL;
   223     }
   224 
   225     /* Check for WGL_ARB_pixel_format */
   226     _this->gl_data->WGL_ARB_pixel_format = 0;
   227     if (HasExtension("WGL_ARB_pixel_format", extensions)) {
   228         _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
   229                                                    (HDC, const int *,
   230                                                     const FLOAT *, UINT,
   231                                                     int *, UINT *))
   232             WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
   233         _this->gl_data->wglGetPixelFormatAttribivARB =
   234             (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
   235             WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
   236 
   237         if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
   238             (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
   239             _this->gl_data->WGL_ARB_pixel_format = 1;
   240         }
   241     }
   242 
   243     /* Check for WGL_EXT_swap_control */
   244     if (HasExtension("WGL_EXT_swap_control", extensions)) {
   245         _this->gl_data->wglSwapIntervalEXT =
   246             WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
   247         _this->gl_data->wglGetSwapIntervalEXT =
   248             WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
   249     }
   250 
   251     if (hglrc) {
   252         _this->gl_data->wglMakeCurrent(NULL, NULL);
   253         _this->gl_data->wglDeleteContext(hglrc);
   254     }
   255     ReleaseDC(hwnd, hdc);
   256     DestroyWindow(hwnd);
   257     WIN_PumpEvents(_this);
   258 }
   259 
   260 static void
   261 WIN_GL_Shutdown(_THIS)
   262 {
   263     if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
   264         return;
   265     }
   266 
   267     WIN_GL_UnloadLibrary(_this);
   268 
   269     SDL_free(_this->gl_data);
   270     _this->gl_data = NULL;
   271 }
   272 
   273 static int
   274 WIN_GL_Initialize(_THIS)
   275 {
   276     if (_this->gl_data) {
   277         ++_this->gl_data->initialized;
   278         return 0;
   279     }
   280 
   281     _this->gl_data =
   282         (struct SDL_GLDriverData *) SDL_calloc(1,
   283                                                sizeof(struct
   284                                                       SDL_GLDriverData));
   285     if (!_this->gl_data) {
   286         SDL_OutOfMemory();
   287         return -1;
   288     }
   289     _this->gl_data->initialized = 1;
   290 
   291     if (WIN_GL_LoadLibrary(_this, NULL) < 0) {
   292         return -1;
   293     }
   294 
   295     /* Initialize extensions */
   296     WIN_GL_InitExtensions(_this);
   297 
   298     return 0;
   299 }
   300 
   301 int
   302 WIN_GL_SetupWindow(_THIS, SDL_Window * window)
   303 {
   304     HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   305     PIXELFORMATDESCRIPTOR pfd;
   306     int pixel_format;
   307     unsigned int matching;
   308     int iAttribs[64];
   309     int *iAttr;
   310     float fAttribs[1] = { 0 };
   311 
   312     if (WIN_GL_Initialize(_this) < 0) {
   313         return -1;
   314     }
   315 
   316     WIN_GL_SetupPixelFormat(_this, &pfd);
   317 
   318     /* setup WGL_ARB_pixel_format attribs */
   319     iAttr = &iAttribs[0];
   320 
   321     *iAttr++ = WGL_DRAW_TO_WINDOW_ARB;
   322     *iAttr++ = GL_TRUE;
   323     *iAttr++ = WGL_ACCELERATION_ARB;
   324     *iAttr++ = WGL_FULL_ACCELERATION_ARB;
   325     *iAttr++ = WGL_RED_BITS_ARB;
   326     *iAttr++ = _this->gl_config.red_size;
   327     *iAttr++ = WGL_GREEN_BITS_ARB;
   328     *iAttr++ = _this->gl_config.green_size;
   329     *iAttr++ = WGL_BLUE_BITS_ARB;
   330     *iAttr++ = _this->gl_config.blue_size;
   331 
   332     if (_this->gl_config.alpha_size) {
   333         *iAttr++ = WGL_ALPHA_BITS_ARB;
   334         *iAttr++ = _this->gl_config.alpha_size;
   335     }
   336 
   337     *iAttr++ = WGL_DOUBLE_BUFFER_ARB;
   338     *iAttr++ = _this->gl_config.double_buffer;
   339 
   340     *iAttr++ = WGL_DEPTH_BITS_ARB;
   341     *iAttr++ = _this->gl_config.depth_size;
   342 
   343     if (_this->gl_config.stencil_size) {
   344         *iAttr++ = WGL_STENCIL_BITS_ARB;
   345         *iAttr++ = _this->gl_config.stencil_size;
   346     }
   347 
   348     if (_this->gl_config.accum_red_size) {
   349         *iAttr++ = WGL_ACCUM_RED_BITS_ARB;
   350         *iAttr++ = _this->gl_config.accum_red_size;
   351     }
   352 
   353     if (_this->gl_config.accum_green_size) {
   354         *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB;
   355         *iAttr++ = _this->gl_config.accum_green_size;
   356     }
   357 
   358     if (_this->gl_config.accum_blue_size) {
   359         *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB;
   360         *iAttr++ = _this->gl_config.accum_blue_size;
   361     }
   362 
   363     if (_this->gl_config.accum_alpha_size) {
   364         *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB;
   365         *iAttr++ = _this->gl_config.accum_alpha_size;
   366     }
   367 
   368     if (_this->gl_config.stereo) {
   369         *iAttr++ = WGL_STEREO_ARB;
   370         *iAttr++ = GL_TRUE;
   371     }
   372 
   373     if (_this->gl_config.multisamplebuffers) {
   374         *iAttr++ = WGL_SAMPLE_BUFFERS_ARB;
   375         *iAttr++ = _this->gl_config.multisamplebuffers;
   376     }
   377 
   378     if (_this->gl_config.multisamplesamples) {
   379         *iAttr++ = WGL_SAMPLES_ARB;
   380         *iAttr++ = _this->gl_config.multisamplesamples;
   381     }
   382 
   383     if (_this->gl_config.accelerated >= 0) {
   384         *iAttr++ = WGL_ACCELERATION_ARB;
   385         *iAttr++ =
   386             (_this->gl_config.
   387              accelerated ? WGL_GENERIC_ACCELERATION_ARB :
   388              WGL_NO_ACCELERATION_ARB);
   389     }
   390 
   391     *iAttr = 0;
   392 
   393     /* Choose and set the closest available pixel format */
   394     if (!_this->gl_data->WGL_ARB_pixel_format
   395         || !_this->gl_data->wglChoosePixelFormatARB(hdc, iAttribs, fAttribs,
   396                                                     1, &pixel_format,
   397                                                     &matching) || !matching) {
   398         pixel_format = ChoosePixelFormat(hdc, &pfd);
   399     }
   400     if (!pixel_format) {
   401         SDL_SetError("No matching GL pixel format available");
   402         return -1;
   403     }
   404     if (!SetPixelFormat(hdc, pixel_format, &pfd)) {
   405         WIN_SetError("SetPixelFormat()");
   406         return (-1);
   407     }
   408     return 0;
   409 }
   410 
   411 void
   412 WIN_GL_CleanupWindow(_THIS, SDL_Window * window)
   413 {
   414     WIN_GL_Shutdown(_this);
   415 }
   416 
   417 int
   418 WIN_GL_GetWindowAttribute(_THIS, SDL_Window * window, SDL_GLattr attrib,
   419                           int *value)
   420 {
   421     HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   422     int pixel_format;
   423 
   424     pixel_format = GetPixelFormat(hdc);
   425 
   426     if (_this->gl_data->WGL_ARB_pixel_format) {
   427         int wgl_attrib;
   428 
   429         switch (attrib) {
   430         case SDL_GL_RED_SIZE:
   431             wgl_attrib = WGL_RED_BITS_ARB;
   432             break;
   433         case SDL_GL_GREEN_SIZE:
   434             wgl_attrib = WGL_GREEN_BITS_ARB;
   435             break;
   436         case SDL_GL_BLUE_SIZE:
   437             wgl_attrib = WGL_BLUE_BITS_ARB;
   438             break;
   439         case SDL_GL_ALPHA_SIZE:
   440             wgl_attrib = WGL_ALPHA_BITS_ARB;
   441             break;
   442         case SDL_GL_DOUBLEBUFFER:
   443             wgl_attrib = WGL_DOUBLE_BUFFER_ARB;
   444             break;
   445         case SDL_GL_BUFFER_SIZE:
   446             wgl_attrib = WGL_COLOR_BITS_ARB;
   447             break;
   448         case SDL_GL_DEPTH_SIZE:
   449             wgl_attrib = WGL_DEPTH_BITS_ARB;
   450             break;
   451         case SDL_GL_STENCIL_SIZE:
   452             wgl_attrib = WGL_STENCIL_BITS_ARB;
   453             break;
   454         case SDL_GL_ACCUM_RED_SIZE:
   455             wgl_attrib = WGL_ACCUM_RED_BITS_ARB;
   456             break;
   457         case SDL_GL_ACCUM_GREEN_SIZE:
   458             wgl_attrib = WGL_ACCUM_GREEN_BITS_ARB;
   459             break;
   460         case SDL_GL_ACCUM_BLUE_SIZE:
   461             wgl_attrib = WGL_ACCUM_BLUE_BITS_ARB;
   462             break;
   463         case SDL_GL_ACCUM_ALPHA_SIZE:
   464             wgl_attrib = WGL_ACCUM_ALPHA_BITS_ARB;
   465             break;
   466         case SDL_GL_STEREO:
   467             wgl_attrib = WGL_STEREO_ARB;
   468             break;
   469         case SDL_GL_MULTISAMPLEBUFFERS:
   470             wgl_attrib = WGL_SAMPLE_BUFFERS_ARB;
   471             break;
   472         case SDL_GL_MULTISAMPLESAMPLES:
   473             wgl_attrib = WGL_SAMPLES_ARB;
   474             break;
   475         case SDL_GL_ACCELERATED_VISUAL:
   476             wgl_attrib = WGL_ACCELERATION_ARB;
   477             _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0,
   478                                                          1, &wgl_attrib,
   479                                                          value);
   480             if (*value == WGL_NO_ACCELERATION_ARB) {
   481                 *value = SDL_FALSE;
   482             } else {
   483                 *value = SDL_TRUE;
   484             }
   485             return 0;
   486             break;
   487         default:
   488             return (-1);
   489         }
   490         _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0, 1,
   491                                                      &wgl_attrib, value);
   492         return 0;
   493     } else {
   494         PIXELFORMATDESCRIPTOR pfd;
   495         int retval;
   496 
   497         if (!DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd)) {
   498             WIN_SetError("DescribePixelFormat()");
   499             return -1;
   500         }
   501         retval = 0;
   502         switch (attrib) {
   503         case SDL_GL_RED_SIZE:
   504             *value = pfd.cRedBits;
   505             break;
   506         case SDL_GL_GREEN_SIZE:
   507             *value = pfd.cGreenBits;
   508             break;
   509         case SDL_GL_BLUE_SIZE:
   510             *value = pfd.cBlueBits;
   511             break;
   512         case SDL_GL_ALPHA_SIZE:
   513             *value = pfd.cAlphaBits;
   514             break;
   515         case SDL_GL_DOUBLEBUFFER:
   516             if (pfd.dwFlags & PFD_DOUBLEBUFFER) {
   517                 *value = 1;
   518             } else {
   519                 *value = 0;
   520             }
   521             break;
   522         case SDL_GL_BUFFER_SIZE:
   523             *value = pfd.cColorBits;
   524             break;
   525         case SDL_GL_DEPTH_SIZE:
   526             *value = pfd.cDepthBits;
   527             break;
   528         case SDL_GL_STENCIL_SIZE:
   529             *value = pfd.cStencilBits;
   530             break;
   531         case SDL_GL_ACCUM_RED_SIZE:
   532             *value = pfd.cAccumRedBits;
   533             break;
   534         case SDL_GL_ACCUM_GREEN_SIZE:
   535             *value = pfd.cAccumGreenBits;
   536             break;
   537         case SDL_GL_ACCUM_BLUE_SIZE:
   538             *value = pfd.cAccumBlueBits;
   539             break;
   540         case SDL_GL_ACCUM_ALPHA_SIZE:
   541             *value = pfd.cAccumAlphaBits;
   542             break;
   543         case SDL_GL_STEREO:
   544             if (pfd.dwFlags & PFD_STEREO) {
   545                 *value = 1;
   546             } else {
   547                 *value = 0;
   548             }
   549             break;
   550         case SDL_GL_MULTISAMPLEBUFFERS:
   551             *value = 0;
   552             break;
   553         case SDL_GL_MULTISAMPLESAMPLES:
   554             *value = 1;
   555             break;
   556         default:
   557             retval = -1;
   558             break;
   559         }
   560         return retval;
   561     }
   562 }
   563 
   564 SDL_GLContext
   565 WIN_GL_CreateContext(_THIS, SDL_Window * window)
   566 {
   567     HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   568 
   569     return _this->gl_data->wglCreateContext(hdc);
   570 }
   571 
   572 int
   573 WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
   574 {
   575     HDC hdc;
   576     int status;
   577 
   578     if (window) {
   579         hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   580     } else {
   581         hdc = NULL;
   582     }
   583     if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC) context)) {
   584         WIN_SetError("wglMakeCurrent()");
   585         status = -1;
   586     } else {
   587         status = 0;
   588     }
   589     return status;
   590 }
   591 
   592 int
   593 WIN_GL_SetSwapInterval(_THIS, int interval)
   594 {
   595     if (_this->gl_data->wglSwapIntervalEXT) {
   596         _this->gl_data->wglSwapIntervalEXT(interval);
   597         return 0;
   598     } else {
   599         SDL_Unsupported();
   600         return -1;
   601     }
   602 }
   603 
   604 int
   605 WIN_GL_GetSwapInterval(_THIS)
   606 {
   607     if (_this->gl_data->wglGetSwapIntervalEXT) {
   608         return _this->gl_data->wglGetSwapIntervalEXT();
   609     } else {
   610         SDL_Unsupported();
   611         return -1;
   612     }
   613 }
   614 
   615 void
   616 WIN_GL_SwapWindow(_THIS, SDL_Window * window)
   617 {
   618     HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   619 
   620     SwapBuffers(hdc);
   621 }
   622 
   623 void
   624 WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
   625 {
   626     if (context) {
   627         _this->gl_data->wglDeleteContext((HGLRC) context);
   628     }
   629 }
   630 
   631 #endif /* SDL_VIDEO_OPENGL */
   632 
   633 
   634 /* vi: set ts=4 sw=4 expandtab: */