summaryrefslogtreecommitdiff
path: root/gltfview/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'gltfview/src/main.c')
-rw-r--r--gltfview/src/main.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/gltfview/src/main.c b/gltfview/src/main.c
deleted file mode 100644
index f4863b4..0000000
--- a/gltfview/src/main.c
+++ /dev/null
@@ -1,67 +0,0 @@
1#include "game.h"
2
3#include <gfx/gfx_app.h>
4#include <log/log.h>
5
6#include <stdlib.h>
7
8static bool init(const GfxAppDesc* desc, void** app_state) {
9 Game* game = calloc(1, sizeof(Game));
10 if (!game) {
11 LOGE("Failed to allocate game state");
12 return false;
13 }
14 if (!game_new(game, desc->argc, desc->argv)) {
15 LOGE("Failed to initialize game");
16 return false;
17 }
18 *app_state = game;
19 return true;
20}
21
22static void shutdown(void* app_state) {
23 assert(app_state);
24 Game* game = (Game*)(app_state);
25 game_end(game);
26}
27
28static void update(void* app_state, double t, double dt) {
29 assert(app_state);
30 Game* game = (Game*)(app_state);
31 game_update(game, t, dt);
32}
33
34static void render(void* app_state) {
35 assert(app_state);
36 Game* game = (Game*)(app_state);
37 game_render(game);
38}
39
40static void resize(void* app_state, int width, int height) {
41 assert(app_state);
42 Game* game = (Game*)(app_state);
43 game_set_viewport(game, width, height);
44}
45
46int main(int argc, const char** argv) {
47 const int initial_width = 1350;
48 const int initial_height = 900;
49 const int max_fps = 60;
50
51 gfx_app_run(
52 &(GfxAppDesc){
53 .argc = argc,
54 .argv = argv,
55 .width = initial_width,
56 .height = initial_height,
57 .max_fps = max_fps,
58 .update_delta_time = max_fps > 0 ? 1.0 / (double)max_fps : 0.0},
59 &(GfxAppCallbacks){
60 .init = init,
61 .update = update,
62 .render = render,
63 .resize = resize,
64 .shutdown = shutdown});
65
66 return 0;
67}