summaryrefslogtreecommitdiff
path: root/gfx-iso/include/isogfx/isogfx.h
blob: a5f7770abc59ffcdf44005ba49e1bef48067007a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Isometric rendering engine.
 */
#pragma once

#include <stdint.h>

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*);