diff options
Diffstat (limited to 'gfx-iso/include/isogfx')
-rw-r--r-- | gfx-iso/include/isogfx/backend.h | 28 | ||||
-rw-r--r-- | gfx-iso/include/isogfx/isogfx.h | 136 |
2 files changed, 0 insertions, 164 deletions
diff --git a/gfx-iso/include/isogfx/backend.h b/gfx-iso/include/isogfx/backend.h deleted file mode 100644 index 172991d..0000000 --- a/gfx-iso/include/isogfx/backend.h +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <stdbool.h> | ||
4 | |||
5 | typedef struct Gfx Gfx; | ||
6 | typedef struct IsoGfx IsoGfx; | ||
7 | |||
8 | typedef struct IsoBackend IsoBackend; | ||
9 | |||
10 | /// Initialize the backend. | ||
11 | IsoBackend* IsoBackendInit(const IsoGfx*); | ||
12 | |||
13 | /// Shut down the backend. | ||
14 | void IsoBackendShutdown(IsoBackend**); | ||
15 | |||
16 | /// Notify the backend of a window resize event. | ||
17 | /// This allows the backend to determine how to position and scale the iso | ||
18 | /// screen buffer on the graphics window. | ||
19 | void IsoBackendResizeWindow(IsoBackend*, const IsoGfx*, int width, int height); | ||
20 | |||
21 | /// Render the iso screen to the graphics window. | ||
22 | void IsoBackendRender(const IsoBackend*, const IsoGfx*); | ||
23 | |||
24 | /// Map window coordinates to iso space coordinates. | ||
25 | /// This takes into account any possible resizing done by the backend in | ||
26 | /// response to calls to IsoBackendResizeWindow(). | ||
27 | bool IsoBackendGetMousePosition( | ||
28 | const IsoBackend*, double window_x, double window_y, double* x, double* y); | ||
diff --git a/gfx-iso/include/isogfx/isogfx.h b/gfx-iso/include/isogfx/isogfx.h deleted file mode 100644 index 3421a7b..0000000 --- a/gfx-iso/include/isogfx/isogfx.h +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | /* | ||
2 | * Isometric rendering engine. | ||
3 | */ | ||
4 | #pragma once | ||
5 | |||
6 | #include <stdbool.h> | ||
7 | #include <stdint.h> | ||
8 | |||
9 | typedef struct IsoGfx IsoGfx; | ||
10 | |||
11 | /// Sprite sheet handle. | ||
12 | typedef uint16_t SpriteSheet; | ||
13 | |||
14 | /// Sprite handle. | ||
15 | typedef uint16_t Sprite; | ||
16 | |||
17 | /// Tile handle. | ||
18 | typedef uint16_t Tile; | ||
19 | |||
20 | /// Colour channel. | ||
21 | typedef uint8_t Channel; | ||
22 | |||
23 | typedef struct Pixel { | ||
24 | Channel r, g, b, a; | ||
25 | } Pixel; | ||
26 | |||
27 | typedef enum TileDescType { | ||
28 | TileFromColour, | ||
29 | TileFromFile, | ||
30 | TileFromMemory, | ||
31 | } TileDescType; | ||
32 | |||
33 | typedef struct TileDesc { | ||
34 | TileDescType type; | ||
35 | int width; /// Tile width in pixels. | ||
36 | int height; /// Tile height in pixels. | ||
37 | union { | ||
38 | Pixel colour; /// Constant colour tile. | ||
39 | struct { | ||
40 | const char* path; | ||
41 | } file; | ||
42 | struct { | ||
43 | const uint8_t* data; /// sizeof(Pixel) * width * height | ||
44 | } mem; | ||
45 | }; | ||
46 | } TileDesc; | ||
47 | |||
48 | typedef struct WorldDesc { | ||
49 | int tile_width; /// Base tile width in pixels. | ||
50 | int tile_height; /// Base tile height in pixels. | ||
51 | int world_width; /// World width in tiles. | ||
52 | int world_height; /// World height in tiles. | ||
53 | int max_num_tiles; /// 0 for an implementation-defined default. | ||
54 | } WorldDesc; | ||
55 | |||
56 | typedef struct IsoGfxDesc { | ||
57 | int screen_width; /// Screen width in pixels. | ||
58 | int screen_height; /// Screen height in pixels. | ||
59 | int max_num_sprites; /// 0 for an implementation-defined default. | ||
60 | int sprite_sheet_pool_size_bytes; /// 0 for an implementation-defined default. | ||
61 | } IsoGfxDesc; | ||
62 | |||
63 | /// Create a new isometric graphics engine. | ||
64 | IsoGfx* isogfx_new(const IsoGfxDesc*); | ||
65 | |||
66 | /// Destroy the isometric graphics engine. | ||
67 | void isogfx_del(IsoGfx**); | ||
68 | |||
69 | /// Create an empty world. | ||
70 | bool isogfx_make_world(IsoGfx*, const WorldDesc*); | ||
71 | |||
72 | /// Load a world from a tile map (.TM) file. | ||
73 | bool isogfx_load_world(IsoGfx*, const char* filepath); | ||
74 | |||
75 | /// Return the world's width. | ||
76 | int isogfx_world_width(const IsoGfx*); | ||
77 | |||
78 | /// Return the world's height. | ||
79 | int isogfx_world_height(const IsoGfx*); | ||
80 | |||
81 | /// Create a new tile. | ||
82 | Tile isogfx_make_tile(IsoGfx*, const TileDesc*); | ||
83 | |||
84 | /// Set the tile at position (x,y). | ||
85 | void isogfx_set_tile(IsoGfx*, int x, int y, Tile); | ||
86 | |||
87 | /// Set the tiles in positions in the range (x0,y0) - (x1,y1). | ||
88 | void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); | ||
89 | |||
90 | /// Load a sprite sheet (.SS) file. | ||
91 | bool isogfx_load_sprite_sheet(IsoGfx*, const char* filepath, SpriteSheet*); | ||
92 | |||
93 | /// Create an animated sprite. | ||
94 | Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); | ||
95 | |||
96 | /// Destroy the sprite. | ||
97 | void isogfx_del_sprite(IsoGfx*, Sprite); | ||
98 | |||
99 | /// Destroy all the sprites. | ||
100 | void isogfx_del_sprites(IsoGfx*); | ||
101 | |||
102 | /// Set the sprite's position. | ||
103 | void isogfx_set_sprite_position(IsoGfx*, Sprite, int x, int y); | ||
104 | |||
105 | /// Set the sprite's current animation. | ||
106 | void isogfx_set_sprite_animation(IsoGfx*, Sprite, int animation); | ||
107 | |||
108 | /// Update the renderer. | ||
109 | /// | ||
110 | /// Currently this updates the sprite animations. | ||
111 | void isogfx_update(IsoGfx*, double t); | ||
112 | |||
113 | /// Render the world. | ||
114 | void isogfx_render(IsoGfx*); | ||
115 | |||
116 | /// Draw/overlay a tile at position (x,y). | ||
117 | /// | ||
118 | /// This function just renders a tile at position (x,y) and should be called | ||
119 | /// after isogfx_render() to obtain the correct result. To set the tile at | ||
120 | /// position (x,y) instead, use isogfx_set_tile(). | ||
121 | void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); | ||
122 | |||
123 | /// Resize the virtual screen's dimensions. | ||
124 | bool isogfx_resize(IsoGfx*, int screen_width, int screen_height); | ||
125 | |||
126 | /// Get the virtual screen's dimensions. | ||
127 | void isogfx_get_screen_size(const IsoGfx*, int* width, int* height); | ||
128 | |||
129 | /// Return a pointer to the virtual screen's colour buffer. | ||
130 | /// | ||
131 | /// Call after each call to isogfx_render() to retrieve the render output. | ||
132 | const Pixel* isogfx_get_screen_buffer(const IsoGfx*); | ||
133 | |||
134 | /// Translate Cartesian to isometric coordinates. | ||
135 | void isogfx_pick_tile( | ||
136 | const IsoGfx*, double xcart, double ycart, int* xiso, int* yiso); | ||