summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/qardboard/main.cpp
blob: d6115cee917aaa0d9739553721a8b405a46d73bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <Qt3DQuickExtras/qt3dquickwindow.h>
#include <Qt3DQuick/QQmlAspectEngine>
#include <QGuiApplication>
#include <QQmlEngine>
#include <QQmlContext>

#ifdef Q_OS_IOS
#include "iosdeviceorientation.h"
#else
#include "dummydeviceorientation.h"
#endif

int main(int argc, char* argv[])
{
    QGuiApplication app(argc, argv);

    Qt3DExtras::Quick::Qt3DQuickWindow view;

#ifdef Q_OS_IOS
    qmlRegisterType<iOSDeviceOrientation>("Qardboard", 1, 0, "DeviceOrientation");
#else
    qmlRegisterType<DummyDeviceOrientation>("Qardboard", 1, 0, "DeviceOrientation");
#endif

    view.engine()->qmlEngine()->rootContext()->setContextProperty(QStringLiteral("_window"), &view);
    view.setSource(QUrl("qrc:/main.qml"));
#ifdef Q_OS_IOS
    view.showFullScreen();
#else
    view.resize(800, 400);
    view.show();
#endif

    return app.exec();
}