diff options
author | 3gg <3gg@shellblade.net> | 2023-06-24 18:46:33 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-06-24 18:46:33 -0700 |
commit | 0831d5bce79008bfa6404f8e8116ae8290442fde (patch) | |
tree | e488c719e16b34b60126837a90a44d1c3dd552ee /gfx-iso/include | |
parent | cf886f4fa406ddd48f30c00ad3c77f9dc134af3a (diff) |
Isometric Renderer initial commit.
Diffstat (limited to 'gfx-iso/include')
-rw-r--r-- | gfx-iso/include/isogfx/isogfx.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/gfx-iso/include/isogfx/isogfx.h b/gfx-iso/include/isogfx/isogfx.h new file mode 100644 index 0000000..a5f7770 --- /dev/null +++ b/gfx-iso/include/isogfx/isogfx.h | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * Isometric rendering engine. | ||
3 | */ | ||
4 | #pragma once | ||
5 | |||
6 | #include <stdint.h> | ||
7 | |||
8 | typedef struct IsoGfx IsoGfx; | ||
9 | |||
10 | typedef uint8_t Tile; | ||
11 | typedef uint8_t Channel; | ||
12 | |||
13 | typedef struct Pixel { | ||
14 | Channel r, g, b; | ||
15 | } Pixel; | ||
16 | |||
17 | typedef enum TileDescType { | ||
18 | TileFromColour, | ||
19 | TileFromFile, | ||
20 | TileFromMemory | ||
21 | } TileDescType; | ||
22 | |||
23 | typedef struct TileDesc { | ||
24 | TileDescType type; | ||
25 | union { | ||
26 | Pixel colour; | ||
27 | struct { | ||
28 | const char* path; | ||
29 | } file; | ||
30 | struct { | ||
31 | const void* data; | ||
32 | } mem; | ||
33 | }; | ||
34 | } TileDesc; | ||
35 | |||
36 | typedef struct IsoGfxDesc { | ||
37 | int screen_width; | ||
38 | int screen_height; | ||
39 | int tile_width; | ||
40 | int tile_height; | ||
41 | int world_width; | ||
42 | int world_height; | ||
43 | int max_num_tiles; // 0 for an implementation-defined default. | ||
44 | } IsoGfxDesc; | ||
45 | |||
46 | IsoGfx* isogfx_new(const IsoGfxDesc*); | ||
47 | |||
48 | void isogfx_del(IsoGfx**); | ||
49 | |||
50 | Tile isogfx_make_tile(IsoGfx*, const TileDesc*); | ||
51 | |||
52 | void isogfx_set_tile(IsoGfx*, int x, int y, Tile); | ||
53 | |||
54 | void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); | ||
55 | |||
56 | void isogfx_pick_tile( | ||
57 | const IsoGfx*, double xcart, double ycart, int* xiso, int* yiso); | ||
58 | |||
59 | void isogfx_render(IsoGfx*); | ||
60 | |||
61 | void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); | ||
62 | |||
63 | const Pixel* isogfx_get_screen_buffer(const IsoGfx*); | ||
64 | |||
65 | int isogfx_world_width(const IsoGfx*); | ||
66 | int isogfx_world_height(const IsoGfx*); | ||