aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/customrendernode/main.cpp
blob: 5cc870b1aa3b55146710a953c031313dcb4a5efd (plain)
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
44
45
46
47
48
49
50
51
52
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include <QGuiApplication>
#include <QtQuick/QQuickView>
#include <QSurfaceFormat>

int main(int argc, char **argv)
{
#ifdef Q_OS_MACOS
    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
    format.setMajorVersion(4);
    format.setMinorVersion(1);
    format.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(format);
#endif

    QGuiApplication app(argc, argv);

    QQuickView view;

    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl("qrc:///scenegraph/customrendernode/main.qml"));
    view.setColor(QColor(0, 0, 0));
    view.show();

    QString api;
    switch (view.graphicsApi()) {
    case QSGRendererInterface::GraphicsApi::OpenGLRhi:
        api = "RHI OpenGL";
        break;
    case QSGRendererInterface::GraphicsApi::Direct3D11Rhi:
        api = "RHI Direct3D";
        break;
    case QSGRendererInterface::GraphicsApi::VulkanRhi:
        api = "RHI Vulkan";
        break;
    case QSGRendererInterface::GraphicsApi::MetalRhi:
        api = "RHI Metal";
        break;
    case QSGRendererInterface::GraphicsApi::NullRhi:
        api = "RHI Null";
        break;
    default:
        api = "unknown";
        break;
    }

    view.setTitle(QStringLiteral("Custom QSGRenderNode - ") + api);

    return QGuiApplication::exec();
}