diff --git a/src/egl_context.c b/src/egl_context.c index 7f61e250..a0d77765 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -236,7 +236,7 @@ void _glfwTerminateContextAPI(void) assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \ } -// Prepare for creation of the OpenGL context +// Create the OpenGL or OpenGL ES context // int _glfwCreateContext(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, @@ -296,8 +296,7 @@ int _glfwCreateContext(_GLFWwindow* window, window->egl.visual = XGetVisualInfo(_glfw.x11.display, mask, &info, &count); - - if (window->egl.visual == NULL) + if (!window->egl.visual) { _glfwInputError(GLFW_PLATFORM_ERROR, "EGL: Failed to retrieve visual for EGLConfig"); @@ -345,7 +344,7 @@ int _glfwCreateContext(_GLFWwindow* window, flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR; } - if (ctxconfig->robustness != GLFW_NO_ROBUSTNESS) + if (ctxconfig->robustness) { if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION) strategy = EGL_NO_RESET_NOTIFICATION_KHR; diff --git a/src/glx_context.c b/src/glx_context.c index 15e300be..2e33c369 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -281,7 +281,7 @@ void _glfwTerminateContextAPI(void) assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \ } -// Prepare for creation of the OpenGL context +// Create the OpenGL or OpenGL ES context // int _glfwCreateContext(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, @@ -303,8 +303,7 @@ int _glfwCreateContext(_GLFWwindow* window, // Retrieve the corresponding visual window->glx.visual = glXGetVisualFromFBConfig(_glfw.x11.display, native); - - if (window->glx.visual == NULL) + if (!window->glx.visual) { _glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to retrieve visual for GLXFBConfig"); @@ -372,7 +371,7 @@ int _glfwCreateContext(_GLFWwindow* window, else mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT; - if (ctxconfig->robustness != GLFW_NO_ROBUSTNESS) + if (ctxconfig->robustness) { if (_glfw.glx.ARB_create_context_robustness) { @@ -413,7 +412,7 @@ int _glfwCreateContext(_GLFWwindow* window, True, attribs); - if (window->glx.context == NULL) + if (!window->glx.context) { // HACK: This is a fallback for the broken Mesa implementation of // GLX_ARB_create_context_profile, which fails default 1.0 @@ -433,7 +432,7 @@ int _glfwCreateContext(_GLFWwindow* window, _glfwReleaseXErrorHandler(); - if (window->glx.context == NULL) + if (!window->glx.context) { _glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context"); return GL_FALSE; diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 5401f913..faf6676d 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -112,14 +112,8 @@ int _glfwCreateContext(_GLFWwindow* window, } #endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ - // Fail if a robustness strategy was requested - if (ctxconfig->robustness) - { - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "NSGL: OS X does not support OpenGL robustness " - "strategies"); - return GL_FALSE; - } + // Context robustness modes (GL_KHR_robustness) are not yet supported on + // OS X but are not a hard constraint, so ignore and continue #define ADD_ATTR(x) { attributes[attributeCount++] = x; } #define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); } diff --git a/src/wgl_context.c b/src/wgl_context.c index 9a47e417..792cca12 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -345,7 +345,7 @@ void _glfwTerminateContextAPI(void) assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \ } -// Prepare for creation of the OpenGL context +// Create the OpenGL or OpenGL ES context // int _glfwCreateContext(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, @@ -423,6 +423,10 @@ int _glfwCreateContext(_GLFWwindow* window, if (ctxconfig->major != 1 || ctxconfig->minor != 0) { + // NOTE: Only request an explicitly versioned context when + // necessary, as explicitly requesting version 1.0 does not + // always return the highest available version + setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major); setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor); }