-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
109 lines (80 loc) · 2.12 KB
/
Copy pathmain.cpp
File metadata and controls
109 lines (80 loc) · 2.12 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "mainwindow.h"
#include <QApplication>
#include <QDir>
#include <fenv.h>
#if 0
#include <QDir>
#include "path.h"
#include <QFileSystemWatcher>
#include <QProcess>
class FileShader
{
QString filepath_source;
QString filepath_spv;
public:
FileShader(const QString &filepath_source, const QString &filepath_spv)
{
this->filepath_source = filepath_source;
this->filepath_spv = filepath_spv;
}
QString source()
{
return filepath_source;
}
QString spv()
{
return filepath_spv;
}
};
class DynamicChangeShaderCompiller : public QObject
{
QFileSystemWatcher fileWatcher;
QHash<QString, FileShader*> hash;
void fileChanged(const QString &path)
{
//qDebug() << "fileChanged" << path;
FileShader *fileShader = hash[path];
if (fileShader == nullptr)
return;
QStringList arguments;
arguments << "-V";
arguments << fileShader->source();
arguments << "-o";
arguments << fileShader->spv();
QProcess::execute("glslangValidator", arguments);
fileWatcher.addPath(path);
}
void add(const QString &source, const QString &spriv)
{
if (spriv.endsWith(".vert") || spriv.endsWith(".frag"))
{
qDebug("error DynamicChangeShaderCompiller::add");
return;
}
QDir dir(path::getShaders() + "../" + source);
QString path_source = dir.absolutePath();
hash[path_source] = new FileShader(path_source, path::getShaders() + spriv);
fileWatcher.addPath(path_source);
}
public:
DynamicChangeShaderCompiller()
{
add("PaintVertex.vert", "PaintVertex.spv");
add("AnimatedPaintFragment.frag", "AnimatedPaintFragment.spv");
QObject::connect(&fileWatcher, &QFileSystemWatcher::fileChanged, this, &DynamicChangeShaderCompiller::fileChanged);
}
};
#endif
int main(int argc, char *argv[])
{
//feenableexcept(FE_INVALID);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
#endif
QApplication a(argc, argv);
QDir::setCurrent(a.applicationDirPath());
MainWindow w;
w.show();
//DynamicChangeShaderCompiller dynamicChangeShaderCompiller;
return a.exec();
}