-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cpp
87 lines (72 loc) · 1.49 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
#include "Application.h"
#include "Globals.h"
#include "MemLeaks.h"
#include "SDL/include/SDL.h"
#pragma comment( lib, "SDL/libx86/SDL2.lib" )
#pragma comment( lib, "SDL/libx86/SDL2main.lib" )
enum main_states
{
MAIN_CREATION,
MAIN_START,
MAIN_UPDATE,
MAIN_FINISH,
MAIN_EXIT
};
Application* App = nullptr;
int main(int argc, char* argv[])
{
ReportMemoryLeaks();
int main_return = EXIT_FAILURE;
main_states state = MAIN_CREATION;
while (state != MAIN_EXIT)
{
switch (state)
{
case MAIN_CREATION:
{
LOG("Application Creation --------------");
App = new Application();
state = MAIN_START;
} break;
case MAIN_START:
{
LOG("Application Init --------------");
if(App->Init() == false)
{
LOG("Application Init exits with error -----");
state = MAIN_EXIT;
}
else
{
state = MAIN_UPDATE;
LOG("Application Update --------------");
}
} break;
case MAIN_UPDATE:
{
int update_return = App->Update();
if (update_return == UPDATE_ERROR)
{
LOG("Application Update exits with error -----");
state = MAIN_EXIT;
} else if (update_return == UPDATE_STOP)
state = MAIN_FINISH;
}
break;
case MAIN_FINISH:
{
LOG("Application CleanUp --------------");
if(App->CleanUp() == false)
{
LOG("Application CleanUp exits with error -----");
}
else
main_return = EXIT_SUCCESS;
state = MAIN_EXIT;
} break;
}
}
delete App;
LOG("Bye :)\n");
return main_return;
}