| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "tessellatedquadmesh.h" |
| 5 | #include <Qt3DQuickExtras/qt3dquickwindow.h> |
| 6 | #include <Qt3DQuick/QQmlAspectEngine> |
| 7 | #include <QGuiApplication> |
| 8 | #include <qqml.h> |
| 9 | #include <QQmlContext> |
| 10 | #include <QQmlEngine> |
| 11 | |
| 12 | int main(int argc, char* argv[]) |
| 13 | { |
| 14 | QGuiApplication app(argc, argv); |
| 15 | |
| 16 | Qt3DExtras::Quick::Qt3DQuickWindow view; |
| 17 | // Register our custom types |
| 18 | qmlRegisterType<TessellatedQuadMesh>("Qt3D.Examples", 1, 0, "TessellatedQuadMesh"); |
| 19 | |
| 20 | // Expose the window as a context property so we can set the aspect ratio |
| 21 | view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); |
| 22 | |
| 23 | // There should be some synchronising mechanism to make sure |
| 24 | // the source is set after all aspects have been completely initialized |
| 25 | // Otherwise we might encounter cases where an Aspect's QML elements have |
| 26 | // not yet been registered |
| 27 | view.setSource(QUrl("qrc:/main.qml")); |
| 28 | view.show(); |
| 29 | |
| 30 | return app.exec(); |
| 31 | } |