| 1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QGuiApplication> |
| 5 | #include <QQuickView> |
| 6 | |
| 7 | #include <Qt3DRender/qt3drender-config.h> |
| 8 | |
| 9 | |
| 10 | int main(int argc, char **argv) |
| 11 | { |
| 12 | { |
| 13 | // Set OpenGL requirements |
| 14 | QSurfaceFormat format = QSurfaceFormat::defaultFormat(); |
| 15 | #if !QT_CONFIG(opengles2) |
| 16 | format.setVersion(4, 1); |
| 17 | format.setProfile(QSurfaceFormat::CoreProfile); |
| 18 | format.setSamples(4); |
| 19 | #else |
| 20 | format.setVersion(3, 0); |
| 21 | format.setProfile(QSurfaceFormat::NoProfile); |
| 22 | format.setRenderableType(QSurfaceFormat::OpenGLES); |
| 23 | #endif |
| 24 | QSurfaceFormat::setDefaultFormat(format); |
| 25 | } |
| 26 | |
| 27 | #if !QT_CONFIG(qt3d_rhi_renderer) |
| 28 | qputenv("QSG_RHI_BACKEND", "opengl"); |
| 29 | #endif |
| 30 | |
| 31 | QGuiApplication app(argc, argv); |
| 32 | |
| 33 | // Force OpenGL backend |
| 34 | QQuickView view; |
| 35 | |
| 36 | view.resize(1024, 768); |
| 37 | view.setResizeMode(QQuickView::SizeRootObjectToView); |
| 38 | view.setPersistentSceneGraph(true); |
| 39 | view.setSource(QUrl("qrc:/main.qml")); |
| 40 | view.show(); |
| 41 | |
| 42 | return app.exec(); |
| 43 | } |