-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
40 lines (34 loc) · 1.07 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
#include "Game.h"
#include "common/SignalHandler.h"
#include "common/assertions.h"
#include "common/debug.h"
#include "engine/GlfwContext.h"
#include "engine/Window.h"
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <exception>
auto main(int argc, char** argv) -> int {
using namespace game;
engine::GlfwContext glfw_context;
common::SignalHandler signal_handler;
try {
engine::Window window({
.title = "Moonlander 2.5D",
.window_size = {.width = 1024, .height = 768},
.resizable = false,
});
signal_handler.register_listener([&window](auto signal) -> void { window.close(); }, {SIGINT, SIGTERM});
Game game{window};
game.initialize();
game.loop();
} catch (std::exception& e) {
std::fprintf(stderr, "ERROR: %s\n", e.what());
std::exit(1);
}
// trying to free OpenGL objects after the GLFW context has been destroyed
// causes core dump
engine::OpenGlObjectManager::instance().free_all();
dbgln("Exiting program");
return 0;
}