场景图——QML下的Direct3D 11
演示如何在Qt Quick 场景下直接使用Direct3D 11进行渲染。
Qt Quick 场景中使用 Direct3D 11 渲染的带文字叠加的动画“椭圆”" src="images/d3d11underqml-example.jpg" title="在 Qt Quick 场景中使用 Direct3D 11 渲染的带文字叠加的动画“椭圆”"/>
“QML下的Direct3D 11”示例展示了应用程序如何利用QQuickWindow::beforeRendering()信号,在Qt Quick 场景中绘制自定义的D3D11内容。 该信号在每帧开始时触发,即在场景图开始渲染之前,因此任何作为对此信号响应而发出的 D3D11 绘制调用,都将堆叠在Qt Quick 项之下。
作为替代方案,希望在Qt Quick 场景之上渲染D3D11内容的应用程序,可通过连接到QQuickWindow::afterRendering()信号来实现。
在此示例中,我们还将看到如何将影响 D3D11 渲染的值暴露给 QML。我们通过 QML 文件中的NumberAnimation 对阈值进行动画处理,而绘制“松鼠圈”的 HLSL 着色器程序会使用该值。
该示例在多数方面与“OpenGL Under QML”、“Metal Under QML ”和“Vulkan Under QML”示例等效,它们都渲染相同的自定义内容,只是通过不同的原生 API 实现。
© 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.