Skip to content

Commit

Permalink
Remove support for OpenGL < 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kintel committed Mar 23, 2023
1 parent 40f973e commit 64e2a42
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 74 deletions.
33 changes: 3 additions & 30 deletions src/glview/GLView.cc
Expand Up @@ -7,11 +7,6 @@
#include "degree_trig.h"
#include <cmath>
#include <cstdio>
#ifdef _WIN32
#include <GL/wglew.h>
#elif !defined(__APPLE__)
#include <GL/glxew.h>
#endif

#ifdef ENABLE_OPENCSG
#include <opencsg.h>
Expand All @@ -32,7 +27,6 @@ GLView::GLView()
#ifdef ENABLE_OPENCSG
is_opencsg_capable = false;
has_shaders = false;
opencsg_support = true;
static int sId = 0;
this->opencsg_id = sId++;
#endif
Expand Down Expand Up @@ -195,33 +189,12 @@ void glCompileCheck(GLuint shader) {

void GLView::enable_opencsg_shaders()
{
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 = nullptr;
}

// All OpenGL 2 contexts are OpenCSG capable
if (GLEW_VERSION_2_0) {
if (!openscad_disable_gl20_env) {
this->is_opencsg_capable = true;
this->has_shaders = true;
}
this->is_opencsg_capable = true;
this->has_shaders = true;
}
#ifndef GLEW_EGL
// If OpenGL < 2, check for extensions
else if (GLEW_ARB_framebuffer_object || (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil)
#ifdef _WIN32
|| (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format)
#elif !defined(__APPLE__)
// not supported by GLEW when built with EGL
|| (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig)
#endif
) {
this->is_opencsg_capable = true;
}
#endif // ifndef GLEW_EGL

if (!GLEW_VERSION_2_0 || !this->is_opencsg_capable) {
else {
display_opencsg_warning();
}
}
Expand Down
1 change: 0 additions & 1 deletion src/glview/GLView.h
Expand Up @@ -75,7 +75,6 @@ class GLView
bool has_shaders;
void enable_opencsg_shaders();
virtual void display_opencsg_warning() = 0;
bool opencsg_support;
int opencsg_id;
#endif
private:
Expand Down
5 changes: 0 additions & 5 deletions src/gui/OpenCSGWarningDialog.cc
Expand Up @@ -9,11 +9,6 @@ OpenCSGWarningDialog::OpenCSGWarningDialog(QWidget *)
Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool)));
connect(this->showBox, SIGNAL(toggled(bool)),
Preferences::inst(), SLOT(on_openCSGWarningBox_toggled(bool)));

connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)),
Preferences::inst()->enableOpenCSGBox, SLOT(setChecked(bool)));
connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)),
Preferences::inst(), SLOT(on_enableOpenCSGBox_toggled(bool)));
}

void OpenCSGWarningDialog::setText(const QString& text)
Expand Down
10 changes: 0 additions & 10 deletions src/gui/OpenCSGWarningDialog.ui
Expand Up @@ -28,16 +28,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableOpenCSGBox">
<property name="text">
<string>Enable OpenCSG</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand Down
9 changes: 0 additions & 9 deletions src/gui/Preferences.cc
Expand Up @@ -115,7 +115,6 @@ void Preferences::init() {

// Setup default settings
this->defaultmap["advanced/opencsg_show_warning"] = true;
this->defaultmap["advanced/enable_opencsg_opengl1x"] = true;
this->defaultmap["advanced/polysetCacheSize"] = qulonglong(GeometryCache::instance()->maxSizeMB()) * 1024ul * 1024ul;
this->defaultmap["advanced/polysetCacheSizeMB"] = getValue("advanced/polysetCacheSize").toULongLong() / (1024ul * 1024ul); // carry over old settings if they exist
#ifdef ENABLE_CGAL
Expand Down Expand Up @@ -437,13 +436,6 @@ Preferences::on_openCSGWarningBox_toggled(bool state)
settings.setValue("advanced/opencsg_show_warning", state);
}

void
Preferences::on_enableOpenCSGBox_toggled(bool state)
{
QSettingsCached settings;
settings.setValue("advanced/enable_opencsg_opengl1x", state);
}

void Preferences::on_cgalCacheSizeMBEdit_textChanged(const QString& text)
{
QSettingsCached settings;
Expand Down Expand Up @@ -963,7 +955,6 @@ void Preferences::updateGUI()
}

BlockSignals<QCheckBox *>(this->openCSGWarningBox)->setChecked(getValue("advanced/opencsg_show_warning").toBool());
BlockSignals<QCheckBox *>(this->enableOpenCSGBox)->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool());
BlockSignals<QLineEdit *>(this->cgalCacheSizeMBEdit)->setText(getValue("advanced/cgalCacheSizeMB").toString());
BlockSignals<QLineEdit *>(this->polysetCacheSizeMBEdit)->setText(getValue("advanced/polysetCacheSizeMB").toString());
BlockSignals<QLineEdit *>(this->opencsgLimitEdit)->setText(getValue("advanced/openCSGLimit").toString());
Expand Down
1 change: 0 additions & 1 deletion src/gui/Preferences.h
Expand Up @@ -33,7 +33,6 @@ public slots:
void on_fontSize_currentIndexChanged(const QString&);
void on_syntaxHighlight_activated(const QString&);
void on_openCSGWarningBox_toggled(bool);
void on_enableOpenCSGBox_toggled(bool);
void on_cgalCacheSizeMBEdit_textChanged(const QString&);
void on_polysetCacheSizeMBEdit_textChanged(const QString&);
void on_opencsgLimitEdit_textChanged(const QString&);
Expand Down
7 changes: 0 additions & 7 deletions src/gui/Preferences.ui
Expand Up @@ -1655,13 +1655,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableOpenCSGBox">
<property name="text">
<string>Enable for OpenGL 1.x</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
Expand Down
11 changes: 1 addition & 10 deletions src/gui/QGLView.cc
Expand Up @@ -121,13 +121,7 @@ void QGLView::display_opencsg_warning_dialog()
{
auto 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();
}
QString message = _("Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n");
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");
Expand All @@ -138,10 +132,7 @@ void QGLView::display_opencsg_warning_dialog()
(const char *)glGetString(GL_VERSION));

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 // ifdef ENABLE_OPENCSG

Expand Down
2 changes: 1 addition & 1 deletion src/gui/QGLView.h
Expand Up @@ -22,7 +22,7 @@ class QGLView : public QOpenGLWidget, public GLView
public:
QGLView(QWidget *parent = nullptr);
#ifdef ENABLE_OPENCSG
bool hasOpenCSGSupport() { return this->opencsg_support; }
bool hasOpenCSGSupport() { return this->is_opencsg_capable; }
#endif
// Properties
bool orthoMode() const { return (this->cam.projection == Camera::ProjectionType::ORTHOGONAL); }
Expand Down

0 comments on commit 64e2a42

Please sign in to comment.