summaryrefslogtreecommitdiffhomepage
path: root/include/rodeo.h
blob: c49bd5ecf310777414eb1eff1c5570628857197e (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
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
141
142
143
144
145
146
147
148
149
150
151
152

// -- internal --
// public
#include "rodeo_types.h"
#include "rodeo/input.h"
#include "rodeo/log.h"
#include "rodeo/common.h"
#include "rodeo/audio.h"

// -- external --
#include "stc/cstr.h"

// -- system --
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <limits.h>

/// --- Math ---

rodeo_color_RGBA8_t
rodeo_color_RGBAFloat_to_RGBA8(const rodeo_color_RGBAFloat_t color);

rodeo_color_RGBAFloat_t
rodeo_color_RGBA8_to_RGBAFloat(const rodeo_color_RGBA8_t color);

void
rodeo_random_seed_set(uint64_t seed);

double
rodeo_random_double_get(void);

uint64_t
rodeo_random_uint64_get(void);

/// --- Core ---

#define								\
mrodeo_window_do(					\
	screen_height,					\
	screen_width,					\
	title							\
)									\
	mrodeo_defer_do(				\
		rodeo_window_init(			\
			screen_height,			\
			screen_width,			\
			title					\
		),							\
		rodeo_window_deinit()		\
	)

void
rodeo_window_init(
	uint16_t screen_height,
	uint16_t screen_width,
	cstr title
);

void
rodeo_window_deinit(void);

uint16_t
rodeo_screen_width_get(void);

uint16_t
rodeo_screen_height_get(void);

#define								\
mrodeo_frame_do(					\
	state							\
)									\
	mrodeo_defer_do(				\
		rodeo_frame_begin(state),	\
		rodeo_frame_end(state)		\
	)

void
rodeo_frame_begin(void);

void
rodeo_frame_end(void);

void
rodeo_mainLoop_run(
	rodeo_mainLoop_function main_loop_func
);

bool
rodeo_window_quit_get(void);

void
rodeo_window_quit_set(bool quit);

void
rodeo_debug_text_draw(uint16_t x, uint16_t y, const char *format, ...);

cstr
rodeo_renderer_name_get(void);

void
rodeo_renderer_flush(void);

const rodeo_texture_2d_t*
rodeo_texture_2d_default_get(void);

rodeo_texture_2d_t
rodeo_texture_2d_create_from_RGBA8(
	const uint16_t width,
	const uint16_t height,
	const uint8_t memory[]
);

rodeo_texture_2d_t
rodeo_texture_2d_create_from_path(cstr path);

void
rodeo_texture_2d_destroy(rodeo_texture_2d_t *texture);

void
rodeo_rectangle_draw(
	const rodeo_rectangle_t *rectangle,
	const rodeo_color_RGBAFloat_t *color
);

void
rodeo_texture_2d_draw(
	const rodeo_rectangle_t *destination,
	const rodeo_rectangle_t *source,
	const rodeo_color_RGBAFloat_t *color,
	const rodeo_texture_2d_t *texture
);


/// --- Framerate ---

uint64_t
rodeo_frame_count_get(void);

float
rodeo_frame_time_get(void);

float
rodeo_frame_perSecond_get(void);

void
rodeo_frame_limit_set(uint32_t limit);

uint32_t
rodeo_frame_limit_get(void);