summaryrefslogtreecommitdiff
path: root/include/isogfx/isogfx.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/isogfx/isogfx.h')
-rw-r--r--include/isogfx/isogfx.h57
1 files changed, 23 insertions, 34 deletions
diff --git a/include/isogfx/isogfx.h b/include/isogfx/isogfx.h
index 3421a7b..93c6d4e 100644
--- a/include/isogfx/isogfx.h
+++ b/include/isogfx/isogfx.h
@@ -3,26 +3,18 @@
3 */ 3 */
4#pragma once 4#pragma once
5 5
6#include <stdbool.h> 6#include <isogfx/types.h>
7
8#include <stddef.h>
7#include <stdint.h> 9#include <stdint.h>
8 10
9typedef struct IsoGfx IsoGfx; 11typedef struct IsoGfx IsoGfx;
10 12
11/// Sprite sheet handle. 13/// Sprite sheet handle.
12typedef uint16_t SpriteSheet; 14typedef uintptr_t SpriteSheet;
13 15
14/// Sprite handle. 16/// Sprite handle.
15typedef uint16_t Sprite; 17typedef uintptr_t Sprite;
16
17/// Tile handle.
18typedef uint16_t Tile;
19
20/// Colour channel.
21typedef uint8_t Channel;
22
23typedef struct Pixel {
24 Channel r, g, b, a;
25} Pixel;
26 18
27typedef enum TileDescType { 19typedef enum TileDescType {
28 TileFromColour, 20 TileFromColour,
@@ -32,32 +24,32 @@ typedef enum TileDescType {
32 24
33typedef struct TileDesc { 25typedef struct TileDesc {
34 TileDescType type; 26 TileDescType type;
35 int width; /// Tile width in pixels. 27 int width; // Tile width in pixels.
36 int height; /// Tile height in pixels. 28 int height; // Tile height in pixels.
37 union { 29 union {
38 Pixel colour; /// Constant colour tile. 30 Pixel colour; // Constant colour tile.
39 struct { 31 struct {
40 const char* path; 32 const char* path;
41 } file; 33 } file;
42 struct { 34 struct {
43 const uint8_t* data; /// sizeof(Pixel) * width * height 35 const uint8_t* data; // sizeof(Pixel) * width * height
44 } mem; 36 } mem;
45 }; 37 };
46} TileDesc; 38} TileDesc;
47 39
48typedef struct WorldDesc { 40typedef struct WorldDesc {
49 int tile_width; /// Base tile width in pixels. 41 int tile_width; // Base tile width in pixels.
50 int tile_height; /// Base tile height in pixels. 42 int tile_height; // Base tile height in pixels.
51 int world_width; /// World width in tiles. 43 int world_width; // World width in tiles.
52 int world_height; /// World height in tiles. 44 int world_height; // World height in tiles.
53 int max_num_tiles; /// 0 for an implementation-defined default. 45 int num_tiles; // Number of tiles to allocate memory for.
54} WorldDesc; 46} WorldDesc;
55 47
56typedef struct IsoGfxDesc { 48typedef struct IsoGfxDesc {
57 int screen_width; /// Screen width in pixels. 49 void* memory; // Block of memory for the engine to use.
58 int screen_height; /// Screen height in pixels. 50 size_t memory_size; // Size of memory block in bytes.
59 int max_num_sprites; /// 0 for an implementation-defined default. 51 int screen_width; // Screen width in pixels.
60 int sprite_sheet_pool_size_bytes; /// 0 for an implementation-defined default. 52 int screen_height; // Screen height in pixels.
61} IsoGfxDesc; 53} IsoGfxDesc;
62 54
63/// Create a new isometric graphics engine. 55/// Create a new isometric graphics engine.
@@ -66,8 +58,11 @@ IsoGfx* isogfx_new(const IsoGfxDesc*);
66/// Destroy the isometric graphics engine. 58/// Destroy the isometric graphics engine.
67void isogfx_del(IsoGfx**); 59void isogfx_del(IsoGfx**);
68 60
61/// Clear all loaded worlds and sprites.
62void isogfx_clear(IsoGfx*);
63
69/// Create an empty world. 64/// Create an empty world.
70bool isogfx_make_world(IsoGfx*, const WorldDesc*); 65void isogfx_make_world(IsoGfx*, const WorldDesc*);
71 66
72/// Load a world from a tile map (.TM) file. 67/// Load a world from a tile map (.TM) file.
73bool isogfx_load_world(IsoGfx*, const char* filepath); 68bool isogfx_load_world(IsoGfx*, const char* filepath);
@@ -88,14 +83,11 @@ void isogfx_set_tile(IsoGfx*, int x, int y, Tile);
88void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); 83void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile);
89 84
90/// Load a sprite sheet (.SS) file. 85/// Load a sprite sheet (.SS) file.
91bool isogfx_load_sprite_sheet(IsoGfx*, const char* filepath, SpriteSheet*); 86SpriteSheet isogfx_load_sprite_sheet(IsoGfx*, const char* filepath);
92 87
93/// Create an animated sprite. 88/// Create an animated sprite.
94Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet); 89Sprite isogfx_make_sprite(IsoGfx*, SpriteSheet);
95 90
96/// Destroy the sprite.
97void isogfx_del_sprite(IsoGfx*, Sprite);
98
99/// Destroy all the sprites. 91/// Destroy all the sprites.
100void isogfx_del_sprites(IsoGfx*); 92void isogfx_del_sprites(IsoGfx*);
101 93
@@ -120,9 +112,6 @@ void isogfx_render(IsoGfx*);
120/// position (x,y) instead, use isogfx_set_tile(). 112/// position (x,y) instead, use isogfx_set_tile().
121void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); 113void isogfx_draw_tile(IsoGfx*, int x, int y, Tile);
122 114
123/// Resize the virtual screen's dimensions.
124bool isogfx_resize(IsoGfx*, int screen_width, int screen_height);
125
126/// Get the virtual screen's dimensions. 115/// Get the virtual screen's dimensions.
127void isogfx_get_screen_size(const IsoGfx*, int* width, int* height); 116void isogfx_get_screen_size(const IsoGfx*, int* width, int* height);
128 117