Qt 3D Render C++ Classes
Qt 3D 渲染模块包含支持使用Qt 3D 进行2D和3D渲染的功能。更多内容...
自 6.8 版本起,该模块已被废弃。我们强烈建议不要在新代码中使用它。
命名空间
类
详细说明
Qt 3D 渲染模块提供了一个方面、组件以及其他必要的支持类型,用于作为Qt 3D 框架的一部分来实现2D和3D渲染。
要使用该模块中的类,请在 C++ 文件中添加以下指令:
#include <Qt3DRender>要链接相应的 C++ 库,请在 qmake 项目文件中添加以下内容:
QT += 3drender类、类型和函数均声明在Qt3DRender 命名空间下。
概述
Qt 3D 的Render组件支持Qt 3D 渲染框架中所述的数据驱动配置。
选择渲染后端
“Render”方面提供了两个渲染后端。
- OpenGL 后端(ES 2、ES 3.2、GL 2、GL 3、GL 3.2、GL 4.3)
- RHI 后端(ES 2、GL、DirectX、Vulkan、Metal)
如果您仅针对 OpenGL 平台开发,并且使用了特定的 OpenGL 功能,那么使用 OpenGL 后端可能更合适。这是Qt 3D 在 Qt 5 系列中专用的 OpenGL 后端。
如果您未使用特定的 OpenGL 功能,且希望支持可能已弃用 OpenGL 的不同平台,则使用 RHI 后端是更好的选择。
要选择渲染后端,需将环境变量 QT3D_RENDERER 设置为“opengl”或“rhi”。默认使用 OpenGL 后端。
使用 RHI 后端时,您可以通过将 QSG_RHI_BACKEND 设置为以下值之一,进一步强制使用内部 RHI 后端:
- opengl -> RHI OpenGL 后端
- gl -> RHI OpenGL 后端
- gles2 -> RHI OpenGL 后端
- metal -> RHI Metal 后端
- vulkan -> RHI Vulkan 后端
- d3d11 -> RHI DirectX 11 后端
如果未指定,RHI 将默认采用其推断出的最适合该平台的后端。
参考
© 2026 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.