From cfce638e85aa64f765bfefb7f6a1ccd4a866b6dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 23 Oct 2012 20:16:04 +0100 Subject: [PATCH] Fix creation of shared WGL contexts. --- retrace/glws_wgl.cpp | 45 ++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/retrace/glws_wgl.cpp b/retrace/glws_wgl.cpp index b4fd922..878726b 100644 --- a/retrace/glws_wgl.cpp +++ b/retrace/glws_wgl.cpp @@ -243,6 +243,34 @@ public: wglDeleteContext(hglrc); } } + + bool + create(WglDrawable *wglDrawable) { + if (!hglrc) { + hglrc = wglCreateContext(wglDrawable->hDC); + if (!hglrc) { + std::cerr << "error: wglCreateContext failed\n"; + exit(1); + return false; + } + if (shareContext) { + if (shareContext->create(wglDrawable)) { + BOOL bRet; + bRet = wglShareLists(shareContext->hglrc, + hglrc); + if (!bRet) { + std::cerr + << "warning: wglShareLists failed: " + << std::hex << GetLastError() << std::dec + << "\n"; + } + } + } + } + + return true; + } + }; @@ -311,22 +339,7 @@ makeCurrent(Drawable *drawable, Context *context) WglDrawable *wglDrawable = static_cast(drawable); WglContext *wglContext = static_cast(context); - if (!wglContext->hglrc) { - wglContext->hglrc = wglCreateContext(wglDrawable->hDC); - if (!wglContext->hglrc) { - std::cerr << "error: wglCreateContext failed\n"; - exit(1); - return false; - } - if (wglContext->shareContext) { - BOOL bRet; - bRet = wglShareLists(wglContext->shareContext->hglrc, - wglContext->hglrc); - if (!bRet) { - std::cerr << "warning: wglShareLists failed\n"; - } - } - } + wglContext->create(wglDrawable); return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc); } -- 2.43.0