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 --- include/isogfx/backend.h | 29 +++++++++++++------------- include/isogfx/gfx2d.h | 54 ++++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/isogfx/backend.h b/include/isogfx/backend.h index 76ee13d..86afed5 100644 --- a/include/isogfx/backend.h +++ b/include/isogfx/backend.h @@ -2,28 +2,29 @@ #include -typedef struct Gfx Gfx; -typedef struct IsoGfx IsoGfx; +typedef struct Gfx Gfx; +typedef struct Gfx2d Gfx2d; -typedef struct IsoBackend IsoBackend; +typedef struct Gfx2dBackend Gfx2dBackend; /// Initialize the backend. -IsoBackend* iso_backend_init(const IsoGfx*); +Gfx2dBackend* gfx2d_backend_init(const Gfx2d*); /// Shut down the backend. -void iso_backend_shutdown(IsoBackend**); +void gfx2d_backend_shutdown(Gfx2dBackend**); /// Notify the backend of a window resize event. -/// This allows the backend to determine how to position and scale the iso +/// This allows the backend to determine how to position and scale the gfx /// screen buffer on the graphics window. -void iso_backend_resize_window( - IsoBackend*, const IsoGfx*, int width, int height); +void gfx2d_backend_resize_window( + Gfx2dBackend*, const Gfx2d*, int width, int height); -/// Render the iso screen to the graphics window. -void iso_backend_render(const IsoBackend*, const IsoGfx*); +/// Render the gfx screen to the graphics window. +void gfx2d_backend_render(const Gfx2dBackend*, const Gfx2d*); -/// Map window coordinates to iso space coordinates. +/// Map window coordinates to gfx space coordinates. /// This takes into account any possible resizing done by the backend in -/// 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); +/// response to calls to gfx2d_backend_resize_window(). +bool gfx2d_backend_get_mouse_position( + const Gfx2dBackend*, double window_x, double window_y, double* x, + double* y); diff --git a/include/isogfx/gfx2d.h b/include/isogfx/gfx2d.h index 323b389..59566f3 100644 --- a/include/isogfx/gfx2d.h +++ b/include/isogfx/gfx2d.h @@ -8,7 +8,7 @@ #include #include -typedef struct IsoGfx IsoGfx; +typedef struct Gfx2d Gfx2d; /// Sprite sheet handle. typedef uintptr_t SpriteSheet; @@ -50,43 +50,43 @@ typedef struct IsoGfxDesc { size_t memory_size; // Size of memory block in bytes. int screen_width; // Screen width in pixels. int screen_height; // Screen height in pixels. -} IsoGfxDesc; +} Gfx2dDesc; /// Create a new isometric graphics engine. -IsoGfx* isogfx_new(const IsoGfxDesc*); +Gfx2d* gfx2d_new(const Gfx2dDesc*); /// Destroy the isometric graphics engine. -void isogfx_del(IsoGfx**); +void gfx2d_del(Gfx2d**); /// Clear all loaded worlds and sprites. -void isogfx_clear(IsoGfx*); +void gfx2d_clear(Gfx2d*); /// Create an empty map. -void isogfx_make_map(IsoGfx*, const MapDesc*); +void gfx2d_make_map(Gfx2d*, const MapDesc*); /// Load a tile map (.TM) file. -bool isogfx_load_map(IsoGfx*, const char* filepath); +bool gfx2d_load_map(Gfx2d*, const char* filepath); /// Return the world's width. -int isogfx_world_width(const IsoGfx*); +int gfx2d_world_width(const Gfx2d*); /// Return the world's height. -int isogfx_world_height(const IsoGfx*); +int gfx2d_world_height(const Gfx2d*); /// Create a new tile. -Tile isogfx_make_tile(IsoGfx*, const TileDesc*); +Tile gfx2d_make_tile(Gfx2d*, const TileDesc*); /// Set the tile at position (x,y). -void isogfx_set_tile(IsoGfx*, int x, int y, Tile); +void gfx2d_set_tile(Gfx2d*, int x, int y, Tile); /// Set the tiles in positions in the range (x0,y0) - (x1,y1). -void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); +void gfx2d_set_tiles(Gfx2d*, int x0, int y0, int x1, int y1, Tile); /// Load a sprite sheet (.SS) file. -SpriteSheet isogfx_load_sprite_sheet(IsoGfx*, const char* filepath); +SpriteSheet gfx2d_load_sprite_sheet(Gfx2d*, const char* filepath); /// Create an animated sprite. -Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); +Sprite gfx2d_make_sprite(Gfx2d*, SpriteSheet); // TODO: Add a function to delete a sprite. Making the caller manage and re-use // sprites is a shitty API. @@ -94,41 +94,41 @@ Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); // list of sprites so that we can re-use the ones that have been "freed". /// Set the sprite's position. -void isogfx_set_sprite_position(IsoGfx*, Sprite, int x, int y); +void gfx2d_set_sprite_position(Gfx2d*, Sprite, int x, int y); /// Set the sprite's current animation. -void isogfx_set_sprite_animation(IsoGfx*, Sprite, int animation); +void gfx2d_set_sprite_animation(Gfx2d*, Sprite, int animation); /// Update the renderer. /// /// Currently, this updates the sprite animations. -void isogfx_update(IsoGfx*, double t); +void gfx2d_update(Gfx2d*, double t); // TODO: Do we really need to store the camera in the library? It's not used // for anything other than to render, so we could remove library state and // take a camera argument in render() instead. /// Set the camera. -void isogfx_set_camera(IsoGfx*, int x, int y); +void gfx2d_set_camera(Gfx2d*, int x, int y); /// Render the world. -void isogfx_render(IsoGfx*); +void gfx2d_render(Gfx2d*); /// Draw/overlay a tile at position (x,y). /// /// This function just renders a tile at position (x,y) and should be called -/// after isogfx_render() to obtain the correct result. To set the tile at -/// position (x,y) instead, use isogfx_set_tile(). -void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); +/// after gfx2d_render() to obtain the correct result. To set the tile at +/// position (x,y) instead, use gfx2d_set_tile(). +void gfx2d_draw_tile(Gfx2d*, int x, int y, Tile); /// Get the virtual screen's dimensions. -void isogfx_get_screen_size(const IsoGfx*, int* width, int* height); +void gfx2d_get_screen_size(const Gfx2d*, int* width, int* height); /// Return a pointer to the virtual screen's colour buffer. /// -/// Call after each call to isogfx_render() to retrieve the render output. -const Pixel* isogfx_get_screen_buffer(const IsoGfx*); +/// Call after each call to gfx2d_render() to retrieve the render output. +const Pixel* gfx2d_get_screen_buffer(const Gfx2d*); /// Translate Cartesian to isometric coordinates. -void isogfx_pick_tile( - const IsoGfx*, double xcart, double ycart, int* xiso, int* yiso); +void gfx2d_pick_tile( + const Gfx2d*, double xcart, double ycart, int* xiso, int* yiso); -- cgit v1.2.3