Check success of MakeCurrent before updating TLS

Fixes #706.
master
Camilla Berglund ago%!(EXTRA string=9 years)
parent bdbad880c4
commit 2826f3d42f
  1. 20
      src/egl_context.c
  2. 18
      src/glx_context.c
  3. 21
      src/wgl_context.c

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

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

@ -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); {
if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
_glfwPlatformSetCurrentContext(window);
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to make context current");
_glfwPlatformSetCurrentContext(NULL);
}
}
else else
wglMakeCurrent(NULL, NULL); {
if (!wglMakeCurrent(NULL, NULL))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to clear current context");
}
_glfwPlatformSetCurrentContext(window); _glfwPlatformSetCurrentContext(NULL);
}
} }
void _glfwPlatformSwapBuffers(_GLFWwindow* window) void _glfwPlatformSwapBuffers(_GLFWwindow* window)

Loading…
Cancel
Save