mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-27 04:28:52 -05:00
Added X error text to context creation failure.
This commit is contained in:
parent
b1ff42b7bb
commit
2ece101f0e
|
@ -67,8 +67,7 @@ static _GLFW_TLS _GLFWwindow* _glfwCurrentWindow = NULL;
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Error handler used when creating a context with the GLX_ARB_create_context
|
// Error handler used when creating a context
|
||||||
// extension set
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static int errorHandler(Display *display, XErrorEvent* event)
|
static int errorHandler(Display *display, XErrorEvent* event)
|
||||||
|
@ -411,6 +410,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_glfwErrorCode = Success;
|
||||||
|
XSetErrorHandler(errorHandler);
|
||||||
|
|
||||||
if (_glfw.glx.ARB_create_context)
|
if (_glfw.glx.ARB_create_context)
|
||||||
{
|
{
|
||||||
int index = 0, mask = 0, flags = 0, strategy = 0;
|
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||||
|
@ -468,13 +470,6 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||||
|
|
||||||
setGLXattrib(None, None);
|
setGLXattrib(None, None);
|
||||||
|
|
||||||
// This is the only place we set an Xlib error handler, and we only do
|
|
||||||
// it because glXCreateContextAttribsARB generates a BadMatch error if
|
|
||||||
// the requested OpenGL version is unavailable (instead of a civilized
|
|
||||||
// response like returning NULL)
|
|
||||||
_glfwErrorCode = Success;
|
|
||||||
XSetErrorHandler(errorHandler);
|
|
||||||
|
|
||||||
window->glx.context =
|
window->glx.context =
|
||||||
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
|
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
|
||||||
*native,
|
*native,
|
||||||
|
@ -482,9 +477,6 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||||
True,
|
True,
|
||||||
attribs);
|
attribs);
|
||||||
|
|
||||||
// We are done, so unset the error handler again (see above)
|
|
||||||
XSetErrorHandler(NULL);
|
|
||||||
|
|
||||||
if (window->glx.context == NULL)
|
if (window->glx.context == NULL)
|
||||||
{
|
{
|
||||||
// HACK: This is a fallback for the broken Mesa implementation of
|
// HACK: This is a fallback for the broken Mesa implementation of
|
||||||
|
@ -502,11 +494,21 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||||
else
|
else
|
||||||
window->glx.context = createLegacyContext(window, *native, share);
|
window->glx.context = createLegacyContext(window, *native, share);
|
||||||
|
|
||||||
|
XSetErrorHandler(NULL);
|
||||||
|
|
||||||
XFree(native);
|
XFree(native);
|
||||||
|
|
||||||
if (window->glx.context == NULL)
|
if (window->glx.context == NULL)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
|
char buffer[8192];
|
||||||
|
XGetErrorText(_glfw.x11.display,
|
||||||
|
_glfwErrorCode,
|
||||||
|
buffer, sizeof(buffer));
|
||||||
|
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"GLX: Failed to create context: %s",
|
||||||
|
buffer);
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user