From 52f76844877d3e6f976db31923c07fb2c24c77a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Jun 2017 15:20:24 +0200 Subject: [PATCH] WGL: Add WGL_ARB_create_context_no_error support --- README.md | 1 + src/wgl_context.c | 17 +++++++++++++++-- src/wgl_context.h | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 516c913b..3058a40a 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Full screen framebuffer was incorrectly sized for some video modes (#682) - [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts +- [WGL] Added support for `WGL_ARB_create_context_no_error` - [EGL] Added support for `EGL_KHR_get_all_proc_addresses` (#871) - [EGL] Added support for `EGL_KHR_context_flush_control` - [EGL] Bugfix: The test for `EGL_RGB_BUFFER` was invalid diff --git a/src/wgl_context.c b/src/wgl_context.c index fc1b3970..92bd70e6 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -418,6 +418,8 @@ static void loadWGLExtensions(void) extensionSupportedWGL("WGL_EXT_create_context_es2_profile"); _glfw.wgl.ARB_create_context_robustness = extensionSupportedWGL("WGL_ARB_create_context_robustness"); + _glfw.wgl.ARB_create_context_no_error = + extensionSupportedWGL("WGL_ARB_create_context_no_error"); _glfw.wgl.EXT_swap_control = extensionSupportedWGL("WGL_EXT_swap_control"); _glfw.wgl.EXT_colorspace = @@ -579,8 +581,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, if (ctxconfig->debug) flags |= WGL_CONTEXT_DEBUG_BIT_ARB; - if (ctxconfig->noerror) - flags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR; if (ctxconfig->robustness) { @@ -618,6 +618,14 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, } } + if (ctxconfig->noerror) + { + if (_glfw.wgl.ARB_create_context_no_error) + { + setWGLattrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); + } + } + // NOTE: Only request an explicitly versioned context when necessary, as // explicitly requesting version 1.0 does not always return the // highest version supported by the driver @@ -664,6 +672,11 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, _glfwInputError(GLFW_VERSION_UNAVAILABLE, "WGL: Driver does not support the requested OpenGL profile"); } + else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB)) + { + _glfwInputError(GLFW_INVALID_VALUE, + "WGL: The share context is not compatible with the requested context"); + } else { if (ctxconfig->client == GLFW_OPENGL_API) diff --git a/src/wgl_context.h b/src/wgl_context.h index e02cc0ec..9fae9114 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -68,11 +68,13 @@ #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3 #define WGL_COLORSPACE_EXT 0x309d #define WGL_COLORSPACE_SRGB_EXT 0x3089 #define ERROR_INVALID_VERSION_ARB 0x2095 #define ERROR_INVALID_PROFILE_ARB 0x2096 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); @@ -142,6 +144,7 @@ typedef struct _GLFWlibraryWGL GLFWbool ARB_create_context_profile; GLFWbool EXT_create_context_es2_profile; GLFWbool ARB_create_context_robustness; + GLFWbool ARB_create_context_no_error; GLFWbool ARB_context_flush_control; } _GLFWlibraryWGL;