diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-10-19 19:20:18 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2009-10-19 19:20:18 (GMT) |
commit | b905e8e537515d80b24e77943e7a6ffcf0e6749d (patch) | |
tree | 0b88663e596f5361005119efdea31a3c4a7ba5b4 | |
parent | 05b2eb1b90620025ba9242477b0df688745dd0db (diff) |
Clifford Wolf:
Added OpenGL 2.0 / OpenCSG check
git-svn-id: http://svn.clifford.at/openscad/trunk@110 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r-- | glview.cc | 18 | ||||
-rw-r--r-- | mainwin.cc | 42 | ||||
-rw-r--r-- | openscad.h | 10 |
3 files changed, 57 insertions, 13 deletions
@@ -23,6 +23,7 @@ #include <QApplication> #include <QWheelEvent> #include <QMouseEvent> +#include <QMessageBox> #define FAR_FAR_AWAY 100000.0 @@ -53,6 +54,9 @@ GLView::GLView(QWidget *parent) : QGLWidget(parent) statusLabel = NULL; setMouseTracking(true); +#ifdef ENABLE_OPENCSG + opencsg_support = true; +#endif } extern GLint e1, e2, e3; @@ -158,11 +162,23 @@ void GLView::initializeGL() } } } else { - fprintf(stdout, "GLEW: GL_VERSION_2_0 is not supported!\n"); + opencsg_support = false; + QTimer::singleShot(0, this, SLOT(display_opengl20_warning())); } #endif /* ENABLE_OPENCSG */ } +#ifdef ENABLE_OPENCSG +void GLView::display_opengl20_warning() +{ + QMessageBox::warning(NULL, "GLEW: GL_VERSION_2_0 is not supported!", + "Warning: No support for OpenGL 2.0 found! OpenCSG View has been disabled.\n\n" + "It is highly recommended to use OpenSCAD on a system with OpenGL 2.0 " + "support. Please check if OpenGL 2.0 drivers are available for your " + "graphics hardware."); +} +#endif + void GLView::resizeGL(int w, int h) { #ifdef ENABLE_OPENCSG @@ -153,8 +153,12 @@ MainWindow::MainWindow(const char *filename) { QMenu *menu = menuBar()->addMenu("&View"); #ifdef ENABLE_OPENCSG - actViewModeOpenCSG = menu->addAction("OpenCSG", this, SLOT(viewModeOpenCSG()), QKeySequence(Qt::Key_F9)); - actViewModeOpenCSG->setCheckable(true); + if (screen->opencsg_support) { + actViewModeOpenCSG = menu->addAction("OpenCSG", this, SLOT(viewModeOpenCSG()), QKeySequence(Qt::Key_F9)); + actViewModeOpenCSG->setCheckable(true); + } else { + actViewModeOpenCSG = NULL; + } #endif #ifdef ENABLE_CGAL actViewModeCGALSurface = menu->addAction("CGAL Surfaces", this, SLOT(viewModeCGALSurface()), QKeySequence(Qt::Key_F10)); @@ -214,6 +218,12 @@ MainWindow::MainWindow(const char *filename) setWindowTitle("New Document"); } + setCentralWidget(s1); + + // display this window and check for OpenGL 2.0 (OpenCSG) support + viewModeThrownTogether(); + show(); + #ifdef ENABLE_OPENCSG viewModeOpenCSG(); #else @@ -221,7 +231,6 @@ MainWindow::MainWindow(const char *filename) #endif viewPerspective(); - setCentralWidget(s1); current_win = NULL; } @@ -634,7 +643,8 @@ void MainWindow::actionReloadCompile() compile(true); #ifdef ENABLE_OPENCSG - if (!actViewModeOpenCSG->isChecked() && !actViewModeThrownTogether->isChecked()) { + if (!(actViewModeOpenCSG && actViewModeOpenCSG->isChecked()) && + !actViewModeThrownTogether->isChecked()) { viewModeOpenCSG(); } else @@ -653,7 +663,8 @@ void MainWindow::actionCompile() compile(!actViewModeAnimate->isChecked()); #ifdef ENABLE_OPENCSG - if (!actViewModeOpenCSG->isChecked() && !actViewModeThrownTogether->isChecked()) { + if (!(actViewModeOpenCSG && actViewModeOpenCSG->isChecked()) && + !actViewModeThrownTogether->isChecked()) { viewModeOpenCSG(); } else @@ -850,7 +861,8 @@ void MainWindow::actionExportOFF() void MainWindow::viewModeActionsUncheck() { #ifdef ENABLE_OPENCSG - actViewModeOpenCSG->setChecked(false); + if (actViewModeOpenCSG) + actViewModeOpenCSG->setChecked(false); #endif #ifdef ENABLE_CGAL actViewModeCGALSurface->setChecked(false); @@ -954,11 +966,19 @@ static void renderGLviaOpenCSG(void *vp) void MainWindow::viewModeOpenCSG() { - viewModeActionsUncheck(); - actViewModeOpenCSG->setChecked(true); - screen->renderfunc = renderGLviaOpenCSG; - screen->renderfunc_vp = this; - screen->updateGL(); + if (screen->opencsg_support) { + viewModeActionsUncheck(); + actViewModeOpenCSG->setChecked(true); + screen->renderfunc = renderGLviaOpenCSG; + screen->renderfunc_vp = this; + screen->updateGL(); + } else { + if (actViewModeOpenCSG) { + delete actViewModeOpenCSG; + actViewModeOpenCSG = NULL; + } + viewModeThrownTogether(); + } } #endif /* ENABLE_OPENCSG */ @@ -663,6 +663,9 @@ public: GLint shaderinfo[11]; QLabel *statusLabel; +#ifdef ENABLE_OPENCSG + bool opencsg_support; +#endif GLView(QWidget *parent = NULL); @@ -680,6 +683,11 @@ protected: void initializeGL(); void resizeGL(int w, int h); void paintGL(); + +#ifdef ENABLE_OPENCSG +private slots: + void display_opengl20_warning(); +#endif }; class MainWindow : public QMainWindow @@ -773,7 +781,7 @@ public: QAction *actViewOrthogonal; void viewModeActionsUncheck(); -private slots: +public slots: #ifdef ENABLE_OPENCSG void viewModeOpenCSG(); #endif |