mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Made context creation backends more consistent.
This commit is contained in:
parent
77d2a2131d
commit
cfc47abf0d
@ -236,7 +236,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
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,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
@ -296,8 +296,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
|
|
||||||
window->egl.visual = XGetVisualInfo(_glfw.x11.display,
|
window->egl.visual = XGetVisualInfo(_glfw.x11.display,
|
||||||
mask, &info, &count);
|
mask, &info, &count);
|
||||||
|
if (!window->egl.visual)
|
||||||
if (window->egl.visual == NULL)
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"EGL: Failed to retrieve visual for EGLConfig");
|
"EGL: Failed to retrieve visual for EGLConfig");
|
||||||
@ -345,7 +344,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig->robustness != GLFW_NO_ROBUSTNESS)
|
if (ctxconfig->robustness)
|
||||||
{
|
{
|
||||||
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
strategy = EGL_NO_RESET_NOTIFICATION_KHR;
|
strategy = EGL_NO_RESET_NOTIFICATION_KHR;
|
||||||
|
@ -281,7 +281,7 @@ void _glfwTerminateContextAPI(void)
|
|||||||
assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
|
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,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
@ -303,8 +303,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
|
|
||||||
// Retrieve the corresponding visual
|
// Retrieve the corresponding visual
|
||||||
window->glx.visual = glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
window->glx.visual = glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
||||||
|
if (!window->glx.visual)
|
||||||
if (window->glx.visual == NULL)
|
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"GLX: Failed to retrieve visual for GLXFBConfig");
|
"GLX: Failed to retrieve visual for GLXFBConfig");
|
||||||
@ -372,7 +371,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
else
|
else
|
||||||
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||||
|
|
||||||
if (ctxconfig->robustness != GLFW_NO_ROBUSTNESS)
|
if (ctxconfig->robustness)
|
||||||
{
|
{
|
||||||
if (_glfw.glx.ARB_create_context_robustness)
|
if (_glfw.glx.ARB_create_context_robustness)
|
||||||
{
|
{
|
||||||
@ -413,7 +412,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
True,
|
True,
|
||||||
attribs);
|
attribs);
|
||||||
|
|
||||||
if (window->glx.context == NULL)
|
if (!window->glx.context)
|
||||||
{
|
{
|
||||||
// HACK: This is a fallback for the broken Mesa implementation of
|
// HACK: This is a fallback for the broken Mesa implementation of
|
||||||
// GLX_ARB_create_context_profile, which fails default 1.0
|
// GLX_ARB_create_context_profile, which fails default 1.0
|
||||||
@ -433,7 +432,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
|
|
||||||
_glfwReleaseXErrorHandler();
|
_glfwReleaseXErrorHandler();
|
||||||
|
|
||||||
if (window->glx.context == NULL)
|
if (!window->glx.context)
|
||||||
{
|
{
|
||||||
_glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
|
_glfwInputXError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
@ -112,14 +112,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
// Fail if a robustness strategy was requested
|
// Context robustness modes (GL_KHR_robustness) are not yet supported on
|
||||||
if (ctxconfig->robustness)
|
// OS X but are not a hard constraint, so ignore and continue
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
|
||||||
"NSGL: OS X does not support OpenGL robustness "
|
|
||||||
"strategies");
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
|
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
|
||||||
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
#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])); \
|
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,
|
int _glfwCreateContext(_GLFWwindow* window,
|
||||||
const _GLFWctxconfig* ctxconfig,
|
const _GLFWctxconfig* ctxconfig,
|
||||||
@ -423,6 +423,10 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
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_MAJOR_VERSION_ARB, ctxconfig->major);
|
||||||
setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user