summaryrefslogtreecommitdiff
path: root/render.h
blob: 62044a0498f215f2311f7cf943ee566fdd415cc9 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef render_h
#define render_h

#include "config.h"
#include "rect.h"
#include "memory.h"

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

Colour make_colour(unsigned rgb, unsigned char a);
Colour make_black();
Colour make_white();

typedef struct Bitmap {
	Colour* pixels;
	int w, h;
} Bitmap;

void init_bitmap(
	Bitmap* bitmap,
	Colour* pixels,
	int w,
	int h
);

#define max_glyphset 256

struct Font;
typedef struct Font Font;

int font_height(Font* f);

void get_font_rect(
	const Font* font,
	Rectangle* dst,
	char c
);

Font* new_font(
	Heap* h,
	const unsigned char* raw,
	int size
);
Rectangle text_rect(Font* font, const char* text);

void rfont_text(
	Font* font,
	int x,
	int y,
	const char* text
);
void rfont_text_col(
	Font* font,
	int x,
	int y,
	const char* text,
	Colour colour
);

void render_init(void);

void render_begin(void);
void render_clear(void);
void render_clear_col(Colour col);
void render_clip(const Rectangle* rect);
void render_reset_clip(void);

Colour blend(Colour dst, Colour src);
Colour blend_mod(Colour dst, Colour src, Colour mod);

Colour* get_render_pixels(void);

extern int sprite_camera_x;
extern int sprite_camera_y;

void render_bitmap(
	const Bitmap* bitmap,
	int x,
	int y,
	const Rectangle* rect
);

void render_bitmap_col(
	const Bitmap* bitmap,
	int x,
	int y,
	const Rectangle* rect,
	Colour colour
);

void render_rect(
	const Rectangle* rect,
	Colour colour
);

void render_mask(
	const unsigned char* pixels,
	int x,
	int y,
	int w,
	int h,
	const Rectangle* rect,
	Colour colour
);

void rcopy(
	Bitmap* dst,
	const Bitmap* src,
	int x,
	int y,
	const Rectangle* rect
);

void rcopy_col(
	Bitmap* dst,
	const Bitmap* src,
	int x,
	int y,
	const Rectangle* rect,
	Colour colour
);

void rcopy_ac(
	Bitmap* dst,
	const Bitmap* src,
	int x,
	int y,
	const Rectangle* rect,
	unsigned char t
);

void rcopy_rect(
	Bitmap* dst,
	const Rectangle* rect,
	Colour colour
);

#endif