qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include "application.h"
2
3#include <QtQuick/QSGRendererInterface>
4
5#ifndef __APPLE__
6#include <QSurfaceFormat>
7#endif
8
9#include <csignal>
10#include <entryPoint.h>
11
12#include <QMapLibre/Utils>
13
14void SigintCallbackHandler(int signum);
15
16int main(int argc, char *argv[]) {
17 signal(SIGINT, &SigintCallbackHandler);
18 signal(SIGILL, &SigintCallbackHandler);
19 signal(SIGFPE, &SigintCallbackHandler);
20 signal(SIGSEGV, &SigintCallbackHandler);
21 signal(SIGTERM, &SigintCallbackHandler);
22 signal(SIGABRT, &SigintCallbackHandler);
23
24 qputenv("QSG_RENDER_LOOP", "threaded");
25 qputenv("QML_DISK_CACHE", "aot");
26
27 const QMapLibre::RendererType rendererType = QMapLibre::supportedRendererType();
28 const auto graphicsApi = static_cast<QSGRendererInterface::GraphicsApi>(rendererType);
29 QQuickWindow::setGraphicsApi(graphicsApi);
30
31 if (graphicsApi == QSGRendererInterface::OpenGLRhi) {
32 QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
33 QSurfaceFormat format;
34 format.setProfile(QSurfaceFormat::CoreProfile); // Только Core Profile (без устаревшего кода)
35 format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); // Двойная буферизация
36 format.setSwapInterval(0); // Отключение VSync для максимального FPS (если не нужна синхронизация)
37 format.setDepthBufferSize(24); // 24-битный буфер глубины (стандарт)
38 format.setStencilBufferSize(8); // 8-битный буфер трафарета
39 format.setOption(QSurfaceFormat::DeprecatedFunctions, false); // Отключить устаревшие функции
40 format.setOption(QSurfaceFormat::DebugContext, false); // Отключить отладочный контекст (если не нужно)
41 QSurfaceFormat::setDefaultFormat(format);
42 }
43
44 Application app(argc, argv);
45
46 Application::setApplicationDisplayName(app.getApplicationName());
47 Application::setApplicationVersion(app.getApplicationVersion());
48
49 QQuickStyle::setStyle("Universal");
50
51 app.installEventFilter(&app);
52
53 spdlog::info("{} {}", app.getApplicationName().toStdString(), app.getApplicationVersion().toStdString());
54
55 auto entryPoint = new EntryPoint(app.getLoggerName());
56 QObject::connect(&app, &QGuiApplication::aboutToQuit, [entryPoint] { entryPoint->deleteLater(); });
57
58 return Application::exec();
59}
60void SigintCallbackHandler(const int signum) {
61 printf("%s %d", "Приложение остановлено с кодом: ", signum);
62 exit(signum);
63}
Main application class for qHexWalker.
Main application class extending QGuiApplication.
Definition application.h:39
auto getApplicationName() const noexcept
Gets the application name.
Definition application.h:56
auto getApplicationVersion() const noexcept
Gets the application version.
Definition application.h:62
auto getLoggerName() const noexcept
Gets the logger name for spdlog.
Definition application.h:68
Application initialization orchestrator.
Definition entryPoint.h:61
Application entry point and initialization orchestrator.
int main(int argc, char *argv[])
Definition main.cpp:16
void SigintCallbackHandler(int signum)
Definition main.cpp:60