Kuesa Car-Scene QML Example
#include <qtkuesa-config.h>
#include <QGuiApplication>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QQuickStyle>
#include <Kuesa/kuesa_global.h>
#ifdef Q_OS_ANDROID
#include <QOpenGLContext>
#endif
int main(int ac, char **av)
{
Kuesa::setupDefaultSurfaceFormat();
bool isES2 = false;
#if defined(KUESA_OPENGL_ES_2) && !defined (KUESA_OPENGL_ES_3)
isES2 = true;
#endif
QQuickStyle::setStyle("Material");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(ac, av);
QCommandLineParser parser;
parser.setApplicationDescription("KDAB Kuesa Demo");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption cursorDisableOption(QStringList() << "no-cursor"
<< "cursor visibility",
"Make sure no pointer is hidden.");
parser.addOption(cursorDisableOption);
QCommandLineOption fullscreenOption(QStringList() << "fullscreen"
<< "Fullscreen option",
"Open the demo in fullscreen");
parser.addOption(fullscreenOption);
QCommandLineOption heightScaleOption(QStringList() << "screenHeightScale"
<< "Height Scale UI",
"Scale UI based on screen height rather than DPI (default on iOS and Android)");
parser.addOption(heightScaleOption);
parser.process(app);
if (parser.isSet(cursorDisableOption))
app.setOverrideCursor(QCursor(Qt::BlankCursor));
QQuickView view;
#ifdef Q_OS_ANDROID
QOpenGLContext ctx;
ctx.setFormat(QSurfaceFormat::defaultFormat());
if (ctx.create()) {
const QSurfaceFormat androidFormat = ctx.format();
isES2 = (androidFormat.majorVersion() == 2);
}
#endif
#if defined(KUESA_DRACO_COMPRESSION)
const QString modelSuffix = QStringLiteral("-draco");
#else
const QString modelSuffix = QStringLiteral("");
#endif
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
bool screenHeightScale = true;
#else
bool screenHeightScale = parser.isSet(heightScaleOption);
#endif
#ifdef KUESA_BUILD_ROOT
view.engine()->addImportPath(QStringLiteral(KUESA_BUILD_ROOT "/qml"));
#endif
view.engine()->rootContext()->setContextProperty(QStringLiteral("_isES2"), isES2);
view.engine()->rootContext()->setContextProperty(QStringLiteral("_view"), &view);
view.engine()->rootContext()->setContextProperty(QStringLiteral("_screenHeightScale"), screenHeightScale);
view.engine()->rootContext()->setContextProperty(QStringLiteral("_isFullScreen"), parser.isSet(fullscreenOption));
view.engine()->rootContext()->setContextProperty(QStringLiteral("_modelSuffix"), modelSuffix);
#ifdef Q_OS_IOS
view.setFlags(view.flags() | Qt::MaximizeUsingFullscreenGeometryHint);
#endif
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl(QStringLiteral("qrc:/main.qml")));
view.resize(1920, 1080);
if (parser.isSet(fullscreenOption)) {
view.showFullScreen();
} else {
view.show();
}
return app.exec();
}