X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglws_wgl.cpp;h=cdcb3a2bc07c28df543a381d229aa938ff384332;hb=b4fb7a4628a0c14b8124dbcd1f97749c0276bf81;hp=c6e4a3fb39b1935e3c29a2a806fdcf007250f211;hpb=15a1c736b20b7eb1ad84d7041ff589c8271ccbdb;p=apitrace diff --git a/retrace/glws_wgl.cpp b/retrace/glws_wgl.cpp index c6e4a3f..cdcb3a2 100644 --- a/retrace/glws_wgl.cpp +++ b/retrace/glws_wgl.cpp @@ -100,8 +100,8 @@ public: PIXELFORMATDESCRIPTOR pfd; int iPixelFormat; - WglDrawable(const Visual *vis, int width, int height) : - Drawable(vis, width, height) + WglDrawable(const Visual *vis, int width, int height, bool pbuffer) : + Drawable(vis, width, height, pbuffer) { static bool first = TRUE; RECT rect; @@ -188,14 +188,14 @@ public: return; } + Drawable::resize(w, h); + RECT rClient, rWindow; GetClientRect(hWnd, &rClient); GetWindowRect(hWnd, &rWindow); w += (rWindow.right - rWindow.left) - rClient.right; h += (rWindow.bottom - rWindow.top) - rClient.bottom; SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, w, h, SWP_NOMOVE); - - Drawable::resize(w, h); } void show(void) { @@ -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; + } + }; @@ -275,7 +303,9 @@ cleanup(void) { Visual * createVisual(bool doubleBuffer, Profile profile) { - if (profile != PROFILE_COMPAT) { + if (profile != PROFILE_COMPAT && + profile != PROFILE_CORE && + profile != PROFILE_ES2) { return NULL; } @@ -287,18 +317,31 @@ createVisual(bool doubleBuffer, Profile profile) { } Drawable * -createDrawable(const Visual *visual, int width, int height) +createDrawable(const Visual *visual, int width, int height, bool pbuffer) { - return new WglDrawable(visual, width, height); + return new WglDrawable(visual, width, height, pbuffer); } Context * createContext(const Visual *visual, Context *shareContext, Profile profile, bool debug) { - if (profile != PROFILE_COMPAT) { + if (profile != PROFILE_COMPAT && + profile != PROFILE_CORE && + profile != PROFILE_ES2) { return NULL; } + switch (profile) { + case PROFILE_CORE: + std::cerr << "warning: ignoring OpenGL core profile request\n"; + break; + case PROFILE_ES2: + std::cerr << "warning: ignoring OpenGL ES 2.0 profile request\n"; + break; + default: + break; + } + return new WglContext(visual, profile, static_cast(shareContext)); } @@ -311,22 +354,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); }