summaryrefslogtreecommitdiff
path: root/gfx-iso/include
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2023-06-24 18:46:33 -0700
committer3gg <3gg@shellblade.net>2023-06-24 18:46:33 -0700
commit0831d5bce79008bfa6404f8e8116ae8290442fde (patch)
treee488c719e16b34b60126837a90a44d1c3dd552ee /gfx-iso/include
parentcf886f4fa406ddd48f30c00ad3c77f9dc134af3a (diff)
Isometric Renderer initial commit.
Diffstat (limited to 'gfx-iso/include')
-rw-r--r--gfx-iso/include/isogfx/isogfx.h66
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
8typedef struct IsoGfx IsoGfx;
9
10typedef uint8_t Tile;
11typedef uint8_t Channel;
12
13typedef struct Pixel {
14 Channel r, g, b;
15} Pixel;
16
17typedef enum TileDescType {
18 TileFromColour,
19 TileFromFile,
20 TileFromMemory
21} TileDescType;
22
23typedef 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
36typedef 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
46IsoGfx* isogfx_new(const IsoGfxDesc*);
47
48void isogfx_del(IsoGfx**);
49
50Tile isogfx_make_tile(IsoGfx*, const TileDesc*);
51
52void isogfx_set_tile(IsoGfx*, int x, int y, Tile);
53
54void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile);
55
56void isogfx_pick_tile(
57 const IsoGfx*, double xcart, double ycart, int* xiso, int* yiso);
58
59void isogfx_render(IsoGfx*);
60
61void isogfx_draw_tile(IsoGfx*, int x, int y, Tile);
62
63const Pixel* isogfx_get_screen_buffer(const IsoGfx*);
64
65int isogfx_world_width(const IsoGfx*);
66int isogfx_world_height(const IsoGfx*);