Made context creation backends more consistent.

This commit is contained in:
Camilla Berglund 2014-08-20 20:12:59 +02:00
parent 77d2a2131d
commit cfc47abf0d
4 changed files with 15 additions and 19 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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); }

View File

@ -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);
}