aboutsummaryrefslogtreecommitdiff
path: root/render.h
blob: be03f022fcc7a6770f9a38d93bbc914ccc391b51 (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
#ifndef render_h
#define render_h

#include "config.h"
#include "rect.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 {
	Colour* pixels;
	int w, h;
} Bitmap;

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

typedef struct BM_Font {
	const Bitmap* bmp;
	int char_w, char_h;
	int chars_across;
} BM_Font;

void init_font(
	BM_Font* font,
	const Bitmap* bmp,
	int char_w,
	int char_h,
	int chars_across
);

void rfont_char(const BM_Font* font, int x, int y, char c);
void rfont_char_col(
	const BM_Font* font,
	int x,
	int y,
	char c,
	Colour colour
);
void rfont_text(
	const BM_Font* font,
	int x,
	int y,
	const char* text
);
void rfont_text_col(
	const BM_Font* font,
	int x,
	int y,
	const char* text,
	Colour colour
);

void init_renderer();

void renderer_begin_frame();

Colour* get_render_pixels();

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

#endif