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