Qt Quick 3D supports operating with all the graphics APIs and shading languages supported by Qt Quick in Qt 6.0. In some cases, with OpenGL and OpenGL ES in particular, the version requirement may be higher for Qt Quick 3D than for Qt Quick.
The shader pipeline is based on the standard approach of Qt 6: Vulkan-compatible GLSL shader code is compiled to SPIR-V, which is then translated to GLSL, HLSL, and MSL source code. Refer to the Qt Shader Tools module documentation for details.
Qt Quick 3D does not directly work with any of the graphics APIs mentioned above. Rather, it uses the Qt Rendering Hardware Interface abstractions, similarly to Qt Quick.
As Qt Quick 3D does not initialize rendering or a window on its own, but rather relies on QQuickWindow or QQuickView or the Window QML type, everything related to graphics API selection that applies to the Qt Quick Scene Graph applies to Qt Quick 3D as well. It is possible to control the behavior of the scene graph by setting specific environment variables as listed below:
Environment Variable | Possible Values | Description |
---|---|---|
QSG_RHI_BACKEND |
vulkan , metal , opengl , d3d11 |
Requests the specific RHI backend. By default the targeted graphics API is chosen based on the platform, unless overridden by this variable or the equivalent C++ APIs. The defaults are currently Direct3D 11 for Windows, Metal for macOS, OpenGL elsewhere. |
QSG_RHI_DEBUG_LAYER |
1 |
Where applicable (Vulkan, Direct3D), enables the graphics API implementation's debug and/or validation layers, if available. |
QSG_INFO |
1 |
Like with the OpenGL-based rendering path, setting this enables printing system information when initializing the Qt Quick scene graph. This can be very useful for troubleshooting. |
Applications wishing to always run with a single given graphics API can request this via the QSG_RHI_BACKEND
enivronment variable, as well as with C++. For example, the following call made early in
main()
, before constructing any QQuickWindow, forces the use of Vulkan (and will fail otherwise).
QQuickWindow::setGraphicsApi(QSGRendererInterface::Vulkan);
Note: The software adaptation of Qt Quick is not supported for 3D content.
Well written Qt Quick 3D applications are expected to call QQuick3D::idealSurfaceFormat() in their main() function, and use the returned QSurfaceFormat as the default:
QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
Calling this has no effect when a graphics API other than OpenGL is used, but is highly beneficial when the API is OpenGL as it will lead to creating an OpenGL context that is best suited for Qt Quick 3D's needs.
Qt Quick 3D supports running on OpenGL ES 2.0, but with a significantly limited feature set. The following list contains some of the features that will be unavailable or disfunctional:
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: