From 946aab3e87cfd1e7da280cef2de1fb961019f791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 26 Jul 2016 20:47:01 +0200 Subject: [PATCH] Platform: properly restore previous GL context in WindowlessWglApp. Now it is actually possible to create another context and not break the current GL state on Windows. --- src/Magnum/Platform/WindowlessWglApplication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Platform/WindowlessWglApplication.cpp b/src/Magnum/Platform/WindowlessWglApplication.cpp index 8e4be0878..4a0da7fc6 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWglApplication.cpp @@ -64,6 +64,7 @@ WindowlessWglContext::WindowlessWglContext(const Configuration& configuration, C WS_OVERLAPPEDWINDOW, 0, 0, 32, 32, 0, 0, wc.hInstance, 0); /* Get device context */ + const HDC currentDeviceContext = wglGetCurrentDC(); _deviceContext = GetDC(_window); /* Use first provided pixel format */ @@ -177,7 +178,7 @@ WindowlessWglContext::WindowlessWglContext(const Configuration& configuration, C #endif /* Make the previous context active and delete the temporary context */ - if(!wglMakeCurrent(_deviceContext, currentContext)) { + if(!wglMakeCurrent(currentDeviceContext, currentContext)) { Error() << "Platform::WindowlessWglContext: cannot make the previous context current:" << GetLastError(); /* Everything is fucked up, but try to delete the temporary context