This is a module, made using Qt 5.14.0, that speeds up the creation of OpenXR applications for Qt Quick 3D.
- Install Monado (https://gitlab.freedesktop.org/monado/monado) and ensure xrgears runs
- Install Qt 5.14.1 base, QML, Quick and Quick 3D via package manager, Qt's website (https://www.qt.io/download), or compile it yourself (https://github.com/qt)
- Build Quick3D-OpenXR using the provided scripts (make sure qmake is in your PATH):
$ mkdir build && cd build
$ sh ../scripts/build.sh ..
Quick3D-OpenXR does most of the work connecting to OpenXR and setting up Qt Quick 3D. But there are still a few steps you need to do:
In int main
in main.cpp:
- Create a
QGuiApplication
- Create a
QOpenXRApplication
- Register any QML types you need to
- Create a
QQmlEngine
- Create a
QQmlComponent
loading the QML for the main scene synchronously - Initialize the
QOpenXRApplication
Example main.cpp:
#include <QGuiApplication>
#include <QQmlEngine>
#include <QOpenXRApplication>
#include <QDebug>
int main(int argc, char *argv[]) {
QGuiApplication a(argc, argv);
QOpenXRApplication *xrApp = new QOpenXRApplication(nullptr);
qmlRegisterSingletonInstance<QOpenXRApplication>("QtQuick3D.OpenXR", 1, 0, "OpenXR", xrApp);
QQmlEngine *mainQmlEngine = new QQmlEngine();
QQmlComponent *sceneComponent = new QQmlComponent(mainQmlEngine, QUrl("qrc:/xrgears.qml"), QQmlComponent::PreferSynchronous);
xrApp->initialize(mainQmlEngine, sceneComponent);
return a.exec();
}