]> git.bts.cx Git - benzene.git/blob - src_platform/sdl/main.c
Sprites
[benzene.git] / src_platform / sdl / main.c
1 #include <SDL.h>
2
3 #include <bz/debug/log_internal.h>
4 #include <bz/debug/perfgraph_internal.h>
5 #include <bz/game/scene_internal.h>
6 #include <bz/input/input_internal.h>
7 #include <bz/input/platform.h>
8 #include <bz/renderer/renderer.h>
9 #include <bz/resources/file_system_internal.h>
10
11 extern void bzpGameLaunch(void);
12 extern void bzpGameInit(void);
13 extern bool bzpGameTick(void);
14 extern void bzpGameTeardown(void);
15
16 int main(int argc, char *argv[]) {
17         int returnCode = 0;
18
19         bzpGameLaunch();
20
21         gSystemTicksPerSecond = 60;
22
23         SDL_Init(SDL_INIT_EVERYTHING);
24         bzFileSystemInit(argv[0], SDL_GetBasePath());
25         bzInputInit();
26
27         bzpGameInit();
28
29         //uint64_t targetUpdateTime = 1000 / 60;
30         //uint64_t nextUpdateTicks = 0;
31
32         for (;;) {
33 //              bzInputProcessFrame();
34
35                 // FIXME, input stuff...
36
37                 //uint64_t ticks = SDL_GetTicks64();
38
39                 //if (ticks >= nextUpdateTicks) {
40                 //      nextUpdateTicks = ticks + targetUpdateTime;
41                         bzPerfReset();
42                         if (bzpGameTick() == false) goto game_loop_exit; // FIXME
43                         if (bzInputGetBooleanValue(bzQuitInputID)) goto game_loop_exit; // FIXME
44                 //}
45         }
46 game_loop_exit:
47
48         bzpGameTeardown();
49         bzInputTeardown();
50         bzFileSystemTeardown();
51         bzLogTeardown();
52         SDL_Quit();
53         
54         return returnCode;
55 }