씬 그래프 - QML의 Metal

Qt Quick 씬 아래에서 Metal으로 직접 렌더링하는 방법을 보여줍니다.

Metal Under QML 예제는 애플리케이션이 QQuickWindow::beforeRendering() 및 QQuickWindow::beforeRenderPassRecording() 신호를 사용하여 Qt Quick 씬 아래에 커스텀 Metal 콘텐츠를 그리는 방법을 보여줍니다. 이 신호는 씬 그래프가 렌더링을 시작하기 전에 모든 프레임이 시작될 때 방출되므로 이 신호에 대한 응답으로 수행되는 모든 Metal 그리기 호출은 Qt Quick 항목 아래에 스택됩니다. 커스텀 Metal 명령은 씬 그래프가 사용하는 것과 동일한 렌더링 명령 인코더를 사용하여 동일한 명령 버퍼에 기록되기 때문에 두 개의 신호가 있습니다. MTLRenderCommandEncoder를 사용하기 전에 프레임이 시작될 때 발생하므로 beforeRendering() 자체만으로는 충분하지 않습니다. 또한 beforeRenderPassRecording()에 연결하면 애플리케이션이 필요한 네이티브 오브젝트에 액세스할 수 있습니다.

또는 Qt Quick 씬 위에 Metal 콘텐츠를 렌더링하려는 애플리케이션은 QQuickWindow::afterRendering() 및 QQuickWindow::afterRenderPassRecording() 신호에 연결하여 렌더링할 수 있습니다.

이 예제에서는 메탈 렌더링에 영향을 주는 값을 QML에 노출하는 방법도 살펴봅니다. QML 파일에서 NumberAnimation 을 사용하여 임계값에 애니메이션을 적용하고 이 값은 동그라미를 그리는 Metal 셰이더 프로그램에서 사용됩니다.

이 예제는 대부분의 경우 QML의 OpenGL, QML의 Direct3D 11Vulkan의 QML 예제와 동일하며, 모두 다른 네이티브 API를 통해 동일한 커스텀 콘텐츠를 렌더링합니다.

예제 프로젝트 @ code.qt.io

© 2025 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.