-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
89 lines (73 loc) · 2.58 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
// Copyright (C) 2021 Piotr (Peter) Beben <pdbcas2@gmail.com>
// See LICENSE included with this distribution.
#include "GLWidget.h"
#include "MainWindow.h"
#include "constants.h"
#include <Eigen/Dense>
#include <QApplication>
#include <QDesktopWidget>
#include <QSurfaceFormat>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QTextBlock>
#include <QTextCursor>
#include <cstdlib>
#include <iostream>
void out_of_mem_handler();
int main(int argc, char *argv[])
{
srand(2);
std::set_new_handler(out_of_mem_handler);
Eigen::initParallel();
qRegisterMetaType<size_t>("size_t");
qRegisterMetaType<QTextBlock>("QTextBlock");
qRegisterMetaType<QTextCursor>("QTextCursor");
qRegisterMetaType<std::function<float(float xu, float xv)>>(
"std::function<float(float xu, float xv)>");
QCoreApplication::setApplicationName("SurfMeshSmooth");
QCoreApplication::setOrganizationName("Piotr Beben");
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCoreApplication::addLibraryPath("./");
QApplication app(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::applicationName());
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption multipleSampleOption("multisample", "Multisampling");
parser.addOption(multipleSampleOption);
QCommandLineOption coreProfileOption("coreprofile", "Use core profile");
parser.addOption(coreProfileOption);
QCommandLineOption transparentOption("transparent", "Transparent window");
parser.addOption(transparentOption);
parser.process(app);
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
if (parser.isSet(multipleSampleOption))
fmt.setSamples(4);
if (parser.isSet(coreProfileOption)) {
fmt.setVersion(3, 2);
fmt.setProfile(QSurfaceFormat::CoreProfile);
}
QSurfaceFormat::setDefaultFormat(fmt);
MainWindow mainWindow;
GLWidget::setTransparent(parser.isSet(transparentOption));
if (GLWidget::isTransparent()) {
mainWindow.setAttribute(Qt::WA_TranslucentBackground);
mainWindow.setAttribute(Qt::WA_NoSystemBackground, false);
}
mainWindow.resize(mainWindow.sizeHint());
// int desktopArea = QApplication::desktop()->width() *
// QApplication::desktop()->height();
// int widgetArea = mainWindow.width() * mainWindow.height();
// if (((float)widgetArea / (float)desktopArea) < 0.75f)
// mainWindow.show();
// else
// mainWindow.showMaximized();
mainWindow.showMaximized();
return app.exec();
}
void out_of_mem_handler()
{
std::cerr << "Unable to allocate memory.\n";
std::abort();
}