-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
95 lines (76 loc) · 3.35 KB
/
main.cpp
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
#include "gui/mainwindow.h"
#include "settings/settings.h"
#include <QDir>
#include <QApplication>
#include <QStyleFactory>
#include <cstdlib>
#include <iostream>
#include <cxxopts/cxxopts.hpp>
using namespace std;
int main(int argc, char *argv[]) {
cxxopts::Options options("sph", "SPH fluid simulation");
options.add_options()
("help", "Print help")
("s,scene", "Scene file path", cxxopts::value<std::string>())
("c,config", "Config file path", cxxopts::value<std::string>())
("o,performance_output", "Fps performance output file path", cxxopts::value<std::string>());
try {
options.parse(argc, argv);
if (options.count("help")) {
std::cout << options.help() << std::endl;
return 0;
}
cxxopts::check_required(options, {"scene", "config"});
auto config_filename = options["config"].as<std::string>();
auto scene_filename = options["scene"].as<std::string>();
string profiling_filename = "";
if (options.count("performance_output")) {
profiling_filename = options["performance_output"].as<std::string>();
}
// Create directory for kernels profile
if (!QDir("k_profile").exists()) {
QDir().mkdir("k_profile");
}
// Disable CUDA/OpenCL compiler caching(NVIDIA-only)
setenv("CUDA_CACHE_DISABLE", "1", 1);
// Before initializing Qt Application, settings must be loaded
Settings::load(config_filename, scene_filename);
// Configure the application to use OpenGL 4.5
QSurfaceFormat format;
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapInterval(0); // This turns off vsync
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
QSurfaceFormat::setDefaultFormat(format);
QApplication a(argc, argv);
a.setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::Button, QColor(53,53,53));
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
a.setPalette(darkPalette);
a.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
MainWindow w(profiling_filename);
w.show();
return a.exec();
}
catch(cxxopts::OptionException& e) {
std::cerr << e.what() << std::endl;
std::cerr << options.help() << std::endl;
std::exit(-1);
}
catch(std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::exit(-1);
}
}