aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/openglunderqml/squircle.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2014-06-13 13:59:57 +0200
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-06-16 09:12:48 +0200
commit1e39eb5f701977ac3ea4b6d66f2ce304931a1085 (patch)
tree7d5339b07a14991f1b770a69160372410d02b3f1 /examples/quick/scenegraph/openglunderqml/squircle.h
parentdf2c91bfb1e70937725bf2da760dc9475cb04105 (diff)
Separate renderer out in "OpenGL under QML" example.
The example was promoting very bad practice. Change-Id: Ibb83780ec33e59ee5aabf65a775705dd0da681e6 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'examples/quick/scenegraph/openglunderqml/squircle.h')
-rw-r--r--examples/quick/scenegraph/openglunderqml/squircle.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.h b/examples/quick/scenegraph/openglunderqml/squircle.h
index 449e02bbf1..aa50908242 100644
--- a/examples/quick/scenegraph/openglunderqml/squircle.h
+++ b/examples/quick/scenegraph/openglunderqml/squircle.h
@@ -45,11 +45,32 @@
#include <QtQuick/QQuickItem>
#include <QtGui/QOpenGLShaderProgram>
+
+
+//! [1]
+class SquircleRenderer : public QObject {
+ Q_OBJECT
+public:
+ SquircleRenderer() : m_t(0), m_program(0) { }
+ ~SquircleRenderer();
+
+ void setT(qreal t) { m_t = t; }
+ void setViewportSize(const QSize &size) { m_viewportSize = size; }
+
+public slots:
+ void paint();
+
+private:
+ QSize m_viewportSize;
+ qreal m_t;
+ QOpenGLShaderProgram *m_program;
+};
//! [1]
+
+//! [2]
class Squircle : public QQuickItem
{
Q_OBJECT
-
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
public:
@@ -62,19 +83,16 @@ signals:
void tChanged();
public slots:
- void paint();
- void cleanup();
void sync();
+ void cleanup();
private slots:
void handleWindowChanged(QQuickWindow *win);
private:
- QOpenGLShaderProgram *m_program;
-
qreal m_t;
- qreal m_thread_t;
+ SquircleRenderer *m_renderer;
};
-//! [1]
+//! [2]
#endif // SQUIRCLE_H