summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/isogfx/backend.h29
-rw-r--r--include/isogfx/gfx2d.h54
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
5typedef struct Gfx Gfx; 5typedef struct Gfx Gfx;
6typedef struct IsoGfx IsoGfx; 6typedef struct Gfx2d Gfx2d;
7 7
8typedef struct IsoBackend IsoBackend; 8typedef struct Gfx2dBackend Gfx2dBackend;
9 9
10/// Initialize the backend. 10/// Initialize the backend.
11IsoBackend* iso_backend_init(const IsoGfx*); 11Gfx2dBackend* gfx2d_backend_init(const Gfx2d*);
12 12
13/// Shut down the backend. 13/// Shut down the backend.
14void iso_backend_shutdown(IsoBackend**); 14void 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.
19void iso_backend_resize_window( 19void 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.
23void iso_backend_render(const IsoBackend*, const IsoGfx*); 23void 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().
28bool iso_backend_get_mouse_position( 28bool 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
11typedef struct IsoGfx IsoGfx; 11typedef struct Gfx2d Gfx2d;
12 12
13/// Sprite sheet handle. 13/// Sprite sheet handle.
14typedef uintptr_t SpriteSheet; 14typedef 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.
56IsoGfx* isogfx_new(const IsoGfxDesc*); 56Gfx2d* gfx2d_new(const Gfx2dDesc*);
57 57
58/// Destroy the isometric graphics engine. 58/// Destroy the isometric graphics engine.
59void isogfx_del(IsoGfx**); 59void gfx2d_del(Gfx2d**);
60 60
61/// Clear all loaded worlds and sprites. 61/// Clear all loaded worlds and sprites.
62void isogfx_clear(IsoGfx*); 62void gfx2d_clear(Gfx2d*);
63 63
64/// Create an empty map. 64/// Create an empty map.
65void isogfx_make_map(IsoGfx*, const MapDesc*); 65void gfx2d_make_map(Gfx2d*, const MapDesc*);
66 66
67/// Load a tile map (.TM) file. 67/// Load a tile map (.TM) file.
68bool isogfx_load_map(IsoGfx*, const char* filepath); 68bool gfx2d_load_map(Gfx2d*, const char* filepath);
69 69
70/// Return the world's width. 70/// Return the world's width.
71int isogfx_world_width(const IsoGfx*); 71int gfx2d_world_width(const Gfx2d*);
72 72
73/// Return the world's height. 73/// Return the world's height.
74int isogfx_world_height(const IsoGfx*); 74int gfx2d_world_height(const Gfx2d*);
75 75
76/// Create a new tile. 76/// Create a new tile.
77Tile isogfx_make_tile(IsoGfx*, const TileDesc*); 77Tile gfx2d_make_tile(Gfx2d*, const TileDesc*);
78 78
79/// Set the tile at position (x,y). 79/// Set the tile at position (x,y).
80void isogfx_set_tile(IsoGfx*, int x, int y, Tile); 80void 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).
83void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); 83void 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.
86SpriteSheet isogfx_load_sprite_sheet(IsoGfx*, const char* filepath); 86SpriteSheet gfx2d_load_sprite_sheet(Gfx2d*, const char* filepath);
87 87
88/// Create an animated sprite. 88/// Create an animated sprite.
89Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); 89Sprite 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.
97void isogfx_set_sprite_position(IsoGfx*, Sprite, int x, int y); 97void 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.
100void isogfx_set_sprite_animation(IsoGfx*, Sprite, int animation); 100void 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.
105void isogfx_update(IsoGfx*, double t); 105void 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.
112void isogfx_set_camera(IsoGfx*, int x, int y); 112void gfx2d_set_camera(Gfx2d*, int x, int y);
113 113
114/// Render the world. 114/// Render the world.
115void isogfx_render(IsoGfx*); 115void 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().
122void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); 122void 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.
125void isogfx_get_screen_size(const IsoGfx*, int* width, int* height); 125void 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.
130const Pixel* isogfx_get_screen_buffer(const IsoGfx*); 130const Pixel* gfx2d_get_screen_buffer(const Gfx2d*);
131 131
132/// Translate Cartesian to isometric coordinates. 132/// Translate Cartesian to isometric coordinates.
133void isogfx_pick_tile( 133void 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);