Windows: support for OpenGL extension WGL_ARB_context_flush_control.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 20 Mar 2015 12:23:53 -0400
changeset 9413eb50f63a5777
parent 9412 8b1436ce1028
child 9414 669bf9fb901e
Windows: support for OpenGL extension WGL_ARB_context_flush_control.
src/video/windows/SDL_windowsopengl.c
src/video/windows/SDL_windowsopengl.h
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Fri Mar 06 16:03:40 2015 +0000
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Fri Mar 20 12:23:53 2015 -0400
     1.3 @@ -74,6 +74,13 @@
     1.4  #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20A9
     1.5  #endif
     1.6  
     1.7 +#ifndef WGL_ARB_context_flush_control
     1.8 +#define WGL_ARB_context_flush_control
     1.9 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB   0x2097
    1.10 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB           0x0000
    1.11 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB          0x2098
    1.12 +#endif
    1.13 +
    1.14  typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
    1.15                                                              HGLRC
    1.16                                                              hShareContext,
    1.17 @@ -405,6 +412,11 @@
    1.18          _this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_TRUE;
    1.19      }
    1.20  
    1.21 +    /* Check for GLX_ARB_context_flush_control */
    1.22 +    if (HasExtension("WGL_ARB_context_flush_control", extensions)) {
    1.23 +        _this->gl_data->HAS_WGL_ARB_context_flush_control = SDL_TRUE;
    1.24 +    }
    1.25 +
    1.26      _this->gl_data->wglMakeCurrent(hdc, NULL);
    1.27      _this->gl_data->wglDeleteContext(hglrc);
    1.28      ReleaseDC(hwnd, hdc);
    1.29 @@ -648,8 +660,8 @@
    1.30              SDL_SetError("GL 3.x is not supported");
    1.31              context = temp_context;
    1.32          } else {
    1.33 -        /* max 8 attributes plus terminator */
    1.34 -            int attribs[9] = {
    1.35 +        /* max 10 attributes plus terminator */
    1.36 +            int attribs[11] = {
    1.37                  WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
    1.38                  WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
    1.39                  0
    1.40 @@ -668,6 +680,14 @@
    1.41          attribs[iattr++] = _this->gl_config.flags;
    1.42          }
    1.43  
    1.44 +        /* only set if wgl extension is available */
    1.45 +        if( _this->gl_data->HAS_WGL_ARB_context_flush_control ) {
    1.46 +            attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB;
    1.47 +            attribs[iattr++] = _this->gl_config.release_behavior ?
    1.48 +                                    WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB :
    1.49 +                                    WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB;
    1.50 +        }
    1.51 +
    1.52          attribs[iattr++] = 0;
    1.53  
    1.54              /* Create the GL 3.x context */
     2.1 --- a/src/video/windows/SDL_windowsopengl.h	Fri Mar 06 16:03:40 2015 +0000
     2.2 +++ b/src/video/windows/SDL_windowsopengl.h	Fri Mar 20 12:23:53 2015 -0400
     2.3 @@ -30,6 +30,7 @@
     2.4      SDL_bool HAS_WGL_ARB_pixel_format;
     2.5      SDL_bool HAS_WGL_EXT_swap_control_tear;
     2.6      SDL_bool HAS_WGL_EXT_create_context_es2_profile;
     2.7 +    SDL_bool HAS_WGL_ARB_context_flush_control;
     2.8  
     2.9      void *(WINAPI * wglGetProcAddress) (const char *proc);
    2.10        HGLRC(WINAPI * wglCreateContext) (HDC hdc);