File: main.cpp

package info (click to toggle)
qt6-3d 6.4.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 219,572 kB
  • sloc: cpp: 444,068; cobol: 65,664; ansic: 41,133; xml: 10,866; python: 9,582; asm: 3,071; java: 2,303; ada: 1,681; pascal: 1,405; cs: 879; sh: 478; objc: 382; makefile: 337; javascript: 207
file content (43 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QGuiApplication>
#include <QQuickView>

#include <Qt3DRender/qt3drender-config.h>


int main(int argc, char **argv)
{
    {
        // Set OpenGL requirements
        QSurfaceFormat format = QSurfaceFormat::defaultFormat();
#if !QT_CONFIG(opengles2)
        format.setVersion(4, 1);
        format.setProfile(QSurfaceFormat::CoreProfile);
        format.setSamples(4);
#else
        format.setVersion(3, 0);
        format.setProfile(QSurfaceFormat::NoProfile);
        format.setRenderableType(QSurfaceFormat::OpenGLES);
#endif
        QSurfaceFormat::setDefaultFormat(format);
    }

#if !QT_CONFIG(qt3d_rhi_renderer)
    qputenv("QSG_RHI_BACKEND", "opengl");
#endif

    QGuiApplication app(argc, argv);

    // Force OpenGL backend
    QQuickView view;

    view.resize(1024, 768);
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setPersistentSceneGraph(true);
    view.setSource(QUrl("qrc:/main.qml"));
    view.show();

    return app.exec();
}