Check success of MakeCurrent before updating TLS

Fixes #706.
This commit is contained in:
Camilla Berglund 2016-02-15 15:34:33 +01:00
parent bdbad880c4
commit 2826f3d42f
3 changed files with 54 additions and 15 deletions

View File

@ -583,17 +583,29 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{ {
if (window) if (window)
{ {
eglMakeCurrent(_glfw.egl.display, if (!eglMakeCurrent(_glfw.egl.display,
window->context.egl.surface, window->context.egl.surface,
window->context.egl.surface, window->context.egl.surface,
window->context.egl.handle); window->context.egl.handle))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to make context current: %s",
getErrorString(eglGetError()));
return;
}
} }
else else
{ {
eglMakeCurrent(_glfw.egl.display, if (!eglMakeCurrent(_glfw.egl.display,
EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT); EGL_NO_CONTEXT))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to clear current context: %s",
getErrorString(eglGetError()));
return;
}
} }
_glfwPlatformSetCurrentContext(window); _glfwPlatformSetCurrentContext(window);

View File

@ -545,12 +545,24 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{ {
if (window) if (window)
{ {
glXMakeCurrent(_glfw.x11.display, if (!glXMakeCurrent(_glfw.x11.display,
window->context.glx.window, window->context.glx.window,
window->context.glx.handle); window->context.glx.handle))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to make context current");
return;
}
} }
else else
glXMakeCurrent(_glfw.x11.display, None, NULL); {
if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to clear current context");
return;
}
}
_glfwPlatformSetCurrentContext(window); _glfwPlatformSetCurrentContext(window);
} }

View File

@ -594,11 +594,26 @@ int _glfwAnalyzeContextWGL(_GLFWwindow* window,
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window) void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{ {
if (window) if (window)
wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle); {
else if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
wglMakeCurrent(NULL, NULL);
_glfwPlatformSetCurrentContext(window); _glfwPlatformSetCurrentContext(window);
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to make context current");
_glfwPlatformSetCurrentContext(NULL);
}
}
else
{
if (!wglMakeCurrent(NULL, NULL))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to clear current context");
}
_glfwPlatformSetCurrentContext(NULL);
}
} }
void _glfwPlatformSwapBuffers(_GLFWwindow* window) void _glfwPlatformSwapBuffers(_GLFWwindow* window)