From 39ab6c2bce7434e45c3957168278cacf9dcd19f5 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 14 Jul 2025 08:15:24 -0700 Subject: Rename backend functions to snake case --- demos/checkerboard/checkerboard.c | 48 +++++++++++++++++++-------------------- demos/isomap/isomap.c | 35 ++++++++++++++-------------- include/isogfx/backend.h | 13 ++++++----- src/backend.c | 10 ++++---- 4 files changed, 52 insertions(+), 54 deletions(-) diff --git a/demos/checkerboard/checkerboard.c b/demos/checkerboard/checkerboard.c index dbc817c..9d1791e 100644 --- a/demos/checkerboard/checkerboard.c +++ b/demos/checkerboard/checkerboard.c @@ -76,11 +76,10 @@ static bool init(GfxAppState* state, int argc, const char** argv) { isogfx_resize(iso, SCREEN_WIDTH, SCREEN_HEIGHT); if (!isogfx_make_world( - iso, &(WorldDesc){ - .tile_width = TILE_WIDTH, - .tile_height = TILE_HEIGHT, - .world_width = WORLD_WIDTH, - .world_height = WORLD_HEIGHT})) { + iso, &(WorldDesc){.tile_width = TILE_WIDTH, + .tile_height = TILE_HEIGHT, + .world_width = WORLD_WIDTH, + .world_height = WORLD_HEIGHT})) { return false; } @@ -89,7 +88,7 @@ static bool init(GfxAppState* state, int argc, const char** argv) { state->red = isogfx_make_tile(iso, &tile_set[Red]); make_checkerboard(iso, black, white); - if (!(state->backend = IsoBackendInit(iso))) { + if (!(state->backend = iso_backend_init(iso))) { return false; } @@ -99,7 +98,7 @@ static bool init(GfxAppState* state, int argc, const char** argv) { static void shutdown(GfxAppState* state) { assert(state); - IsoBackendShutdown(&state->backend); + iso_backend_shutdown(&state->backend); isogfx_del(&state->iso); } @@ -116,7 +115,7 @@ static void update(GfxAppState* state, double t, double dt) { gfx_app_get_mouse_position(&mouse_x, &mouse_y); // Map from window coordinates to virtual screen coordinates. - IsoBackendGetMousePosition( + iso_backend_get_mouse_position( state->backend, mouse_x, mouse_y, &mouse_x, &mouse_y); isogfx_pick_tile(iso, mouse_x, mouse_y, &state->xpick, &state->ypick); @@ -135,32 +134,31 @@ static void render(GfxAppState* state) { isogfx_draw_tile(iso, state->xpick, state->ypick, state->red); } - IsoBackendRender(state->backend, iso); + iso_backend_render(state->backend, iso); } static void resize(GfxAppState* state, int width, int height) { assert(state); - IsoBackendResizeWindow(state->backend, state->iso, width, height); + iso_backend_resize_window(state->backend, state->iso, width, height); } int main(int argc, const char** argv) { GfxAppState state = {0}; gfx_app_run( - &(GfxAppDesc){ - .argc = argc, - .argv = argv, - .width = WINDOW_WIDTH, - .height = WINDOW_HEIGHT, - .max_fps = MAX_FPS, - .update_delta_time = MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, - .title = "Isometric Renderer", - .app_state = &state}, - &(GfxAppCallbacks){ - .init = init, - .update = update, - .render = render, - .resize = resize, - .shutdown = shutdown}); + &(GfxAppDesc){.argc = argc, + .argv = argv, + .width = WINDOW_WIDTH, + .height = WINDOW_HEIGHT, + .max_fps = MAX_FPS, + .update_delta_time = + MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, + .title = "Isometric Renderer", + .app_state = &state}, + &(GfxAppCallbacks){.init = init, + .update = update, + .render = render, + .resize = resize, + .shutdown = shutdown}); return 0; } diff --git a/demos/isomap/isomap.c b/demos/isomap/isomap.c index a233659..5adf6f1 100644 --- a/demos/isomap/isomap.c +++ b/demos/isomap/isomap.c @@ -49,7 +49,7 @@ static bool init(GfxAppState* state, int argc, const char** argv) { state->stag = isogfx_make_sprite(iso, state->stag_sheet); isogfx_set_sprite_position(iso, state->stag, 5, 4); - if (!(state->backend = IsoBackendInit(iso))) { + if (!(state->backend = iso_backend_init(iso))) { return false; } @@ -74,32 +74,31 @@ static void render(GfxAppState* state) { IsoGfx* iso = state->iso; isogfx_render(iso); - IsoBackendRender(state->backend, iso); + iso_backend_render(state->backend, iso); } static void resize(GfxAppState* state, int width, int height) { assert(state); - IsoBackendResizeWindow(state->backend, state->iso, width, height); + iso_backend_resize_window(state->backend, state->iso, width, height); } int main(int argc, const char** argv) { GfxAppState state = {0}; gfx_app_run( - &(GfxAppDesc){ - .argc = argc, - .argv = argv, - .width = WINDOW_WIDTH, - .height = WINDOW_HEIGHT, - .max_fps = MAX_FPS, - .update_delta_time = MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, - .title = "Isometric Renderer", - .app_state = &state}, - &(GfxAppCallbacks){ - .init = init, - .update = update, - .render = render, - .resize = resize, - .shutdown = shutdown}); + &(GfxAppDesc){.argc = argc, + .argv = argv, + .width = WINDOW_WIDTH, + .height = WINDOW_HEIGHT, + .max_fps = MAX_FPS, + .update_delta_time = + MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, + .title = "Isometric Renderer", + .app_state = &state}, + &(GfxAppCallbacks){.init = init, + .update = update, + .render = render, + .resize = resize, + .shutdown = shutdown}); return 0; } diff --git a/include/isogfx/backend.h b/include/isogfx/backend.h index 172991d..76ee13d 100644 --- a/include/isogfx/backend.h +++ b/include/isogfx/backend.h @@ -8,21 +8,22 @@ typedef struct IsoGfx IsoGfx; typedef struct IsoBackend IsoBackend; /// Initialize the backend. -IsoBackend* IsoBackendInit(const IsoGfx*); +IsoBackend* iso_backend_init(const IsoGfx*); /// Shut down the backend. -void IsoBackendShutdown(IsoBackend**); +void iso_backend_shutdown(IsoBackend**); /// Notify the backend of a window resize event. /// This allows the backend to determine how to position and scale the iso /// screen buffer on the graphics window. -void IsoBackendResizeWindow(IsoBackend*, const IsoGfx*, int width, int height); +void iso_backend_resize_window( + IsoBackend*, const IsoGfx*, int width, int height); /// Render the iso screen to the graphics window. -void IsoBackendRender(const IsoBackend*, const IsoGfx*); +void iso_backend_render(const IsoBackend*, const IsoGfx*); /// Map window coordinates to iso space coordinates. /// This takes into account any possible resizing done by the backend in -/// response to calls to IsoBackendResizeWindow(). -bool IsoBackendGetMousePosition( +/// response to calls to iso_backend_resize_window(). +bool iso_backend_get_mouse_position( const IsoBackend*, double window_x, double window_y, double* x, double* y); diff --git a/src/backend.c b/src/backend.c index f610905..567146f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -31,7 +31,7 @@ typedef struct IsoBackend { // dimensions. } IsoBackend; -IsoBackend* IsoBackendInit(const IsoGfx* iso) { +IsoBackend* iso_backend_init(const IsoGfx* iso) { assert(iso); IsoBackend* backend = calloc(1, sizeof(IsoBackend)); @@ -95,7 +95,7 @@ cleanup: return 0; } -void IsoBackendShutdown(IsoBackend** ppApp) { +void iso_backend_shutdown(IsoBackend** ppApp) { assert(ppApp); IsoBackend* app = *ppApp; @@ -106,7 +106,7 @@ void IsoBackendShutdown(IsoBackend** ppApp) { gfx_destroy(&app->gfx); } -void IsoBackendResizeWindow( +void iso_backend_resize_window( IsoBackend* app, const IsoGfx* iso, int width, int height) { assert(app); assert(iso); @@ -135,7 +135,7 @@ void IsoBackendResizeWindow( } } -void IsoBackendRender(const IsoBackend* app, const IsoGfx* iso) { +void iso_backend_render(const IsoBackend* app, const IsoGfx* iso) { assert(app); assert(iso); @@ -162,7 +162,7 @@ void IsoBackendRender(const IsoBackend* app, const IsoGfx* iso) { gfx_end_frame(gfxcore); } -bool IsoBackendGetMousePosition( +bool iso_backend_get_mouse_position( const IsoBackend* app, double window_x, double window_y, double* x, double* y) { assert(app); -- cgit v1.2.3