From 5294ea7acb86de460e2426a6dac1d281979d0c3b Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 4 Sep 2025 19:16:32 -0700 Subject: Rename isogfx -> gfx2d --- demos/checkerboard/checkerboard.c | 62 +++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'demos/checkerboard') diff --git a/demos/checkerboard/checkerboard.c b/demos/checkerboard/checkerboard.c index 4f43526..467da61 100644 --- a/demos/checkerboard/checkerboard.c +++ b/demos/checkerboard/checkerboard.c @@ -47,21 +47,21 @@ typedef enum Colour { } Colour; typedef struct GfxAppState { - IsoBackend* backend; - IsoGfx* iso; - Tile red; - int xpick; - int ypick; + Gfx2dBackend* backend; + Gfx2d* gfx; + Tile red; + int xpick; + int ypick; } GfxAppState; -static void make_checkerboard(IsoGfx* iso, Tile black, Tile white) { +static void make_checkerboard(Gfx2d* iso, Tile black, Tile white) { assert(iso); - for (int y = 0; y < isogfx_world_height(iso); ++y) { - for (int x = 0; x < isogfx_world_width(iso); ++x) { + for (int y = 0; y < gfx2d_world_height(iso); ++y) { + for (int x = 0; x < gfx2d_world_width(iso); ++x) { const int odd_col = x & 1; const int odd_row = y & 1; const Tile value = (odd_row ^ odd_col) == 0 ? black : white; - isogfx_set_tile(iso, x, y, value); + gfx2d_set_tile(iso, x, y, value); } } } @@ -72,28 +72,28 @@ static bool init(GfxApp* app, GfxAppState* state, int argc, const char** argv) { (void)argc; (void)argv; - if (!((state->iso = - isogfx_new(&(IsoGfxDesc){.memory = MEMORY, - .memory_size = MEMORY_SIZE, - .screen_width = SCREEN_WIDTH, - .screen_height = SCREEN_HEIGHT})))) { + if (!((state->gfx = + gfx2d_new(&(Gfx2dDesc){.memory = MEMORY, + .memory_size = MEMORY_SIZE, + .screen_width = SCREEN_WIDTH, + .screen_height = SCREEN_HEIGHT})))) { return false; } - IsoGfx* iso = state->iso; + Gfx2d* iso = state->gfx; - isogfx_make_map( + gfx2d_make_map( iso, &(MapDesc){.tile_width = TILE_WIDTH, .tile_height = TILE_HEIGHT, .world_width = WORLD_WIDTH, .world_height = WORLD_HEIGHT, .num_tiles = NUM_TILES}); - const Tile black = isogfx_make_tile(iso, &tile_set[Black]); - const Tile white = isogfx_make_tile(iso, &tile_set[White]); - state->red = isogfx_make_tile(iso, &tile_set[Red]); + const Tile black = gfx2d_make_tile(iso, &tile_set[Black]); + const Tile white = gfx2d_make_tile(iso, &tile_set[White]); + state->red = gfx2d_make_tile(iso, &tile_set[Red]); make_checkerboard(iso, black, white); - if (!((state->backend = iso_backend_init(iso)))) { + if (!((state->backend = gfx2d_backend_init(iso)))) { return false; } @@ -104,8 +104,8 @@ static void shutdown(GfxApp* app, GfxAppState* state) { assert(app); assert(state); - iso_backend_shutdown(&state->backend); - isogfx_del(&state->iso); + gfx2d_backend_shutdown(&state->backend); + gfx2d_del(&state->gfx); } static void update(GfxApp* app, GfxAppState* state, double t, double dt) { @@ -113,19 +113,19 @@ static void update(GfxApp* app, GfxAppState* state, double t, double dt) { assert(state); (void)dt; - IsoGfx* iso = state->iso; + Gfx2d* iso = state->gfx; - isogfx_update(iso, t); + gfx2d_update(iso, t); // Get mouse position in window coordinates. double mouse_x, mouse_y; gfx_app_get_mouse_position(app, &mouse_x, &mouse_y); // Map from window coordinates to virtual screen coordinates. - iso_backend_get_mouse_position( + gfx2d_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); + gfx2d_pick_tile(iso, mouse_x, mouse_y, &state->xpick, &state->ypick); printf("Picked tile: (%d, %d)\n", state->xpick, state->ypick); } @@ -134,22 +134,22 @@ static void render(const GfxApp* app, GfxAppState* state) { assert(app); assert(state); - IsoGfx* iso = state->iso; + Gfx2d* iso = state->gfx; - isogfx_render(iso); + gfx2d_render(iso); if ((state->xpick != -1) && (state->ypick != -1)) { - isogfx_draw_tile(iso, state->xpick, state->ypick, state->red); + gfx2d_draw_tile(iso, state->xpick, state->ypick, state->red); } - iso_backend_render(state->backend, iso); + gfx2d_backend_render(state->backend, iso); } static void resize(GfxApp* app, GfxAppState* state, int width, int height) { assert(app); assert(state); - iso_backend_resize_window(state->backend, state->iso, width, height); + gfx2d_backend_resize_window(state->backend, state->gfx, width, height); } int main(int argc, const char** argv) { -- cgit v1.2.3