summaryrefslogtreecommitdiff
path: root/vcl/opengl/win/gdiimpl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/opengl/win/gdiimpl.cxx')
-rw-r--r--vcl/opengl/win/gdiimpl.cxx20
1 files changed, 17 insertions, 3 deletions
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 41cbda7e7165..58b3178b6c10 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -8,6 +8,7 @@
*/
#include <memory>
+#include <thread>
#include "opengl/win/gdiimpl.hxx"
#include <comphelper/windowserrorstring.hxx>
@@ -75,11 +76,24 @@ void WinOpenGLContext::resetCurrent()
g_bAnyCurrent = false;
}
+thread_local bool bEpoxyDispatchMakeCurrentCalled = false;
+
+void ensureDispatchTable()
+{
+ if (!bEpoxyDispatchMakeCurrentCalled)
+ {
+ epoxy_handle_external_wglMakeCurrent();
+ bEpoxyDispatchMakeCurrentCalled = true;
+ }
+}
+
bool WinOpenGLContext::isCurrent()
{
OpenGLZone aZone;
- return g_bAnyCurrent && m_aGLWin.hRC && wglGetCurrentContext() == m_aGLWin.hRC &&
- wglGetCurrentDC() == m_aGLWin.hDC;
+ if (!g_bAnyCurrent || !m_aGLWin.hRC)
+ return false;
+ ensureDispatchTable();
+ return wglGetCurrentContext() == m_aGLWin.hRC && wglGetCurrentDC() == m_aGLWin.hDC;
}
bool WinOpenGLContext::isAnyCurrent()
@@ -96,7 +110,7 @@ void WinOpenGLContext::makeCurrent()
clearCurrent();
- epoxy_handle_external_wglMakeCurrent();
+ ensureDispatchTable();
if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
{