main.cpp 1.31 KB
Newer Older
Teemu Tamminen's avatar
Teemu Tamminen committed
1 2
#include <QGuiApplication>
#include <QQmlApplicationEngine>
Tomi Korpipää's avatar
Tomi Korpipää committed
3
#include <QtGui/QSurfaceFormat>
Teemu Tamminen's avatar
Teemu Tamminen committed
4 5 6

int main(int argc, char *argv[])
{
Tomi Korpipää's avatar
Tomi Korpipää committed
7
#if 0 // For B2Qt and QNX
Teemu Tamminen's avatar
Teemu Tamminen committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    qputenv("QT_QPA_EGLFS_HIDECURSOR", "1");
    qputenv("QT_QPA_EGLFS_DISABLE_INPUT", "1");
    qputenv("QT_QPA_EGLFS_WIDTH", "1280");
    qputenv("QT_QPA_EGLFS_HEIGHT", "480");
    qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", "293");
    qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", "110");
    qputenv("QSG_RENDER_LOOP", "threaded");

    // Debugging
//    qputenv("QT_QPA_EGLFS_DEBUG", "1");
//    qputenv("QSG_INFO", "1");
//    qputenv("QT_LOGGING_RULES", "qt.qpa.*=true");

    // Disable all extra logging
    qputenv("QT_LOGGING_RULES", "*=false");

//    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Tomi Korpipää's avatar
Tomi Korpipää committed
25
#endif
Teemu Tamminen's avatar
Teemu Tamminen committed
26 27 28

    QGuiApplication app(argc, argv);

Tomi Korpipää's avatar
Tomi Korpipää committed
29 30 31 32 33 34 35 36 37 38
#if defined(Q_OS_MACOS)
    QSurfaceFormat openGLFormat;
    openGLFormat.setRenderableType(QSurfaceFormat::OpenGL);
    openGLFormat.setProfile(QSurfaceFormat::CoreProfile);
    openGLFormat.setMajorVersion(4);
    openGLFormat.setMinorVersion(1);
    openGLFormat.setStencilBufferSize(8);
    QSurfaceFormat::setDefaultFormat(openGLFormat);
#endif

Teemu Tamminen's avatar
Teemu Tamminen committed
39 40 41 42 43 44 45
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}