summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OpenCSG-Reset-Hack.patch82
-rw-r--r--mainwin.cc19
-rw-r--r--openscad.cc16
-rw-r--r--openscad.pro5
4 files changed, 114 insertions, 8 deletions
diff --git a/OpenCSG-Reset-Hack.patch b/OpenCSG-Reset-Hack.patch
new file mode 100644
index 0000000..4968707
--- /dev/null
+++ b/OpenCSG-Reset-Hack.patch
@@ -0,0 +1,82 @@
+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/mainwin.cc b/mainwin.cc
index f28e679..08e1ce6 100644
--- a/mainwin.cc
+++ b/mainwin.cc
@@ -240,6 +240,11 @@ MainWindow::MainWindow(const char *filename)
viewModeThrownTogether();
show();
+ // make sure it looks nice..
+ resize(800, 600);
+ s1->setSizes(QList<int>() << 400 << 400);
+ s2->setSizes(QList<int>() << 400 << 200);
+
#ifdef ENABLE_OPENCSG
viewModeOpenCSG();
#else
@@ -520,9 +525,13 @@ fail:
void MainWindow::actionNew()
{
+#if ENABLE_MDI
+ new MainWindow;
+#else
filename = QString();
setWindowTitle("New Document");
editor->setPlainText("");
+#endif
}
void MainWindow::actionOpen()
@@ -531,6 +540,13 @@ void MainWindow::actionOpen()
QString new_filename = QFileDialog::getOpenFileName(this, "Open File", "", "OpenSCAD Designs (*.scad)");
if (!new_filename.isEmpty())
{
+#if ENABLE_MDI
+ if (!editor->toPlainText().isEmpty()) {
+ new MainWindow(new_filename.toAscii().data());
+ current_win = NULL;
+ return;
+ }
+#endif
filename = new_filename;
maybe_change_dir();
setWindowTitle(filename);
@@ -989,6 +1005,9 @@ static void renderGLviaOpenCSG(void *vp)
glew_initialized = 1;
glewInit();
}
+#ifdef ENABLE_MDI
+ OpenCSG::reset();
+#endif
if (m->root_chain) {
GLint *shaderinfo = m->screen->shaderinfo;
if (!shaderinfo[0])
diff --git a/openscad.cc b/openscad.cc
index 8dd7650..fc9efc8 100644
--- a/openscad.cc
+++ b/openscad.cc
@@ -112,8 +112,10 @@ int main(int argc, char **argv)
if (optind < argc)
filename = argv[optind++];
+#ifndef ENABLE_MDI
if (optind != argc)
help(argv[0]);
+#endif
if (stl_output_file || off_output_file)
{
@@ -203,14 +205,14 @@ int main(int argc, char **argv)
if (filename)
m = new MainWindow(filename);
else
- m = new MainWindow();
-
- m->show();
- m->resize(800, 600);
- m->s1->setSizes(QList<int>() << 400 << 400);
- m->s2->setSizes(QList<int>() << 400 << 200);
-
+ m = new MainWindow;
+#ifdef ENABLE_MDI
+ while (optind < argc)
+ new MainWindow(argv[optind++]);
+ app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
+#else
app.connect(m, SIGNAL(destroyed()), &app, SLOT(quit()));
+#endif
rc = app.exec();
}
else
diff --git a/openscad.pro b/openscad.pro
index ee60724..c7ea413 100644
--- a/openscad.pro
+++ b/openscad.pro
@@ -9,6 +9,9 @@ else {
CONFIG += qt debug
TEMPLATE = app
+# MDI needs an OpenCSG library that is compiled with OpenCSG-Reset-Hack.patch applied
+# DEFINES += "ENABLE_MDI=1"
+
DEFINES += "ENABLE_CGAL=1"
LIBS += -lCGAL
@@ -40,7 +43,7 @@ SOURCES += import.cc dxfdata.cc dxftess.cc dxfdim.cc
SOURCES += dxflinextrude.cc dxfrotextrude.cc
QMAKE_CXXFLAGS += -O0
-// QMAKE_CXXFLAGS += -O3 -march=pentium
+# QMAKE_CXXFLAGS += -O3 -march=pentium
QT += opengl
contact: Jan Huwald // Impressum