1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
From: Giles Bathgate <giles.bathgate@blueprism.com>
Date: Fri, 23 Oct 2015 23:59:04 +0100
Subject: Use QOpenGLWidget when Qt Version >= 5.4
---
src/QGLView.cc | 11 ++++++++++-
src/QGLView.h | 19 +++++++++++++++++--
src/openscad.cc | 4 ++++
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/QGLView.cc b/src/QGLView.cc
index fa190b3..fd447a8 100644
--- a/src/QGLView.cc
+++ b/src/QGLView.cc
@@ -50,12 +50,19 @@
# include <opencsg.h>
#endif
-QGLView::QGLView(QWidget *parent) : QGLWidget(parent)
+QGLView::QGLView(QWidget *parent) :
+#if QT_VERSION >= 0x050400
+ QOpenGLWidget(parent)
+#else
+ QGLWidget(parent)
+#endif
{
init();
}
+#if !(QT_VERSION >= 0x050400)
static bool running_under_wine = false;
+#endif
void QGLView::init()
{
@@ -162,7 +169,9 @@ void QGLView::paintGL()
statusLabel->setText(QString::fromStdString(nc.statusText()));
}
+#if !(QT_VERSION >= 0x050400)
if (running_under_wine) swapBuffers();
+#endif
}
void QGLView::mousePressEvent(QMouseEvent *event)
diff --git a/src/QGLView.h b/src/QGLView.h
index 7d8093a..e51c3df 100644
--- a/src/QGLView.h
+++ b/src/QGLView.h
@@ -1,7 +1,13 @@
#pragma once
#include "system-gl.h"
+#include <QtGlobal>
+
+#if QT_VERSION >= 0x050400
+#include <QOpenGLWidget>
+#else
#include <QGLWidget>
+#endif
#include <QLabel>
#include <Eigen/Core>
@@ -9,7 +15,13 @@
#include "GLView.h"
#include "renderer.h"
-class QGLView : public QGLWidget, public GLView
+class QGLView :
+#if QT_VERSION >= 0x050400
+ public QOpenGLWidget,
+#else
+ public QGLWidget,
+#endif
+ public GLView
{
Q_OBJECT
Q_PROPERTY(bool showFaces READ showFaces WRITE setShowFaces);
@@ -53,7 +65,10 @@ public slots:
public:
QLabel *statusLabel;
-
+#if QT_VERSION >= 0x050400
+ inline void updateGL() { update(); }
+ inline QImage grabFrameBuffer() { return grabFramebuffer(); }
+#endif
private:
void init();
diff --git a/src/openscad.cc b/src/openscad.cc
index 73d6759..60a3a1f 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -690,6 +690,9 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
updater->init();
#endif
+#if !(QT_VERSION >= 0x050400)
+ // This workaround appears to only be needed when QGLWidget is used QOpenGLWidget
+ // available in Qt 5.4 is much better.
QGLFormat fmt;
#if 0 /*** disabled by clifford wolf: adds rendering artefacts with OpenCSG ***/
// turn on anti-aliasing
@@ -703,6 +706,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
// (see https://bugreports.qt-project.org/browse/QTBUG-39370
fmt.setSwapInterval(0);
QGLFormat::setDefaultFormat(fmt);
+#endif
set_render_color_scheme(arg_colorscheme, false);
|