From 1e3fcf5b38d67fb54102786be74af42be5c6792f Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Tue, 3 Jan 2023 08:49:54 -0800 Subject: Initial commit. --- gltfview/src/main.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 gltfview/src/main.c (limited to 'gltfview/src/main.c') diff --git a/gltfview/src/main.c b/gltfview/src/main.c new file mode 100644 index 0000000..f7c372c --- /dev/null +++ b/gltfview/src/main.c @@ -0,0 +1,65 @@ +#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\n"); + 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