| 1 | // Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QGuiApplication> |
| 5 | #include <QQuickView> |
| 6 | #include <QOpenGLContext> |
| 7 | |
| 8 | void setSurfaceFormat() |
| 9 | { |
| 10 | QSurfaceFormat format; |
| 11 | #if QT_CONFIG(opengles2) |
| 12 | format.setRenderableType(QSurfaceFormat::OpenGLES); |
| 13 | #else |
| 14 | if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { |
| 15 | format.setVersion(4, 3); |
| 16 | format.setProfile(QSurfaceFormat::CoreProfile); |
| 17 | } |
| 18 | #endif |
| 19 | format.setDepthBufferSize(24); |
| 20 | format.setSamples(4); |
| 21 | format.setStencilBufferSize(8); |
| 22 | QSurfaceFormat::setDefaultFormat(format); |
| 23 | } |
| 24 | |
| 25 | int main(int argc, char **argv) |
| 26 | { |
| 27 | QGuiApplication app(argc, argv); |
| 28 | setSurfaceFormat(); |
| 29 | |
| 30 | QQuickView view; |
| 31 | |
| 32 | view.resize(1920, 1080); |
| 33 | view.setResizeMode(QQuickView::SizeRootObjectToView); |
| 34 | view.setSource(QUrl("qrc:/main.qml")); |
| 35 | view.show(); |
| 36 | |
| 37 | return app.exec(); |
| 38 | } |