summaryrefslogtreecommitdiff
path: root/render.h
blob: 887cffafec768162a3da1d24b71cdf9fea4e0048 (plain) (blame)
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
#ifndef render_h
#define render_h

#include "rect.h"

typedef struct {
	unsigned char r, g, b, a;
} Colour;

Colour make_colour(unsigned rgb, unsigned char a);
Colour make_red(void);
Colour make_green(void);
Colour make_blue(void);
Colour make_cyan(void);
Colour make_pink(void);
Colour make_yellow(void);
Colour make_aliceblue(void);
Colour blend(Colour dst, Colour src);
Colour blend_mod(Colour dst, Colour src, Colour mod);

typedef struct {
	Colour* t;
	int* d;
	int w, h;
	Rect clip;
} Renderer;

void ren_begin(Renderer* r, Colour* t, int* d, int w, int h);
void ren_end(Renderer* r);
void ren_clear(Renderer* r);
void ren_clearc(Renderer* r, Colour c);
void ren_cleard(Renderer* r, int depth);
void ren_clip(Renderer* r, const Rect* c);
void ren_point(Renderer* r, Colour c, int x, int y);
void ren_char(
	Renderer* r,
	Colour c,
	int x,
	int y,
	char ch
);
void ren_text(
	Renderer* r,
	Colour c,
	int x,
	int y,
	const char* t
);
typedef enum {
	tri_mode_flat,
	tri_mode_textured,
	tri_mode_lit,
	tri_mode_textured_lit
} Tri_Mode;
void ren_tri(
	Renderer* r,
	Colour c,
	int* v0,
	int* v1,
	int* v2,
	Tri_Mode mode
);

#endif