]> git.cworth.org Git - apitrace/blobdiff - glws_wgl.cpp
Add a top-level apitrace program.
[apitrace] / glws_wgl.cpp
index 94390da221f3b8b13eed1d74622da2d09cedb06d..1958b5fc22a193aa8f64cc116231631806768be9 100644 (file)
@@ -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;
 
@@ -136,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) {
@@ -171,65 +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, Context *shareContext)
-    {
-        return new WglContext(visual, dynamic_cast<WglContext *>(shareContext));
-    }
+    visual->doubleBuffer = doubleBuffer;
 
-    bool
-    makeCurrent(Drawable *drawable, Context *context)
-    {
-        if (!drawable || !context) {
-            return wglMakeCurrent(NULL, NULL);
-        } else {
-            WglDrawable *wglDrawable = dynamic_cast<WglDrawable *>(drawable);
-            WglContext *wglContext = dynamic_cast<WglContext *>(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<WglContext *>(shareContext));
+}
+
+bool
+makeCurrent(Drawable *drawable, Context *context)
+{
+    if (!drawable || !context) {
+        return wglMakeCurrent(NULL, NULL);
+    } else {
+        WglDrawable *wglDrawable = dynamic_cast<WglDrawable *>(drawable);
+        WglContext *wglContext = dynamic_cast<WglContext *>(context);
+
+        if (!wglContext->hglrc) {
+            wglContext->hglrc = wglCreateContext(wglDrawable->hDC);
             if (!wglContext->hglrc) {
-                wglContext->hglrc = wglCreateContext(wglDrawable->hDC);
-                if (!wglContext->hglrc) {
-                    return false;
-                }
-                if (wglContext->shareContext) {
-                    wglShareLists(wglContext->shareContext->hglrc,
-                                  wglContext->hglrc);
-                }
+                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 */