“Hello Vulkan Cubes”示例
展示了使用 `QVulkanWindow` 的基础知识。
“Hello Vulkan Cubes”示例展示了QVulkanWindow 的更高级用法。

在此示例中,有一个从文件加载的网格,以及两种不同的材质和相应的图形管线。这些圆角立方体使用实例化技术绘制,并采用 Phong 光照模型,配有一个单向光源。
与“hellovulkantexture”和“hellovulkantriangle”不同,此处的统一缓冲区处理采用了另一种方法:使用动态统一缓冲区代替多个描述符集。
该示例需要 QtConcurrent,因为它演示了如何将 QtConcurrent::run()、QFuture 以及QFutureWatcher 与QVulkanWindow 结合使用。网格和着色器数据的加载、可能耗时的图形管道构建,以及帧命令缓冲区的构建,均在各自的工线程中完成。
该场景被嵌入到基于小部件的用户界面中。QVulkanWindow 的子类还处理鼠标和键盘输入,因为它提供了一个第一人称视角的摄像机,以便在场景中移动。
运行示例
您可以通过以下方式运行该示例:
- Qt Creator
打开Welcome 模式,并从Examples 中选择该示例。有关更多信息,请参阅Qt Creator :教程:构建与运行。
- Qt Extension for Visual Studio Code
在Command Palette 中运行Qt: Open Qt examples 命令,并从列表中选择该示例。有关更多信息,请参阅Qt Extension for Visual Studio Code :教程:构建与运行。
© 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.