aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/openglunderqml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/scenegraph/openglunderqml')
-rw-r--r--examples/quick/scenegraph/openglunderqml/squircle.cpp13
-rw-r--r--examples/quick/scenegraph/openglunderqml/squircle.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp
index 8ef975c5b6..8bb9af1ed4 100644
--- a/examples/quick/scenegraph/openglunderqml/squircle.cpp
+++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp
@@ -42,7 +42,7 @@ Squircle::Squircle()
: m_t(0)
, m_renderer(0)
{
- connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
+ connect(this, &QQuickItem::windowChanged, this, &Squircle::handleWindowChanged);
}
//! [7]
@@ -62,8 +62,8 @@ void Squircle::setT(qreal t)
void Squircle::handleWindowChanged(QQuickWindow *win)
{
if (win) {
- connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);
- connect(win, SIGNAL(sceneGraphInvalidated()), this, SLOT(cleanup()), Qt::DirectConnection);
+ connect(win, &QQuickWindow::beforeSynchronizing, this, &Squircle::sync, Qt::DirectConnection);
+ connect(win, &QQuickWindow::sceneGraphInvalidated, this, &Squircle::cleanup, Qt::DirectConnection);
//! [1]
// If we allow QML to do the clearing, they would clear what we paint
// and nothing would show.
@@ -93,10 +93,11 @@ void Squircle::sync()
{
if (!m_renderer) {
m_renderer = new SquircleRenderer();
- connect(window(), SIGNAL(beforeRendering()), m_renderer, SLOT(paint()), Qt::DirectConnection);
+ connect(window(), &QQuickWindow::beforeRendering, m_renderer, &SquircleRenderer::paint, Qt::DirectConnection);
}
m_renderer->setViewportSize(window()->size() * window()->devicePixelRatio());
m_renderer->setT(m_t);
+ m_renderer->setWindow(window());
}
//! [9]
@@ -156,5 +157,9 @@ void SquircleRenderer::paint()
m_program->disableAttributeArray(0);
m_program->release();
+
+ // Not strictly needed for this example, but generally useful for when
+ // mixing with raw OpenGL.
+ m_window->resetOpenGLState();
}
//! [5]
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.h b/examples/quick/scenegraph/openglunderqml/squircle.h
index f797d7a7a5..28016def44 100644
--- a/examples/quick/scenegraph/openglunderqml/squircle.h
+++ b/examples/quick/scenegraph/openglunderqml/squircle.h
@@ -50,6 +50,7 @@ public:
void setT(qreal t) { m_t = t; }
void setViewportSize(const QSize &size) { m_viewportSize = size; }
+ void setWindow(QQuickWindow *window) { m_window = window; }
public slots:
void paint();
@@ -58,6 +59,7 @@ private:
QSize m_viewportSize;
qreal m_t;
QOpenGLShaderProgram *m_program;
+ QQuickWindow *m_window;
};
//! [1]