X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglws_wgl.cpp;h=878726b87f99853d9c92bff014601c1112577338;hb=cfce638e85aa64f765bfefb7f6a1ccd4a866b6dc;hp=b4fd922fc1412f0180b0d611ee8d00f3f13cb408;hpb=7a5d9692c1072effd87092960333f34e78648bf1;p=apitrace 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); }