Scene Graph Adaptations¶
Scene Graph Adaptations in Qt Quick¶
In Qt 5.0, Qt Quick always relied on OpenGL (OpenGL ES 2.0 or OpenGL 2.0) to parse the scene graph and render the results to a render target.
From Qt 5.8 onwards, Qt Quick also supports rendering in software, and with OpenVG. This is realized by having additional scene graph adaptations, either in form of plugins (openvg) or built-in to the Qt Quick library (software). The default adaptation continues to rely directly on OpenGL.
From Qt 5.14 onwards, the default adaptation gains the option of rendering via a graphics abstraction layer, the Qt Rendering Hardware Interface (RHI), provided by the QtGui module. When enabled, no direct OpenGL calls are made. Rather, the scene graph renders by using the APIs provided by the abstraction layer, which is then translated into OpenGL, Vulkan, Metal, or Direct 3D calls. Shader handling is also unified by writing shader code once, compiling to SPIR-V , and then translating to the language appropriate for the various graphics APIs.
Starting with Qt 6.0, the RHI-based rendering model is the default, and there is no option to fall back to directly using OpenGL.
Switch Between Adaptations in Your Application¶
software, the RHI-based renderer is not an additional adaptation, and is always built-in. As of Qt 6.0 it is always enabled. On platforms where multiple graphics APIs are available, the scenegraph makes a platform-specific choice. If this is not desired, applications can force a specified graphics API by setting the environment variable
QSG_RHI_BACKEND or via
setGraphicsApi() in combination with
Switching to a different adaptation can be achieved in two ways:
Use an environment variable - Set the
QT_QUICK_BACKENDor the legacy
QMLSCENE_DEVICEenvironment variable before launching applications.
Use a C++ API - Call
setSceneGraphBackend()early on in the application’s main() function.
The following backends are supported:
Default - Request with the
"rhi"string or a
GraphicsApienum value different than the ones listed below.
Software - Request with the
"software"string or the
OpenVG - Request with the
"openvg"string or the
To find out which backend is in use, you can enable basic scene graph information logging via the
QSG_INFO environment variable or the
qt.scenegraph.general logging category. This results in some information being printed onto the debug output, during application startup.
In Qt builds with both OpenGL and Vulkan disabled, the default adaptation is
software. This does not apply to Windows or macOS however, because these platforms always have Direct 3D or Metal support, respectively, enabled.
Typically, adaptations other than the default one come with a set of limitations as they are unlikely to provide a feature set that’s 100% compatible with OpenGL. However, these adaptations may provide their own specific advantages in certain areas. For more information on the various adaptations, refer to the sections below.
When using OpenGL directly, the default adaptation is capable of providing the full Qt Quick 2 feature set. For more details, see Default Adaptation .
The Software adaptation is an alternative renderer for Qt Quick 2 that uses the raster paint engine to render the contents of the scene graph. For more details, see Software Adaptation .
The OpenVG adaptation is an alternative renderer for Qt Quick 2 that renders the contents of the scene graph using OpenVG commands to provide hardware-accelerated 2D vector and raster graphics. For more details, see OpenVG Adaptation .
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.