From d3a6f1508e3ab0f8ce16f29f55b6d4019372ef98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 20 May 2011 23:54:13 +0100 Subject: [PATCH] Don't show windows until they are first resized. --- glretrace.py | 3 +++ glws.hpp | 9 ++++++++- glws_glx.cpp | 13 ++++++++++--- glws_wgl.cpp | 10 +++++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/glretrace.py b/glretrace.py index b497b44..979e0e1 100644 --- a/glretrace.py +++ b/glretrace.py @@ -142,6 +142,9 @@ class GlRetracer(Retracer): print ' if (drawable_width > (int)glretrace::drawable->width ||' print ' drawable_height > (int)glretrace::drawable->height) {' print ' glretrace::drawable->resize(drawable_width, drawable_height);' + print ' if (!glretrace::drawable->visible) {' + print ' glretrace::drawable->show();' + print ' }' print ' glScissor(0, 0, drawable_width, drawable_height);' print ' }' print ' }' diff --git a/glws.hpp b/glws.hpp index 3d3c83d..0565420 100644 --- a/glws.hpp +++ b/glws.hpp @@ -53,11 +53,13 @@ public: const Visual *visual; int width; int height; + bool visible; Drawable(const Visual *vis, int w, int h) : visual(vis), width(w), - height(h) + height(h), + visible(false) {} virtual ~Drawable() {} @@ -68,6 +70,11 @@ public: height = h; } + virtual void + show(void) { + visible = true; + } + virtual void swapBuffers(void) = 0; }; diff --git a/glws_glx.cpp b/glws_glx.cpp index 564af90..30de2f4 100644 --- a/glws_glx.cpp +++ b/glws_glx.cpp @@ -138,9 +138,6 @@ public: display, window, name, name, None, (char **)NULL, 0, &sizehints); - XMapWindow(display, window); - - waitForEvent(window, Expose); glXWaitX(); } @@ -175,6 +172,16 @@ public: glXWaitX(); } + void show(void) { + if (!visible) { + XMapWindow(display, window); + + waitForEvent(window, Expose); + + Drawable::show(); + } + } + void swapBuffers(void) { glXSwapBuffers(display, window); } diff --git a/glws_wgl.cpp b/glws_wgl.cpp index 94390da..9e8f1e0 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; @@ -145,6 +145,14 @@ public: 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) { SwapBuffers(hDC); } -- 2.7.4