| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <Qt3DQuickExtras/qt3dquickwindow.h> |
| 5 | #include <Qt3DQuick/QQmlAspectEngine> |
| 6 | #include <QGuiApplication> |
| 7 | #include <QQmlEngine> |
| 8 | #include <QQmlContext> |
| 9 | |
| 10 | int main(int argc, char* argv[]) |
| 11 | { |
| 12 | // Force Qt3D OpenGL renderer |
| 13 | qputenv("QT3D_RENDERER", "opengl"); |
| 14 | |
| 15 | QGuiApplication app(argc, argv); |
| 16 | Qt3DExtras::Quick::Qt3DQuickWindow view; |
| 17 | |
| 18 | // Expose the window as a context property so we can set the aspect ratio |
| 19 | view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); |
| 20 | view.setSource(QUrl("qrc:/main.qml")); |
| 21 | view.show(); |
| 22 | |
| 23 | return app.exec(); |
| 24 | } |