Windows: support for OpenGL extension WGL_ARB_context_flush_control.

This commit is contained in:
Ryan C. Gordon 2015-03-20 12:23:53 -04:00
parent f5d96416ad
commit 34415c4557
2 changed files with 23 additions and 2 deletions

View File

@ -74,6 +74,13 @@
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif #endif
#ifndef WGL_ARB_context_flush_control
#define WGL_ARB_context_flush_control
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
#endif
typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
HGLRC HGLRC
hShareContext, hShareContext,
@ -405,6 +412,11 @@ WIN_GL_InitExtensions(_THIS)
_this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_TRUE; _this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_TRUE;
} }
/* Check for GLX_ARB_context_flush_control */
if (HasExtension("WGL_ARB_context_flush_control", extensions)) {
_this->gl_data->HAS_WGL_ARB_context_flush_control = SDL_TRUE;
}
_this->gl_data->wglMakeCurrent(hdc, NULL); _this->gl_data->wglMakeCurrent(hdc, NULL);
_this->gl_data->wglDeleteContext(hglrc); _this->gl_data->wglDeleteContext(hglrc);
ReleaseDC(hwnd, hdc); ReleaseDC(hwnd, hdc);
@ -648,8 +660,8 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
SDL_SetError("GL 3.x is not supported"); SDL_SetError("GL 3.x is not supported");
context = temp_context; context = temp_context;
} else { } else {
/* max 8 attributes plus terminator */ /* max 10 attributes plus terminator */
int attribs[9] = { int attribs[11] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version,
WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version, WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version,
0 0
@ -668,6 +680,14 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
attribs[iattr++] = _this->gl_config.flags; attribs[iattr++] = _this->gl_config.flags;
} }
/* only set if wgl extension is available */
if( _this->gl_data->HAS_WGL_ARB_context_flush_control ) {
attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB;
attribs[iattr++] = _this->gl_config.release_behavior ?
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB :
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB;
}
attribs[iattr++] = 0; attribs[iattr++] = 0;
/* Create the GL 3.x context */ /* Create the GL 3.x context */

View File

@ -30,6 +30,7 @@ struct SDL_GLDriverData
SDL_bool HAS_WGL_ARB_pixel_format; SDL_bool HAS_WGL_ARB_pixel_format;
SDL_bool HAS_WGL_EXT_swap_control_tear; SDL_bool HAS_WGL_EXT_swap_control_tear;
SDL_bool HAS_WGL_EXT_create_context_es2_profile; SDL_bool HAS_WGL_EXT_create_context_es2_profile;
SDL_bool HAS_WGL_ARB_context_flush_control;
void *(WINAPI * wglGetProcAddress) (const char *proc); void *(WINAPI * wglGetProcAddress) (const char *proc);
HGLRC(WINAPI * wglCreateContext) (HDC hdc); HGLRC(WINAPI * wglCreateContext) (HDC hdc);