Qt Quick 3D Graphics Requirements
Qt Quick 3D图形要求
Supported graphics APIs, versions, and shading languages
支持的图形API、版本和着色语言
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.
Qt Quick 3D支持使用Qt 6.0中Qt Quick支持的所有图形API和着色语言进行操作。在某些情况下,尤其是OpenGL和OpenGL ES,Qt Quick 3D的版本要求可能高于Qt Quick。
- OpenGL 3.0 or higher; OpenGL 3.3 or higher is strongly recommended
- OpenGL ES 2.0 or higher; OpenGL ES 3.0 or higher is strongly recommended
- Direct3D 11.1
- Direct3D 12
- Vulkan 1.0 or higher
- Metal 1.2 or higher
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 6的标准方法:将兼容Vulkan的GLSL着色器代码编译为SPIR-V,然后将其转换为GLSL、HLSL和MSL源代码。有关详细信息,请参阅Qt着色器工具模块文档。
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.
Qt Quick 3D不能直接与上述任何图形API配合使用。相反,它使用了Qt渲染硬件接口抽象,类似于Qt Quick。
Choosing the graphics API
选择图形API
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:
由于Qt Quick 3D不单独初始化渲染或窗口,而是依赖于QQuickWindow或QQuickView或window QML类型,因此与图形API选择相关的应用于Qt Quick Scene Graph的所有内容也适用于Qt Quick3D。可以通过设置下面列出的特定环境变量来控制场景图的行为:
Environment Variable 环境变量 | Possible Values 可能的值 | Description 描述 |
---|---|---|
QSG_RHI_BACKEND | vulkan , metal , opengl , d3d11 , d3d12 | 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. 请求特定的RHI后端。默认情况下,基于平台选择目标图形API,除非被此变量或等效的C++API覆盖。默认值目前为适用于Windows的Direct3D 11、适用于macOS的Metal和其他地方的OpenGL。 |
QSG_RHI_DEBUG_LAYER | 1 | Where applicable (Vulkan, Direct3D), enables the graphics API implementation's debug and/or validation layers, if available. 如果适用(Vulkan、Direct3D),启用图形API实现的调试或验证层(如果可用)。 |
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. 与基于OpenGL的渲染路径一样,设置此选项可以在初始化Qt Quick场景图时打印系统信息。这对于故障排除非常有用。 |
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).
希望始终使用单个给定图形API运行的应用程序可以通过QSG_RHI_BACKEND enivronment变量以及C++请求。例如,在构建任何QQuickWindow之前,在main()中早期进行的以下调用会强制使用Vulkan(否则将失败)。
QQuickWindow::setGraphicsApi(QSGRendererInterface::Vulkan);
Note: The software adaptation of Qt Quick is not supported for 3D content.
注意:3D内容不支持Qt Quick的软件改编。
OpenGL specifics
OpenGL细节
Well written Qt Quick 3D applications are expected to call QQuick3D::idealSurfaceFormat() in their main() function, and use the returned QSurfaceFormat as the default:
编写良好的Qt Quick 3D应用程序应在其main()函数中调用QQuick3D::idealSurfaceFormat(),并使用返回的QSurfaceFormat作为默认值:
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.
当使用除OpenGL之外的图形API时,调用此选项没有任何效果,但当API为OpenGL时,调用它将非常有益,因为它将创建最适合Qt Quick 3D需求的OpenGL上下文。
OpenGL ES 2.0 support
OpenGL ES 2.0支持
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:
Qt Quick 3D支持在OpenGL ES 2.0上运行,但功能集非常有限。以下列表包含一些将不可用或不起作用的功能:
- Image based lighting, light probes, skybox
- Shadow mapping
- Screen space ambient occlusion
- Multisampling
- Certain post-processing effects
- Custom materials that use shaders relying on GLSL features not present in GLSL ES 100
© 2024 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.