From 0831d5bce79008bfa6404f8e8116ae8290442fde Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 24 Jun 2023 18:46:33 -0700 Subject: Isometric Renderer initial commit. --- gfx-iso/include/isogfx/isogfx.h | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 gfx-iso/include/isogfx/isogfx.h (limited to 'gfx-iso/include/isogfx') 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 @@ +/* + * Isometric rendering engine. + */ +#pragma once + +#include + +typedef struct IsoGfx IsoGfx; + +typedef uint8_t Tile; +typedef uint8_t Channel; + +typedef struct Pixel { + Channel r, g, b; +} Pixel; + +typedef enum TileDescType { + TileFromColour, + TileFromFile, + TileFromMemory +} TileDescType; + +typedef struct TileDesc { + TileDescType type; + union { + Pixel colour; + struct { + const char* path; + } file; + struct { + const void* data; + } mem; + }; +} TileDesc; + +typedef struct IsoGfxDesc { + int screen_width; + int screen_height; + int tile_width; + int tile_height; + int world_width; + int world_height; + int max_num_tiles; // 0 for an implementation-defined default. +} IsoGfxDesc; + +IsoGfx* isogfx_new(const IsoGfxDesc*); + +void isogfx_del(IsoGfx**); + +Tile isogfx_make_tile(IsoGfx*, const TileDesc*); + +void isogfx_set_tile(IsoGfx*, int x, int y, Tile); + +void isogfx_set_tiles(IsoGfx*, int x0, int y0, int x1, int y1, Tile); + +void isogfx_pick_tile( + const IsoGfx*, double xcart, double ycart, int* xiso, int* yiso); + +void isogfx_render(IsoGfx*); + +void isogfx_draw_tile(IsoGfx*, int x, int y, Tile); + +const Pixel* isogfx_get_screen_buffer(const IsoGfx*); + +int isogfx_world_width(const IsoGfx*); +int isogfx_world_height(const IsoGfx*); -- cgit v1.2.3