aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/openglunderqml/squircle.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2012-12-12 20:11:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-07 10:44:02 +0100
commit077ad5f30446f6b3ccc38cb7f05897566f8e5eb7 (patch)
treedec3a47d3c2589b91299c2cbf975de041ed3b8bd /examples/quick/scenegraph/openglunderqml/squircle.cpp
parentb58eb5239452d282b7209784274714b25f530a3c (diff)
Documentation for scene graph examples.
Change-Id: Idb39fc0b6d5e538b90ae8a0b98d9f4d77e1fb617 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'examples/quick/scenegraph/openglunderqml/squircle.cpp')
-rw-r--r--examples/quick/scenegraph/openglunderqml/squircle.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp
index 867ce4a7e0..e907995e7a 100644
--- a/examples/quick/scenegraph/openglunderqml/squircle.cpp
+++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp
@@ -48,6 +48,8 @@
//! [7]
Squircle::Squircle()
: m_program(0)
+ , m_t(0)
+ , m_thread_t(0)
{
}
//! [7]
@@ -70,8 +72,8 @@ void Squircle::itemChange(ItemChange change, const ItemChangeData &)
{
// The ItemSceneChange event is sent when we are first attached to a window.
if (change == ItemSceneChange) {
- QQuickWindow *c = window();
- if (!c)
+ QQuickWindow *win = window();
+ if (!win)
return;
//! [1]
@@ -79,15 +81,17 @@ void Squircle::itemChange(ItemChange change, const ItemChangeData &)
// Since this call is executed on the rendering thread it must be
// a Qt::DirectConnection
//! [2]
- connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
+ connect(win, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
+ connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);
//! [2]
// If we allow QML to do the clearing, they would clear what we paint
// and nothing would show.
//! [3]
- c->setClearBeforeRendering(false);
+ win->setClearBeforeRendering(false);
}
}
+
//! [3] //! [4]
void Squircle::paint()
{
@@ -128,7 +132,7 @@ void Squircle::paint()
1, 1
};
m_program->setAttributeArray(0, GL_FLOAT, values, 2);
- m_program->setUniformValue("t", (float) m_t);
+ m_program->setUniformValue("t", (float) m_thread_t);
glViewport(0, 0, window()->width(), window()->height());
@@ -157,4 +161,10 @@ void Squircle::cleanup()
}
//! [6]
+//! [9]
+void Squircle::sync()
+{
+ m_thread_t = m_t;
+}
+//! [9]