-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
69 lines (58 loc) · 2.16 KB
/
main.cpp
File metadata and controls
69 lines (58 loc) · 2.16 KB
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
67
68
69
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2025 Hossein Assaran
**
** This file is part of VulkanImageViewer.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
**
** This file was modified from an example of the Qt Toolkit.
** Original copyright notice and BSD license terms are preserved above.
**
****************************************************************************/
#include <QGuiApplication>
#include <QApplication>
#include <QVulkanInstance>
#include <QLoggingCategory>
#include <QFileDialog>
#include "vulkanimageviewer.h"
Q_LOGGING_CATEGORY(lcVk, "qt.vulkan")
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString fileName = QFileDialog::getOpenFileName(
nullptr,
"Open File",
"",
"Images (*.png *.jpg *.bmp);;All Files (*)"
);
if (!fileName.isEmpty()) {
qDebug() << "Selected file:" << fileName;
} else {
qDebug() << "No file selected.";
}
QLoggingCategory::setFilterRules(QStringLiteral("qt.vulkan=true"));
QVulkanInstance inst;
inst.setLayers({ "VK_LAYER_KHRONOS_validation" });
if (!inst.create())
qFatal("Failed to create Vulkan instance: %d", inst.errorCode());
VulkanWindow w(fileName);
w.setVulkanInstance(&inst);
if (QCoreApplication::arguments().contains(QStringLiteral("--srgb")))
w.setPreferredColorFormats(QList<VkFormat>() << VK_FORMAT_B8G8R8A8_SRGB);
w.resize(1024, 768);
w.show();
return app.exec();
}