From c6477a7cf592c335c027429b8a8066a20b812b87 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 19 Feb 2015 13:29:01 +0100 Subject: 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 --- src/quick3d/imports/scene3d/scene3ditem.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include - #include +#include #include @@ -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(); } -- cgit v1.2.3