From 3b2824de581d6c50df4a2ffa53e46cd13385984b Mon Sep 17 00:00:00 2001 From: clifford Date: Tue, 9 Feb 2010 06:06:37 +0000 Subject: Clifford Wolf: Switched to OpenCSG-1.3.0 for MDI support (this version does not leak GL off screen buffers ;-) git-svn-id: http://svn.clifford.at/openscad/trunk@416 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/README b/README index 9288811..b805226 100644 --- a/README +++ b/README @@ -46,7 +46,7 @@ development. Other versions may or may not work as well.. * cmake (2.6.2, required by CGAL) http://www.cmake.org/ -* OpenCSG (1.1 - 1.2): +* OpenCSG (1.3.0): http://www.opencsg.org/ * GLEW (bundled with OpenCSG) diff --git a/patches/OpenCSG-1.1.0-Reset-Hack.patch b/patches/OpenCSG-1.1.0-Reset-Hack.patch deleted file mode 100644 index 493a11b..0000000 --- a/patches/OpenCSG-1.1.0-Reset-Hack.patch +++ /dev/null @@ -1,82 +0,0 @@ -diff --git a/include/opencsg.h b/include/opencsg.h -index daecacc..ffde239 100644 ---- a/include/opencsg.h -+++ b/include/opencsg.h -@@ -188,6 +188,9 @@ namespace OpenCSG { - Algorithm = AlgorithmUnused, - DepthComplexityAlgorithm = NoDepthComplexitySampling); - -+ // call this function whenever switching the OpenGL context -+ void reset(); -+ - } // namespace OpenCSG - - #endif // __OpenCSG__opencsg_h__ -diff --git a/src/channelManager.h b/src/channelManager.h -index ecd5a1d..0e1458a 100644 ---- a/src/channelManager.h -+++ b/src/channelManager.h -@@ -79,9 +79,9 @@ namespace OpenCSG { - /// moved into alpha, to allow alpha testing of the channel. - static void setupTexEnv(Channel channel); - -- private: -- - static OpenGL::OffscreenBuffer* gOffscreenBuffer; -+ -+ private: - static int gOffscreenType; - static bool gInUse; - -diff --git a/src/offscreenBuffer.cpp b/src/offscreenBuffer.cpp -index e02dd83..4f978d5 100644 ---- a/src/offscreenBuffer.cpp -+++ b/src/offscreenBuffer.cpp -@@ -22,19 +22,41 @@ - #include "offscreenBuffer.h" - #include "frameBufferObject.h" - #include "pBufferTexture.h" -+#include "channelManager.h" -+ -+static bool reset_f = false; -+static bool reset_p = false; - - namespace OpenCSG { - -+ void reset() -+ { -+ reset_f = true; -+ reset_p = true; -+ OpenCSG::ChannelManager::gOffscreenBuffer = NULL; -+ } -+ - namespace OpenGL { - - OffscreenBuffer* getOffscreenBuffer(bool fbo) { -- static FrameBufferObject* f = new FrameBufferObject; -- static PBufferTexture* p = new PBufferTexture; -- -- if (fbo) -- return f; -- else -+ static FrameBufferObject* f = NULL; -+ static PBufferTexture* p = NULL; -+ -+ if (fbo) { -+ if (reset_f || f == NULL) { -+ delete f; -+ f = new FrameBufferObject; -+ reset_f = false; -+ } -+ return f; -+ } else { -+ if (reset_p || p == NULL) { -+ delete p; -+ p = new PBufferTexture; -+ reset_p = false; -+ } - return p; -+ } - } - - } // namespace OpenGL diff --git a/patches/OpenCSG-1.2.0-Reset-Hack.patch b/patches/OpenCSG-1.2.0-Reset-Hack.patch deleted file mode 100644 index 7254ce7..0000000 --- a/patches/OpenCSG-1.2.0-Reset-Hack.patch +++ /dev/null @@ -1,89 +0,0 @@ -diff -ru OpenCSG-1.2.0/include/opencsg.h OpenCSG-1.2.0-reset/include/opencsg.h ---- OpenCSG-1.2.0/include/opencsg.h 2010-01-02 21:04:10.000000000 +0100 -+++ OpenCSG-1.2.0-reset/include/opencsg.h 2010-01-03 00:41:30.000000000 +0100 -@@ -229,6 +229,9 @@ - Algorithm, - DepthComplexityAlgorithm = NoDepthComplexitySampling); - -+ // call this function whenever switching the OpenGL context -+ void reset(); -+ - } // namespace OpenCSG - - #endif // __OpenCSG__opencsg_h__ -Only in OpenCSG-1.2.0-reset/include: opencsg.h~ -diff -ru OpenCSG-1.2.0/src/channelManager.h OpenCSG-1.2.0-reset/src/channelManager.h ---- OpenCSG-1.2.0/src/channelManager.h 2010-01-02 21:03:01.000000000 +0100 -+++ OpenCSG-1.2.0-reset/src/channelManager.h 2010-01-03 00:40:53.000000000 +0100 -@@ -79,9 +79,9 @@ - /// moved into alpha, to allow alpha testing of the channel. - static void setupTexEnv(Channel channel); - -- private: -- - static OpenGL::OffscreenBuffer* gOffscreenBuffer; -+ -+ private: - static int gOffscreenType; - static bool gInUse; - -Only in OpenCSG-1.2.0-reset/src: channelManager.h~ -diff -ru OpenCSG-1.2.0/src/offscreenBuffer.cpp OpenCSG-1.2.0-reset/src/offscreenBuffer.cpp ---- OpenCSG-1.2.0/src/offscreenBuffer.cpp 2010-01-02 21:03:04.000000000 +0100 -+++ OpenCSG-1.2.0-reset/src/offscreenBuffer.cpp 2010-01-03 00:41:28.000000000 +0100 -@@ -24,9 +24,22 @@ - #include "frameBufferObjectExt.h" - #include "pBufferTexture.h" - #include -+#include "channelManager.h" -+ -+static bool reset_fARB = false; -+static bool reset_fEXT = false; -+static bool reset_p = false; - - namespace OpenCSG { - -+ void reset() -+ { -+ reset_fARB = true; -+ reset_fEXT = true; -+ reset_p = true; -+ OpenCSG::ChannelManager::gOffscreenBuffer = NULL; -+ } -+ - namespace OpenGL { - - OffscreenBuffer* getOffscreenBuffer(bool fbo) { -@@ -36,19 +49,28 @@ - - if (fbo) { - if (GLEW_ARB_framebuffer_object) { -- if (!fARB) -+ if (reset_fARB || !fARB) { -+ delete fARB; - fARB = new FrameBufferObject; -+ reset_fARB = false; -+ } - return fARB; - } - else { -- if (!fEXT) -+ if (reset_fEXT || !fEXT) { -+ delete fEXT; - fEXT = new FrameBufferObjectExt; -+ reset_fEXT = false; -+ } - return fEXT; - } - } - else { -- if (!p) -+ if (reset_p || !p) { -+ delete p; - p = new PBufferTexture; -+ reset_p = false; -+ } - return p; - } - } -Only in OpenCSG-1.2.0-reset/src: offscreenBuffer.cpp~ diff --git a/src/GLView.h b/src/GLView.h index dd896fc..7516894 100644 --- a/src/GLView.h +++ b/src/GLView.h @@ -39,6 +39,11 @@ public: double object_trans_z; GLint shaderinfo[11]; +#ifdef ENABLE_OPENCSG + bool opencsg_support; + int opencsg_id; +#endif + private: void (*renderfunc)(void*); void *renderfunc_vp; @@ -51,10 +56,6 @@ private: double w_h_ratio; -#ifdef ENABLE_OPENCSG - bool opencsg_support; -#endif - bool mouse_drag_active; int last_mouse_x; int last_mouse_y; diff --git a/src/glview.cc b/src/glview.cc index dc42a7f..29046e0 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -65,6 +65,8 @@ GLView::GLView(QWidget *parent) : QGLWidget(parent) setMouseTracking(true); #ifdef ENABLE_OPENCSG opencsg_support = true; + static int sId = 0; + opencsg_id = sId++; #endif } diff --git a/src/mainwin.cc b/src/mainwin.cc index 296c417..e9bbdaa 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1323,6 +1323,9 @@ static void renderGLviaOpenCSG(void *vp) glew_initialized = 1; glewInit(); } +#ifdef ENABLE_MDI + OpenCSG::setContext(m->screen->opencsg_id); +#endif if (m->root_chain) { GLint *shaderinfo = m->screen->shaderinfo; if (!shaderinfo[0]) @@ -1335,9 +1338,6 @@ static void renderGLviaOpenCSG(void *vp) renderCSGChainviaOpenCSG(m->highlights_chain, m->viewActionShowEdges->isChecked() ? shaderinfo : NULL, true, false); } } -#ifdef ENABLE_MDI - OpenCSG::reset(); -#endif } /*! -- cgit v0.10.1