X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glws_wgl.cpp;h=1958b5fc22a193aa8f64cc116231631806768be9;hb=33b8ba3bd173bcb6cebbc0d2e1ed3320077a8ac3;hp=b1e274b5f9314f27e2394f1ea362b70f0a4d3cb9;hpb=7497c130f98f33f41437678835f4b2eb2abce750;p=apitrace diff --git a/glws_wgl.cpp b/glws_wgl.cpp index b1e274b..1958b5f 100644 --- a/glws_wgl.cpp +++ b/glws_wgl.cpp @@ -81,7 +81,7 @@ public: } dwExStyle = 0; - dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_OVERLAPPEDWINDOW; + dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW; int x = 0, y = 0; @@ -107,10 +107,11 @@ public: hDC = GetDC(hWnd); memset(&pfd, 0, sizeof pfd); - pfd.cColorBits = 3; + pfd.cColorBits = 4; pfd.cRedBits = 1; pfd.cGreenBits = 1; pfd.cBlueBits = 1; + pfd.cAlphaBits = 1; pfd.cDepthBits = 1; pfd.cStencilBits = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; @@ -135,13 +136,28 @@ public: void resize(int w, int h) { - Drawable::resize(w, h); + if (w == width && h == height) { + return; + } + 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) { + if (visible) { + return; + } + + ShowWindow(hWnd, SW_SHOW); + + Drawable::show(); } void swapBuffers(void) { @@ -154,10 +170,12 @@ class WglContext : public Context { public: HGLRC hglrc; - - WglContext(const Visual *vis) : + WglContext *shareContext; + + WglContext(const Visual *vis, WglContext *share) : Context(vis), - hglrc(0) + hglrc(0), + shareContext(share) {} ~WglContext() { @@ -168,61 +186,64 @@ public: }; -class WglWindowSystem : public WindowSystem -{ -public: - Visual * - createVisual(bool doubleBuffer) { - Visual *visual = new Visual(); +void +init(void) { +} - visual->doubleBuffer = doubleBuffer; +void +cleanup(void) { +} - return visual; - } - - Drawable * - createDrawable(const Visual *visual, int width, int height) - { - return new WglDrawable(visual, width, height); - } +Visual * +createVisual(bool doubleBuffer) { + Visual *visual = new Visual(); - Context * - createContext(const Visual *visual) - { - return new WglContext(visual); - } + visual->doubleBuffer = doubleBuffer; - bool - makeCurrent(Drawable *drawable, Context *context) - { - if (!drawable || !context) { - return wglMakeCurrent(NULL, NULL); - } else { - WglDrawable *wglDrawable = dynamic_cast(drawable); - WglContext *wglContext = dynamic_cast(context); + return visual; +} + +Drawable * +createDrawable(const Visual *visual, int width, int height) +{ + return new WglDrawable(visual, width, height); +} + +Context * +createContext(const Visual *visual, Context *shareContext) +{ + return new WglContext(visual, dynamic_cast(shareContext)); +} +bool +makeCurrent(Drawable *drawable, Context *context) +{ + if (!drawable || !context) { + return wglMakeCurrent(NULL, NULL); + } else { + WglDrawable *wglDrawable = dynamic_cast(drawable); + WglContext *wglContext = dynamic_cast(context); + + if (!wglContext->hglrc) { + wglContext->hglrc = wglCreateContext(wglDrawable->hDC); if (!wglContext->hglrc) { - wglContext->hglrc = wglCreateContext(wglDrawable->hDC); - if (!wglContext->hglrc) { - return false; - } + return false; + } + if (wglContext->shareContext) { + wglShareLists(wglContext->shareContext->hglrc, + wglContext->hglrc); } - - return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc); } - } - bool - processEvents(void) { - // TODO - return true; + return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc); } -}; - +} -WindowSystem *createNativeWindowSystem(void) { - return new WglWindowSystem(); +bool +processEvents(void) { + // TODO + return true; } -} /* namespace glretrace */ +} /* namespace glws */