diff --git a/src/cocoa_window.m b/src/cocoa_window.m index d005ced23..56ad666b5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1061,12 +1061,16 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) // should probably not be done every time any window is shown [NSApp activateIgnoringOtherApps:YES]; + _GLFWwindow* previous = _glfwPlatformGetCurrentContext(); [window->ns.object makeKeyAndOrderFront:nil]; + _glfwPlatformMakeContextCurrent(previous); } void _glfwPlatformUnhideWindow(_GLFWwindow* window) { + _GLFWwindow* previous = _glfwPlatformGetCurrentContext(); [window->ns.object orderFront:nil]; + _glfwPlatformMakeContextCurrent(previous); } void _glfwPlatformHideWindow(_GLFWwindow* window) diff --git a/src/window.c b/src/window.c index c3e7a8180..3acd48c48 100644 --- a/src/window.c +++ b/src/window.c @@ -238,6 +238,9 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, glClear(GL_COLOR_BUFFER_BIT); _glfwPlatformSwapBuffers(window); + // Restore the previously current context (or NULL) + _glfwPlatformMakeContextCurrent(previous); + if (wndconfig.monitor) { int width, height; @@ -259,9 +262,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, } } - // Restore the previously current context (or NULL) - _glfwPlatformMakeContextCurrent(previous); - return (GLFWwindow*) window; }