Commit cfc47abf authored by Camilla Berglund's avatar Camilla Berglund
Browse files

Made context creation backends more consistent.

parent 77d2a213
......@@ -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;
......
......@@ -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;
......
......@@ -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); }
......
......@@ -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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment