X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=glws_wgl.cpp;h=9e8f1e036432a81298b135004c835e790a1e773f;hb=00e0021870c9bbba51376aa32554183e1c7859ba;hp=3ac2a6d0b3905095e828b7d8dd2cf3c52c1e9c25;hpb=49d29a97b15e651ba1f645888f8e7b81fc9071bf;p=apitrace diff --git a/glws_wgl.cpp b/glws_wgl.cpp index 3ac2a6d..9e8f1e0 100644 --- a/glws_wgl.cpp +++ b/glws_wgl.cpp @@ -30,6 +30,27 @@ namespace glws { +static LRESULT CALLBACK +WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + MINMAXINFO *pMMI; + switch (uMsg) { + case WM_GETMINMAXINFO: + // Allow to create a window bigger than the desktop + pMMI = (MINMAXINFO *)lParam; + pMMI->ptMaxSize.x = 60000; + pMMI->ptMaxSize.y = 60000; + pMMI->ptMaxTrackSize.x = 60000; + pMMI->ptMaxTrackSize.y = 60000; + break; + default: + break; + } + + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} + + class WglDrawable : public Drawable { public: @@ -40,8 +61,8 @@ public: PIXELFORMATDESCRIPTOR pfd; int iPixelFormat; - WglDrawable(const Visual *vis) : - Drawable(vis) + WglDrawable(const Visual *vis, int width, int height) : + Drawable(vis, width, height) { static bool first = TRUE; RECT rect; @@ -52,7 +73,7 @@ public: wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.lpfnWndProc = DefWindowProc; + wc.lpfnWndProc = WndProc; wc.lpszClassName = "glretrace"; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); @@ -60,9 +81,9 @@ public: } dwExStyle = 0; - dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_OVERLAPPEDWINDOW; + dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW; - int x = 0, y = 0, width = 256, height = 256; + int x = 0, y = 0; rect.left = x; rect.top = y; @@ -75,8 +96,8 @@ public: "glretrace", /* wc.lpszClassName */ NULL, dwStyle, - CW_USEDEFAULT, /* x */ - CW_USEDEFAULT, /* y */ + 0, /* x */ + 0, /* y */ rect.right - rect.left, /* width */ rect.bottom - rect.top, /* height */ NULL, @@ -86,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; @@ -113,14 +135,22 @@ public: } void - resize(unsigned w, unsigned h) { + resize(int w, int h) { 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; - MoveWindow(hWnd, rWindow.left, rWindow.top, w, h, TRUE); + SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, w, h, SWP_NOMOVE); + } + + void show(void) { + if (!visible) { + ShowWindow(hWnd, SW_SHOW); + + Drawable::show(); + } } void swapBuffers(void) { @@ -133,10 +163,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() { @@ -160,15 +192,15 @@ public: } Drawable * - createDrawable(const Visual *visual) + createDrawable(const Visual *visual, int width, int height) { - return new WglDrawable(visual); + return new WglDrawable(visual, width, height); } Context * - createContext(const Visual *visual) + createContext(const Visual *visual, Context *shareContext) { - return new WglContext(visual); + return new WglContext(visual, dynamic_cast(shareContext)); } bool @@ -185,6 +217,10 @@ public: if (!wglContext->hglrc) { return false; } + if (wglContext->shareContext) { + wglShareLists(wglContext->shareContext->hglrc, + wglContext->hglrc); + } } return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc);