File: main.cpp

package info (click to toggle)
qt6-quick3d 6.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 140,860 kB
  • sloc: cpp: 380,464; ansic: 36,078; xml: 252; sh: 241; makefile: 29
file content (66 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download | duplicates (2)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include <QApplication>
#include <QQuickView>
#include <QtQuick3D/qquick3d.h>

#include <QVBoxLayout>
#include <QListWidget>
#include <QLabel>
#include <QPushButton>
#include <QDialog>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
    qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
    qputenv("QSG_INFO", "1");

    QDialog sel;
    QVBoxLayout *selLayout = new QVBoxLayout;
    selLayout->addWidget(new QLabel("Select SDR/HDR mode"));
    QListWidget *modeList = new QListWidget;
    modeList->addItem("SDR");
    modeList->addItem("HDR: scRGB (extended linear sRGB + FP16 color buffer)");
    modeList->addItem("HDR: HDR10 Rec.2020 ST2084 + RGB10A2 color buffer\n(will appear incorrect, just for demo)");
    modeList->setCurrentRow(0);
    selLayout->addWidget(modeList);
    QPushButton *okBtn = new QPushButton("Ok");
    okBtn->setDefault(true);
    selLayout->addWidget(okBtn);
    sel.setLayout(selLayout);
    sel.resize(340, 160);
    sel.show();

    std::unique_ptr<QQuickView> view;
    QObject::connect(okBtn, &QPushButton::clicked, [modeList, &sel, &view] {
        switch (modeList->currentRow()) {
        case 0:
            break;
        case 1:
            qputenv("QSG_RHI_HDR", "scrgb");
            break;
        case 2:
            qputenv("QSG_RHI_HDR", "hdr10");
            break;
        default:
            break;
        }

        view.reset(new QQuickView);
        view->setColor(Qt::black);
        view->setResizeMode(QQuickView::SizeRootObjectToView);
        view->resize(1280, 720);
        view->setSource(QUrl("qrc:/main.qml"));
        view->show();

        sel.close();
    });

    int r = app.exec();

    return r;
}