diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-19 13:29:01 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-02-19 13:28:48 +0000 |
commit | c6477a7cf592c335c027429b8a8066a20b812b87 (patch) | |
tree | ca4f7abaa9f188313b75bfbf9d8ce07d71e22a10 /src | |
parent | 47d4b0a9a476eb41a4472c5f2bb64040044f0e8a (diff) |
Reset the state the Qt Quick scenegraph relies on in Scene3D
Qt3D rendering may change state that is relevant also for the Qt Quick
scenegraph. This becomes apparent in more complex cases, for example
combining a Qt Quick Controls based UI with a scene containing multiple
textured objects often ends up in totally garbled frames. To overcome this,
call QQuickWindow's resetOpenGLState() which is offered exactly for this
purpose.
Change-Id: Ic56d2f78e121908335917a89b97ba735ca24e0af
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index 04791ec03..ce21e7283 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -43,8 +43,8 @@ #include <QOpenGLContext> #include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObjectFormat> - #include <QSurface> +#include <QQuickWindow> #include <QSGSimpleTextureNode> @@ -103,6 +103,14 @@ public: Q_UNUSED(saver) m_renderAspect->renderSynchronous(); + + // We may have called doneCurrent() so restore the context. + saver.context()->makeCurrent(saver.surface()); + + // Reset the state used by the Qt Quick scenegraph to avoid any + // interference when rendering the rest of the UI. + m_item->window()->resetOpenGLState(); + update(); } |