diff options
| author | 3gg <3gg@shellblade.net> | 2025-09-04 19:16:32 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-09-04 19:16:32 -0700 |
| commit | 5294ea7acb86de460e2426a6dac1d281979d0c3b (patch) | |
| tree | a93bd0dc61340ea282d01a48f106abc6d787e455 /include | |
| parent | 17d7532c796eced679e7e234c4e6dc7546045c22 (diff) | |
Rename isogfx -> gfx2d
Diffstat (limited to 'include')
| -rw-r--r-- | include/isogfx/backend.h | 29 | ||||
| -rw-r--r-- | include/isogfx/gfx2d.h | 54 |
2 files changed, 42 insertions, 41 deletions
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 @@ | |||
| 2 | 2 | ||
| 3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
| 4 | 4 | ||
| 5 | typedef struct Gfx Gfx; | 5 | typedef struct Gfx Gfx; |
| 6 | typedef struct IsoGfx IsoGfx; | 6 | typedef struct Gfx2d Gfx2d; |
| 7 | 7 | ||
| 8 | typedef struct IsoBackend IsoBackend; | 8 | typedef struct Gfx2dBackend Gfx2dBackend; |
| 9 | 9 | ||
| 10 | /// Initialize the backend. | 10 | /// Initialize the backend. |
| 11 | IsoBackend* iso_backend_init(const IsoGfx*); | 11 | Gfx2dBackend* gfx2d_backend_init(const Gfx2d*); |
| 12 | 12 | ||
| 13 | /// Shut down the backend. | 13 | /// Shut down the backend. |
| 14 | void iso_backend_shutdown(IsoBackend**); | 14 | void gfx2d_backend_shutdown(Gfx2dBackend**); |
| 15 | 15 | ||
| 16 | /// Notify the backend of a window resize event. | 16 | /// Notify the backend of a window resize event. |
| 17 | /// This allows the backend to determine how to position and scale the iso | 17 | /// This allows the backend to determine how to position and scale the gfx |
| 18 | /// screen buffer on the graphics window. | 18 | /// screen buffer on the graphics window. |
| 19 | void iso_backend_resize_window( | 19 | void gfx2d_backend_resize_window( |
| 20 | IsoBackend*, const IsoGfx*, int width, int height); | 20 | Gfx2dBackend*, const Gfx2d*, int width, int height); |
| 21 | 21 | ||
| 22 | /// Render the iso screen to the graphics window. | 22 | /// Render the gfx screen to the graphics window. |
| 23 | void iso_backend_render(const IsoBackend*, const IsoGfx*); | 23 | void gfx2d_backend_render(const Gfx2dBackend*, const Gfx2d*); |
| 24 | 24 | ||
| 25 | /// Map window coordinates to iso space coordinates. | 25 | /// Map window coordinates to gfx space coordinates. |
| 26 | /// This takes into account any possible resizing done by the backend in | 26 | /// This takes into account any possible resizing done by the backend in |
| 27 | /// response to calls to iso_backend_resize_window(). | 27 | /// response to calls to gfx2d_backend_resize_window(). |
| 28 | bool iso_backend_get_mouse_position( | 28 | bool gfx2d_backend_get_mouse_position( |
| 29 | const IsoBackend*, double window_x, double window_y, double* x, double* y); | 29 | const Gfx2dBackend*, double window_x, double window_y, double* x, |
| 30 | 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 @@ | |||
| 8 | #include <stddef.h> | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> | 9 | #include <stdint.h> |
| 10 | 10 | ||
| 11 | typedef struct IsoGfx IsoGfx; | 11 | typedef struct Gfx2d Gfx2d; |
| 12 | 12 | ||
| 13 | /// Sprite sheet handle. | 13 | /// Sprite sheet handle. |
| 14 | typedef uintptr_t SpriteSheet; | 14 | typedef uintptr_t SpriteSheet; |
| @@ -50,43 +50,43 @@ typedef struct IsoGfxDesc { | |||
| 50 | size_t memory_size; // Size of memory block in bytes. | 50 | size_t memory_size; // Size of memory block in bytes. |
| 51 | int screen_width; // Screen width in pixels. | 51 | int screen_width; // Screen width in pixels. |
| 52 | int screen_height; // Screen height in pixels. | 52 | int screen_height; // Screen height in pixels. |
| 53 | } IsoGfxDesc; | 53 | } Gfx2dDesc; |
| 54 | 54 | ||
| 55 | /// Create a new isometric graphics engine. | 55 | /// Create a new isometric graphics engine. |
| 56 | IsoGfx* isogfx_new(const IsoGfxDesc*); | 56 | Gfx2d* gfx2d_new(const Gfx2dDesc*); |
| 57 | 57 | ||
| 58 | /// Destroy the isometric graphics engine. | 58 | /// Destroy the isometric graphics engine. |
| 59 | void isogfx_del(IsoGfx**); | 59 | void gfx2d_del(Gfx2d**); |
| 60 | 60 | ||
| 61 | /// Clear all loaded worlds and sprites. | 61 | /// Clear all loaded worlds and sprites. |
| 62 | void isogfx_clear(IsoGfx*); | 62 | void gfx2d_clear(Gfx2d*); |
| 63 | 63 | ||
| 64 | /// Create an empty map. | 64 | /// Create an empty map. |
| 65 | void isogfx_make_map(IsoGfx*, const MapDesc*); | 65 | void gfx2d_make_map(Gfx2d*, const MapDesc*); |
| 66 | 66 | ||
| 67 | /// Load a tile map (.TM) file. | 67 | /// Load a tile map (.TM) file. |
| 68 | bool isogfx_load_map(IsoGfx*, const char* filepath); | 68 | bool gfx2d_load_map(Gfx2d*, const char* filepath); |
| 69 | 69 | ||
| 70 | /// Return the world's width. | 70 | /// Return the world's width. |
| 71 | int isogfx_world_width(const IsoGfx*); | 71 | int gfx2d_world_width(const Gfx2d*); |
| 72 | 72 | ||
| 73 | /// Return the world's height. | 73 | /// Return the world's height. |
| 74 | int isogfx_world_height(const IsoGfx*); | 74 | int gfx2d_world_height(const Gfx2d*); |
| 75 | 75 | ||
| 76 | /// Create a new tile. | 76 | /// Create a new tile. |
| 77 | Tile isogfx_make_tile(IsoGfx*, const TileDesc*); | 77 | Tile gfx2d_make_tile(Gfx2d*, const TileDesc*); |
| 78 | 78 | ||
| 79 | /// Set the tile at position (x,y). | 79 | /// Set the tile at position (x,y). |
| 80 | void isogfx_set_tile(IsoGfx*, int x, int y, Tile); | 80 | void gfx2d_set_tile(Gfx2d*, int x, int y, Tile); |
| 81 | 81 | ||
| 82 | /// Set the tiles in positions in the range (x0,y0) - (x1,y1). | 82 | /// Set the tiles in positions in the range (x0,y0) - (x1,y1). |
| 83 | void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); | 83 | void gfx2d_set_tiles(Gfx2d*, int x0, int y0, int x1, int y1, Tile); |
| 84 | 84 | ||
| 85 | /// Load a sprite sheet (.SS) file. | 85 | /// Load a sprite sheet (.SS) file. |
| 86 | SpriteSheet isogfx_load_sprite_sheet(IsoGfx*, const char* filepath); | 86 | SpriteSheet gfx2d_load_sprite_sheet(Gfx2d*, const char* filepath); |
| 87 | 87 | ||
| 88 | /// Create an animated sprite. | 88 | /// Create an animated sprite. |
| 89 | Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); | 89 | Sprite gfx2d_make_sprite(Gfx2d*, SpriteSheet); |
| 90 | 90 | ||
| 91 | // TODO: Add a function to delete a sprite. Making the caller manage and re-use | 91 | // TODO: Add a function to delete a sprite. Making the caller manage and re-use |
| 92 | // sprites is a shitty API. | 92 | // sprites is a shitty API. |
| @@ -94,41 +94,41 @@ Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); | |||
| 94 | // list of sprites so that we can re-use the ones that have been "freed". | 94 | // list of sprites so that we can re-use the ones that have been "freed". |
| 95 | 95 | ||
| 96 | /// Set the sprite's position. | 96 | /// Set the sprite's position. |
| 97 | void isogfx_set_sprite_position(IsoGfx*, Sprite, int x, int y); | 97 | void gfx2d_set_sprite_position(Gfx2d*, Sprite, int x, int y); |
| 98 | 98 | ||
| 99 | /// Set the sprite's current animation. | 99 | /// Set the sprite's current animation. |
| 100 | void isogfx_set_sprite_animation(IsoGfx*, Sprite, int animation); | 100 | void gfx2d_set_sprite_animation(Gfx2d*, Sprite, int animation); |
| 101 | 101 | ||
| 102 | /// Update the renderer. | 102 | /// Update the renderer. |
| 103 | /// | 103 | /// |
| 104 | /// Currently, this updates the sprite animations. | 104 | /// Currently, this updates the sprite animations. |
| 105 | void isogfx_update(IsoGfx*, double t); | 105 | void gfx2d_update(Gfx2d*, double t); |
| 106 | 106 | ||
| 107 | // TODO: Do we really need to store the camera in the library? It's not used | 107 | // TODO: Do we really need to store the camera in the library? It's not used |
| 108 | // for anything other than to render, so we could remove library state and | 108 | // for anything other than to render, so we could remove library state and |
| 109 | // take a camera argument in render() instead. | 109 | // take a camera argument in render() instead. |
| 110 | 110 | ||
| 111 | /// Set the camera. | 111 | /// Set the camera. |
| 112 | void isogfx_set_camera(IsoGfx*, int x, int y); | 112 | void gfx2d_set_camera(Gfx2d*, int x, int y); |
| 113 | 113 | ||
| 114 | /// Render the world. | 114 | /// Render the world. |
| 115 | void isogfx_render(IsoGfx*); | 115 | void gfx2d_render(Gfx2d*); |
| 116 | 116 | ||
| 117 | /// Draw/overlay a tile at position (x,y). | 117 | /// Draw/overlay a tile at position (x,y). |
| 118 | /// | 118 | /// |
| 119 | /// This function just renders a tile at position (x,y) and should be called | 119 | /// This function just renders a tile at position (x,y) and should be called |
| 120 | /// after isogfx_render() to obtain the correct result. To set the tile at | 120 | /// after gfx2d_render() to obtain the correct result. To set the tile at |
| 121 | /// position (x,y) instead, use isogfx_set_tile(). | 121 | /// position (x,y) instead, use gfx2d_set_tile(). |
| 122 | void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); | 122 | void gfx2d_draw_tile(Gfx2d*, int x, int y, Tile); |
| 123 | 123 | ||
| 124 | /// Get the virtual screen's dimensions. | 124 | /// Get the virtual screen's dimensions. |
| 125 | void isogfx_get_screen_size(const IsoGfx*, int* width, int* height); | 125 | void gfx2d_get_screen_size(const Gfx2d*, int* width, int* height); |
| 126 | 126 | ||
| 127 | /// Return a pointer to the virtual screen's colour buffer. | 127 | /// Return a pointer to the virtual screen's colour buffer. |
| 128 | /// | 128 | /// |
| 129 | /// Call after each call to isogfx_render() to retrieve the render output. | 129 | /// Call after each call to gfx2d_render() to retrieve the render output. |
| 130 | const Pixel* isogfx_get_screen_buffer(const IsoGfx*); | 130 | const Pixel* gfx2d_get_screen_buffer(const Gfx2d*); |
| 131 | 131 | ||
| 132 | /// Translate Cartesian to isometric coordinates. | 132 | /// Translate Cartesian to isometric coordinates. |
| 133 | void isogfx_pick_tile( | 133 | void gfx2d_pick_tile( |
| 134 | const IsoGfx*, double xcart, double ycart, int* xiso, int* yiso); | 134 | const Gfx2d*, double xcart, double ycart, int* xiso, int* yiso); |
