Scene3DRenderer Class
class Qt3DRender::Scene3DRendererThe Scene3DRenderer class takes care of rendering a Qt3D scene within a Framebuffer object to be used by the QtQuick 2 renderer. More...
Header: | #include <Scene3DRenderer> |
Inherits: | QObject |
Detailed Description
\internal
The Scene3DRenderer class renders a Qt3D scene as provided by a Scene3DItem. It owns the aspectEngine even though it doesn't instantiate it.
The render loop goes as follows:
- The main thread runs, drives Animations, etc. and causes changes to be reported to the Qt3D change arbiter. The first change reported will cause the scene3drenderer to be marked dirty.
- The QtQuick render thread starts a new frame, synchronizes the scene graph and emits afterSynchronizing. This will trigger some preparational steps for rendering and mark the QSGNode dirty if the Scene3DRenderer is dirty.
- The QtQuick render loop emits beforeRendering. If we're marked dirty or if the renderPolicy is set to Always, we'll ask the Qt3D renderer aspect to render. That call is blocking. If the aspect jobs are not done, yet, the renderer will exit early and we skip a frame.
The shutdown procedure is a two steps process that goes as follow:
- The window is closed
- This triggers the windowsChanged signal which the Scene3DRenderer uses to perform the necessary cleanups in the QSGRenderThread (destroys DebugLogger ...) with the shutdown slot (queued connection).
- The destroyed signal of the window is also connected to the Scene3DRenderer. When triggered in the context of the main thread, the cleanup slot is called.
There is an alternate shutdown procedure in case the QQuickItem is destroyed with an active window which can happen in the case where the Scene3D is used with a QtQuick Loader
In that case the shutdown procedure goes the same except that the destroyed signal of the window is not called. Therefore the cleanup method is invoked to properly destroy the aspect engine.