From adbd2511beec8f1caa1752bdfd755cc2f62ba425 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 9 Mar 2024 08:43:26 -0800 Subject: Make isogfx a library instead of an executable. --- game/src/game.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'game/src') diff --git a/game/src/game.c b/game/src/game.c index c720656..dc4ab84 100644 --- a/game/src/game.c +++ b/game/src/game.c @@ -39,6 +39,10 @@ static const int WIDTH = 1350; static const int HEIGHT = 900; static const int MAX_FPS = 60; +typedef struct GfxAppState { + Game game; +} GfxAppState; + /// Initialize the game's plugin. static bool init_plugin(Game* game) { assert(game); @@ -113,17 +117,11 @@ static void resize_plugin(Game* game, int width, int height) { void app_end(Game* game); -bool app_init(const GfxAppDesc* desc, void** app_state) { - assert(desc); - - if (desc->argc <= 1) { - LOGE("Usage: %s [plugin args]", desc->argv[0]); - return false; - } +bool app_init(Game* game, int argc, const char** argv) { + assert(game); - Game* game = calloc(1, sizeof(Game)); - if (!game) { - LOGE("Failed to allocate game state"); + if (argc <= 1) { + LOGE("Usage: %s [plugin args]", argv[0]); return false; } @@ -131,8 +129,8 @@ bool app_init(const GfxAppDesc* desc, void** app_state) { // // Here we consume the arg so that plugins receive the remainder // args starting from 0. - game->argc = desc->argc - 1; - game->argv = desc->argv + 1; + game->argc = argc - 1; + game->argv = argv + 1; char exe_path_buf[NAME_MAX] = {0}; if (readlink("/proc/self/exe", exe_path_buf, sizeof(exe_path_buf)) == -1) { @@ -152,7 +150,7 @@ bool app_init(const GfxAppDesc* desc, void** app_state) { goto cleanup; } - const char* plugin = desc->argv[1]; + const char* plugin = argv[1]; if (!(game->plugin = load_plugin(game->plugin_engine, plugin))) { goto cleanup; } @@ -168,7 +166,6 @@ bool app_init(const GfxAppDesc* desc, void** app_state) { goto cleanup; } - *app_state = game; return true; cleanup: @@ -223,4 +220,4 @@ void app_resize(Game* game, int width, int height) { resize_plugin(game, width, height); } -GFX_APP_MAIN(WIDTH, HEIGHT, MAX_FPS); +GFX_APP_MAIN(WIDTH, HEIGHT, MAX_FPS, "Game"); -- cgit v1.2.3