summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-12-09 02:43:06 (GMT)
committerMarius Kintel <marius@kintel.net>2011-12-09 02:43:06 (GMT)
commitf577f91d25071f5ad1a9fdb6ed7c6dd3aa4c1008 (patch)
treecfc834302cc03e520127014faa59d5ecf58d7a06 /src
parentcc4f6ac1846882adbc5214157e1d7b5a1994a9db (diff)
Better warnings and GL info related to OpenCSG capabilities and OpenGL 1.x
Diffstat (limited to 'src')
-rw-r--r--src/GLView.h5
-rw-r--r--src/MainWindow.h3
-rw-r--r--src/MainWindow.ui6
-rw-r--r--src/OpenCSGWarningDialog.cc23
-rw-r--r--src/OpenCSGWarningDialog.h16
-rw-r--r--src/OpenCSGWarningDialog.ui93
-rw-r--r--src/Preferences.cc17
-rw-r--r--src/Preferences.h1
-rw-r--r--src/Preferences.ui18
-rw-r--r--src/glview.cc100
-rw-r--r--src/mainwin.cc14
11 files changed, 235 insertions, 61 deletions
diff --git a/src/GLView.h b/src/GLView.h
index c31e7af..5552e4b 100644
--- a/src/GLView.h
+++ b/src/GLView.h
@@ -32,7 +32,8 @@ public:
void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; }
bool orthoMode() const { return this->orthomode; }
void setOrthoMode(bool enabled) { this->orthomode = enabled; }
-
+ const QString &getRendererInfo() const { return this->rendererInfo; }
+
public:
QLabel *statusLabel;
double object_rot_x;
@@ -52,6 +53,8 @@ private:
void init();
Renderer *renderer;
+ QString rendererInfo;
+
bool showfaces;
bool showedges;
bool showaxes;
diff --git a/src/MainWindow.h b/src/MainWindow.h
index b2d0f60..0f2a922 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -86,6 +86,8 @@ private:
void loadViewSettings();
void loadDesignSettings();
+ class QMessageBox *openglbox;
+
private slots:
void actionNew();
void actionOpen();
@@ -156,6 +158,7 @@ public slots:
void helpAbout();
void helpHomepage();
void helpManual();
+ void helpOpenGL();
void quit();
void actionReloadCompile();
void checkAutoReload();
diff --git a/src/MainWindow.ui b/src/MainWindow.ui
index dc73c05..d1bdb00 100644
--- a/src/MainWindow.ui
+++ b/src/MainWindow.ui
@@ -218,6 +218,7 @@
<addaction name="helpActionAbout"/>
<addaction name="helpActionHomepage"/>
<addaction name="helpActionManual"/>
+ <addaction name="helpActionOpenGLInfo"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Edit"/>
@@ -666,6 +667,11 @@
<string>Export as CSG...</string>
</property>
</action>
+ <action name="helpActionOpenGLInfo">
+ <property name="text">
+ <string>OpenGL info</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
diff --git a/src/OpenCSGWarningDialog.cc b/src/OpenCSGWarningDialog.cc
new file mode 100644
index 0000000..fdaaa50
--- /dev/null
+++ b/src/OpenCSGWarningDialog.cc
@@ -0,0 +1,23 @@
+#include "OpenCSGWarningDialog.h"
+#include "Preferences.h"
+
+OpenCSGWarningDialog::OpenCSGWarningDialog(QWidget *parent)
+{
+ setupUi(this);
+
+ connect(this->showBox, SIGNAL(toggled(bool)),
+ Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool)));
+ connect(this->showBox, SIGNAL(toggled(bool)),
+ Preferences::inst(), SLOT(openCSGWarningChanged(bool)));
+
+ connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)),
+ Preferences::inst()->enableOpenCSGBox, SLOT(setChecked(bool)));
+ connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)),
+ Preferences::inst(), SLOT(enableOpenCSGChanged(bool)));
+}
+
+void OpenCSGWarningDialog::setText(const QString &text)
+{
+ this->warningText->setPlainText(text);
+}
+
diff --git a/src/OpenCSGWarningDialog.h b/src/OpenCSGWarningDialog.h
new file mode 100644
index 0000000..5d9c8fa
--- /dev/null
+++ b/src/OpenCSGWarningDialog.h
@@ -0,0 +1,16 @@
+#ifndef OPENCSGWARNINGDIALOG_H_
+#define OPENCSGWARNINGDIALOG_H_
+
+#include "ui_OpenCSGWarningDialog.h"
+
+class OpenCSGWarningDialog : public QDialog, public Ui::OpenCSGWarningDialog
+{
+ Q_OBJECT;
+public:
+ OpenCSGWarningDialog(QWidget *parent);
+
+public slots:
+ void setText(const QString &text);
+};
+
+#endif
diff --git a/src/OpenCSGWarningDialog.ui b/src/OpenCSGWarningDialog.ui
new file mode 100644
index 0000000..f902521
--- /dev/null
+++ b/src/OpenCSGWarningDialog.ui
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>OpenCSGWarningDialog</class>
+ <widget class="QDialog" name="OpenCSGWarningDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>412</width>
+ <height>275</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>OpenGL Warning</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextEdit" name="warningText">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="html">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enableOpenCSGBox">
+ <property name="text">
+ <string>Enable OpenCSG</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="showBox">
+ <property name="text">
+ <string>Show this message again</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>closeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>OpenCSGWarningDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>361</x>
+ <y>246</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>205</x>
+ <y>137</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/Preferences.cc b/src/Preferences.cc
index d240a9f..577ed4a 100644
--- a/src/Preferences.cc
+++ b/src/Preferences.cc
@@ -40,7 +40,8 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text();
this->defaultmap["editor/fontfamily"] = this->fontChooser->currentText();
this->defaultmap["editor/fontsize"] = this->fontSize->currentText().toUInt();
- this->defaultmap["editor/opengl20_warning_show"] = true;
+ this->defaultmap["advanced/opencsg_show_warning"] = true;
+ this->defaultmap["advanced/enable_opencsg_opengl1x"] = false;
// Toolbar
QActionGroup *group = new QActionGroup(this);
@@ -98,7 +99,7 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
this, SLOT(fontFamilyChanged(const QString &)));
connect(this->fontSize, SIGNAL(editTextChanged(const QString &)),
this, SLOT(fontSizeChanged(const QString &)));
- connect(this->openCSGWarningBox, SIGNAL(clicked(bool)),
+ connect(this->openCSGWarningBox, SIGNAL(toggled(bool)),
this, SLOT(openCSGWarningChanged(bool)));
updateGUI();
}
@@ -154,7 +155,14 @@ void
Preferences::openCSGWarningChanged(bool state)
{
QSettings settings;
- settings.setValue("editor/opengl20_warning_show",state);
+ settings.setValue("advanced/opencsg_show_warning",state);
+}
+
+void
+Preferences::enableOpenCSGChanged(bool state)
+{
+ QSettings settings;
+ settings.setValue("advanced/enable_opencsg_opengl1x", state);
}
void Preferences::keyPressEvent(QKeyEvent *e)
@@ -215,7 +223,8 @@ void Preferences::updateGUI()
this->fontSize->setEditText(fontsize);
}
- this->openCSGWarningBox->setChecked(getValue("editor/opengl20_warning_show").toBool());
+ this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool());
+ this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool());
}
void Preferences::apply() const
diff --git a/src/Preferences.h b/src/Preferences.h
index bdc707d..add1a11 100644
--- a/src/Preferences.h
+++ b/src/Preferences.h
@@ -35,6 +35,7 @@ public slots:
void fontFamilyChanged(const QString &);
void fontSizeChanged(const QString &);
void openCSGWarningChanged(bool);
+ void enableOpenCSGChanged(bool);
signals:
void requestRedraw() const;
diff --git a/src/Preferences.ui b/src/Preferences.ui
index 556172c..6b80674 100644
--- a/src/Preferences.ui
+++ b/src/Preferences.ui
@@ -185,6 +185,16 @@
<property name="text">
<string>Show OpenCSG capability warning</string>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enableOpenCSGBox">
+ <property name="text">
+ <string>Enable OpenCSG for OpenGL 1.x</string>
+ </property>
</widget>
</item>
<item>
@@ -239,7 +249,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../openscad.qrc">
<normaloff>:/icons/prefs3DView.png</normaloff>:/icons/prefs3DView.png</iconset>
</property>
<property name="text">
@@ -251,7 +261,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../openscad.qrc">
<normaloff>:/icons/prefsAdvanced.png</normaloff>:/icons/prefsAdvanced.png</iconset>
</property>
<property name="text">
@@ -263,7 +273,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset>
+ <iconset resource="../openscad.qrc">
<normaloff>:/icons/prefsEditor.png</normaloff>:/icons/prefsEditor.png</iconset>
</property>
<property name="text">
@@ -272,7 +282,7 @@
</action>
</widget>
<resources>
- <include location="openscad.qrc"/>
+ <include location="../openscad.qrc"/>
</resources>
<connections/>
</ui>
diff --git a/src/glview.cc b/src/glview.cc
index bc287b5..bd53b1b 100644
--- a/src/glview.cc
+++ b/src/glview.cc
@@ -39,6 +39,9 @@
#include <QTimer>
#include <QTextEdit>
#include <QVBoxLayout>
+#include <QErrorMessage>
+#include "OpenCSGWarningDialog.h"
+
#include "mathc99.h"
#include <stdio.h>
@@ -133,31 +136,45 @@ void GLView::initializeGL()
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
}
+ this->rendererInfo.sprintf("GLEW version %s\n"
+ "OpenGL version %s\n"
+ "%s (%s)\n\n"
+ "Extensions:\n"
+ "%s\n",
+ glewGetString(GLEW_VERSION),
+ glGetString(GL_RENDERER),
+ glGetString(GL_VENDOR),
+ glGetString(GL_VERSION),
+ glGetString(GL_EXTENSIONS));
+
+
const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20");
if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) {
openscad_disable_gl20_env = NULL;
}
// All OpenGL 2 contexts are OpenCSG capable
- if (GLEW_VERSION_2_0 && !openscad_disable_gl20_env) this->is_opencsg_capable = true;
- // If OpenGL < 2, check for extensions
- else if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true;
- else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) {
- this->is_opencsg_capable = true;
+ if (GLEW_VERSION_2_0) {
+ if (!openscad_disable_gl20_env) {
+ this->is_opencsg_capable = true;
+ this->has_shaders = true;
+ }
}
+ // If OpenGL < 2, check for extensions
+ else {
+ if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true;
+ else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) {
+ this->is_opencsg_capable = true;
+ }
#ifdef WIN32
- else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true;
+ else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true;
#elif !defined(__APPLE__)
- else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true;
+ else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true;
#endif
+ }
- if (GLEW_VERSION_2_0 && !openscad_disable_gl20_env) this->has_shaders = true;
-
- if (!this->is_opencsg_capable) {
- opencsg_support = false;
- QSettings settings;
- // FIXME: This should be an OpenCSG capability warning, not an OpenGL 2 warning
- if (settings.value("editor/opengl20_warning_show",true).toBool()) {
+ if (!GLEW_VERSION_2_0 || !this->is_opencsg_capable) {
+ if (Preferences::inst()->getValue("advanced/opencsg_show_warning").toBool()) {
QTimer::singleShot(0, this, SLOT(display_opencsg_warning()));
}
}
@@ -252,9 +269,19 @@ void GLView::initializeGL()
#ifdef ENABLE_OPENCSG
void GLView::display_opencsg_warning()
{
- // data
- QString title = QString("OpenGL context is not OpenCSG capable");
+ OpenCSGWarningDialog *dialog = new OpenCSGWarningDialog(this);
+ QString message;
+ if (this->is_opencsg_capable) {
+ message += "Warning: You may experience OpenCSG rendering errors.\n\n";
+ }
+ else {
+ message += "Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n";
+ dialog->enableOpenCSGBox->hide();
+ }
+ message += "It is highly recommended to use OpenSCAD on a system with "
+ "OpenGL 2.0 or later.\n"
+ "Your renderer information is as follows:\n";
QString rendererinfo;
rendererinfo.sprintf("GLEW version %s\n"
"%s (%s)\n"
@@ -262,44 +289,13 @@ void GLView::display_opencsg_warning()
glewGetString(GLEW_VERSION),
glGetString(GL_RENDERER), glGetString(GL_VENDOR),
glGetString(GL_VERSION));
+ message += rendererinfo;
- QString message = QString("Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n"
- "It is highly recommended to use OpenSCAD on a system with OpenGL 2.0, "
- "or support for the framebuffer_object or pbuffer extensions. "
- "Your renderer information is as follows:\n\n%1").arg(rendererinfo);
-
- QString note = QString("Uncheck to hide this message in the future");
-
- // presentation
- QDialog *dialog = new QDialog(this);
- dialog->setSizeGripEnabled(true);
- dialog->setWindowTitle(title);
- dialog->resize(500,300);
-
- QVBoxLayout *layout = new QVBoxLayout(dialog);
- dialog->setLayout(layout);
-
- QTextEdit *textEdit = new QTextEdit(dialog);
- textEdit->setPlainText(message);
- layout->addWidget(textEdit);
-
- QCheckBox *checkbox = new QCheckBox(note,dialog);
- checkbox->setCheckState(Qt::Checked);
- layout->addWidget(checkbox);
-
- QDialogButtonBox *buttonbox =
- new QDialogButtonBox( QDialogButtonBox::Ok, Qt::Horizontal,dialog);
- layout->addWidget(buttonbox);
- buttonbox->button(QDialogButtonBox::Ok)->setFocus();
- buttonbox->button(QDialogButtonBox::Ok)->setDefault(true);
-
- // action
- connect(buttonbox, SIGNAL(accepted()), dialog, SLOT(accept()));
- connect(checkbox, SIGNAL(clicked(bool)),
- Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool)));
- connect(checkbox, SIGNAL(clicked(bool)),
- Preferences::inst(), SLOT(openCSGWarningChanged(bool)));
+ dialog->setText(message);
+ dialog->enableOpenCSGBox->setChecked(Preferences::inst()->getValue("advanced/enable_opencsg_opengl1x").toBool());
dialog->exec();
+
+ opencsg_support = this->is_opencsg_capable && Preferences::inst()->getValue("advanced/enable_opencsg_opengl1x").toBool();
}
#endif
diff --git a/src/mainwin.cc b/src/mainwin.cc
index c81f2f2..4b4321d 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -312,6 +312,7 @@ MainWindow::MainWindow(const QString &filename)
connect(this->helpActionAbout, SIGNAL(triggered()), this, SLOT(helpAbout()));
connect(this->helpActionHomepage, SIGNAL(triggered()), this, SLOT(helpHomepage()));
connect(this->helpActionManual, SIGNAL(triggered()), this, SLOT(helpManual()));
+ connect(this->helpActionOpenGLInfo, SIGNAL(triggered()), this, SLOT(helpOpenGL()));
console->setReadOnly(true);
@@ -1752,6 +1753,18 @@ MainWindow::helpManual()
QDesktopServices::openUrl(QUrl("http://en.wikibooks.org/wiki/OpenSCAD_User_Manual"));
}
+void MainWindow::helpOpenGL()
+{
+ if (!this->openglbox) {
+ this->openglbox = new QMessageBox(QMessageBox::Information,
+ "OpenGL Info", "Detailed OpenGL Info",
+ QMessageBox::Ok, this);
+
+ }
+ this->openglbox->setDetailedText(this->glview->getRendererInfo());
+ this->openglbox->show();
+}
+
/*!
FIXME: In MDI mode, should this be called on both reload functions?
*/
@@ -1822,3 +1835,4 @@ void MainWindow::clearCurrentOutput()
{
set_output_handler(NULL, NULL);
}
+
contact: Jan Huwald // Impressum