-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
63 lines (49 loc) · 1.43 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
#include <libDan2.h>
#include <class/kernel.h>
#include "class/dfwimpl/app_config.h"
#include "class/dfwimpl/state_driver.h"
#include <log.h>
//Global log. Bad practice, but useful.
tools::log LOG;
int main(int argc, char ** argv)
{
using namespace app;
//Init global log.
LOG.init("logs/global.log");
LOG.activate();
//Init libdansdl2 log.
ldt::log_lsdl::init("logs/libdansdl2.log");
//Argument controller.
tools::arg_manager carg(argc, argv);
//Init application log.
tools::log log_app("logs/app.log");
log_app<<"starting main process..."<<std::endl;
//Init...
try {
log_app<<"init sdl2..."<<std::endl;
if(!ldt::sdl_init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK)) {
throw std::runtime_error("unable to init sdl2");
}
log_app<<"creating kernel..."<<std::endl;
dfw::kernel kernel(log_app, carg);
log_app<<"init app config..."<<std::endl;
app_config config;
log_app<<"create state driver..."<<std::endl;
state_driver sd(kernel, config);
log_app<<"init state driver..."<<std::endl;
sd.init(kernel);
log_app<<"finish main proccess"<<std::endl;
}
catch(std::exception& e) {
std::cout<<"Interrupting due to exception: "<<e.what()<<std::endl;
log_app<<"an error happened "<<e.what()<<std::endl;
log_app<<"stopping sdl2..."<<std::endl;
ldt::sdl_shutdown();
ldt::log_lsdl::end();
return 1;
}
log_app<<"stopping sdl2..."<<std::endl;
ldt::sdl_shutdown();
ldt::log_lsdl::end();
return 0;
}