From fc883e0b0449509ba2e1c5d14d187feee098ab34 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 18 Jan 2024 19:33:18 -0800 Subject: Simplify game callbacks. --- gltfview/src/main.c | 67 ----------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 gltfview/src/main.c (limited to 'gltfview/src/main.c') 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 @@ -#include "game.h" - -#include -#include - -#include - -static bool init(const GfxAppDesc* desc, void** app_state) { - Game* game = calloc(1, sizeof(Game)); - if (!game) { - LOGE("Failed to allocate game state"); - return false; - } - if (!game_new(game, desc->argc, desc->argv)) { - LOGE("Failed to initialize game"); - return false; - } - *app_state = game; - return true; -} - -static void shutdown(void* app_state) { - assert(app_state); - Game* game = (Game*)(app_state); - game_end(game); -} - -static void update(void* app_state, double t, double dt) { - assert(app_state); - Game* game = (Game*)(app_state); - game_update(game, t, dt); -} - -static void render(void* app_state) { - assert(app_state); - Game* game = (Game*)(app_state); - game_render(game); -} - -static void resize(void* app_state, int width, int height) { - assert(app_state); - Game* game = (Game*)(app_state); - game_set_viewport(game, width, height); -} - -int main(int argc, const char** argv) { - const int initial_width = 1350; - const int initial_height = 900; - const int max_fps = 60; - - gfx_app_run( - &(GfxAppDesc){ - .argc = argc, - .argv = argv, - .width = initial_width, - .height = initial_height, - .max_fps = max_fps, - .update_delta_time = max_fps > 0 ? 1.0 / (double)max_fps : 0.0}, - &(GfxAppCallbacks){ - .init = init, - .update = update, - .render = render, - .resize = resize, - .shutdown = shutdown}); - - return 0; -} -- cgit v1.2.3