12 #ifdef _POSIX_C_SOURCE
13 #undef _POSIX_C_SOURCE
15 #define _POSIX_C_SOURCE 200112L
20 #define _XOPEN_SOURCE 700
22 #ifdef _DEFAULT_SOURCE
23 #undef _DEFAULT_SOURCE
25 #define _DEFAULT_SOURCE
31 #ifndef _HAVE_ARRAY_TYPE
32 #define _HAVE_ARRAY_TYPE
33 typedef struct array_s
{
41 #ifndef _HAVE_FILE_TYPE
42 #define _HAVE_FILE_TYPE
43 typedef struct file_s
{
56 #ifndef _HAVE_COLOUR_TYPE
57 #define _HAVE_COLOUR_TYPE
58 typedef struct colour_s
{
72 } __attribute__((packed
)) v3_t
;
80 } __attribute__((packed
)) v2_t
;
83 #ifndef _HAVE_AABOX_TYPE
84 #define _HAVE_AABOX_TYPE
85 typedef struct aabox_s
{
91 #ifndef _HAVE_RECT_TYPE
92 #define _HAVE_RECT_TYPE
93 typedef struct rect_s
{
101 #ifndef _HAVE_RECTF_TYPE
102 #define _HAVE_RECTF_TYPE
103 typedef struct rectf_s
{
111 #ifndef _HAVE_POS_TYPE
112 #define _HAVE_POS_TYPE
113 typedef struct pos_s
{
117 } __attribute__((packed
)) pos_t
;
120 #ifndef _HAVE_QUATERNION_TYPE
121 #define _HAVE_QUATERNION_TYPE
122 typedef struct quaternion_s
{
127 } __attribute__((packed
)) quaternion_t
;
130 #ifndef _HAVE_MATRIX_TYPE
131 #define _HAVE_MATRIX_TYPE
132 typedef struct matrix_s
{
137 #define CN_ERROR 0x01
139 #define CN_ACTION 0x03
142 #define CN_DEBUG 0x06
144 #define VLSTATE_EXIT 0x00
145 #define VLSTATE_GET 0x01
146 #define VLSTATE_MENU 0x02
147 #define VLSTATE_PAUSE 0x03
148 #define VLSTATE_PLAY 0x04
150 /* defined in math.c */
151 int math_next_pow2(int a
);
152 int math_rand_range(int low
, int high
);
153 float math_rand_rangef(float low
, float high
);
154 float math_radians_to_degrees(float rads
);
155 float math_degrees_to_radians(float degrees
);
157 /* defined in math_quaternion.c */
158 quaternion_t
*quat_create_quat(float x
, float y
, float z
, float w
);
159 quaternion_t
*quat_create_euler(float x
, float y
, float z
);
160 quaternion_t
*quat_create_axis(v3_t
*v
, float angle
);
161 void quat_init_quat(quaternion_t
*q
, float x
, float y
, float z
, float w
);
162 void quat_init_euler(quaternion_t
*q
, float x
, float y
, float z
);
163 void quat_init_axis(quaternion_t
*q
, v3_t
*v
, float angle
);
164 void quat_normalise(quaternion_t
*q
);
165 void quat_get_axis(quaternion_t
*q
, v3_t
*v
, float *angle
);
166 void quat_multiply_vector(quaternion_t
*q
, quaternion_t
*rq
, v3_t
*v
);
167 void quat_multiply(quaternion_t
*q1
, quaternion_t
*q2
, quaternion_t
*rq
);
168 void quat_print(quaternion_t
*q
);
169 void quat_computew(quaternion_t
*q
);
170 void quat_rotate(quaternion_t
*q
, v3_t
*in
, v3_t
*out
);
172 /* defined in math_vector.c */
173 void vect_create(v3_t
*start
, v3_t
*end
, v3_t
*v
);
174 float vect_length(v3_t
*v
);
175 void vect_normalise(v3_t
*v
);
176 float vect_scalarproduct(v3_t
*v1
, v3_t
*v2
);
177 void vect_crossproduct(v3_t
*v1
, v3_t
*v2
, v3_t
*v3
);
178 void vect_dotproduct(v3_t
*v1
, v3_t
*v2
, v3_t
*v3
);
179 void vect_subtract(v3_t
*v1
, v3_t
*v2
, v3_t
*v3
);
180 float vect_diameter(v3_t
*v
);
181 float math_dotproduct(v3_t
*v1
, v3_t
*v2
);
182 float math_distance(v3_t
*v1
, v3_t
*v2
);
184 /* defined in math_matrix.c */
185 void matrix_init(matrix_t
*m
);
186 matrix_t
*matrix_create(void);
187 void matrix_multiply(matrix_t
*m
, matrix_t
*mul
);
188 void matrix_translate(matrix_t
*m
, float x
, float y
, float z
);
189 void matrix_translate_v(matrix_t
*m
, v3_t
*v
);
190 void matrix_scale(matrix_t
*m
, float x
, float y
, float z
);
191 void matrix_scale_v(matrix_t
*m
, v3_t
*v
);
192 void matrix_rotate(matrix_t
*m
, float rads
, float x
, float y
, float z
);
193 void matrix_rotate_v(matrix_t
*m
, float rads
, v3_t
*v
);
194 void matrix_rotate_x(matrix_t
*m
, float rads
);
195 void matrix_rotate_y(matrix_t
*m
, float rads
);
196 void matrix_rotate_z(matrix_t
*m
, float rads
);
197 void matrix_rotate_deg(matrix_t
*m
, float degrees
, float x
, float y
, float z
);
198 void matrix_rotate_deg_v(matrix_t
*m
, float degrees
, v3_t
*v
);
199 void matrix_rotate_deg_x(matrix_t
*m
, float degrees
);
200 void matrix_rotate_deg_y(matrix_t
*m
, float degrees
);
201 void matrix_rotate_deg_z(matrix_t
*m
, float degrees
);
202 void matrix_rotate_quat(matrix_t
*m
, quaternion_t
*q
);
204 /* defined in string.c */
205 char* trim(char* str
);
206 char* strdup(const char* str
);
207 int strappend(char* dest
, int size
, char* str
);
208 int parse_bool(char* str
);
210 /* defined in config.c */
211 char* config_get(char* name
);
212 int config_get_int(char* name
);
213 float config_get_float(char* name
);
214 int config_get_bool(char* name
);
215 void config_set(char* name
, char* value
);
216 int config_set_command(array_t
*args
);
217 void config_set_int(char* name
, int value
);
218 void config_set_float(char* name
, float value
);
219 void config_set_default(char* name
, char* value
, int (*setter
)(char* v
));
220 void config_set_default_int(char* name
, int value
, int (*setter
)(char* v
));
221 void config_set_default_float(char* name
, float value
, int (*setter
)(char* v
));
222 void config_load(char* file
);
223 int config_load_command(array_t
*args
);
224 int config_ignore_command(array_t
*args
);
225 void config_init(int argc
, char** argv
);
226 void config_save(void);
228 /* defined in config_default.c */
229 void config_default_init(void);
231 /* defined in log.c */
232 int log_minlevel_setter(char* v
);
233 int log_maxlevel_setter(char* v
);
234 int log_sminlevel_setter(char* v
);
235 int log_smaxlevel_setter(char* v
);
236 int log_cminlevel_setter(char* v
);
237 int log_cmaxlevel_setter(char* v
);
238 int log_file_setter(char* v
);
239 void vlprintf(uint8_t type
, char* fmt
,...);
241 /* defined in utf8.c */
242 int utf8_seqlen(char* str
);
243 uint32_t utf8_nextchar(char* str
, int *i
);
244 uint32_t utf8_toutf32(char* src
, int size
);
245 int utf8_fromutf32(char *dest
, int sz
, uint32_t ch
);
246 uint32_t utf16_toutf32(uint16_t *str
);
247 int utf8_offset(char* str
, int i
);
248 int utf8_charindex(char* str
, int o
);
249 int utf8_strlen(char* str
);
250 void utf8_inc(char* str
, int *i
);
251 void utf8_dec(char* str
, int *i
);
252 char* utf8_strchr(char* str
, uint32_t ch
, int *charn
);
253 char* utf8_memchr(char* str
, uint32_t ch
, size_t sz
, int *charn
);
255 /* defined in sys_console.c */
256 void sys_console_print(char* str
, int newline
);
257 void sys_console_printf(char* fmt
, ...);
258 void sys_console_init(void);
259 void sys_console_exit(void);
261 /* defined in intl.c */
262 char* gettext(const char *s
);
263 char* ngettext(const char* s1
, const char* s2
, int n
);
264 void intl_init(void);
266 /* defined in time.c */
267 void time_init(void);
268 uint32_t time_ticks(void);
269 void delay(uint32_t ms
);
270 float time_dtime(uint32_t last
);
271 uint32_t interval_delay(uint32_t last
, uint32_t hz
);
272 uint32_t calc_fps(uint32_t prev
, uint32_t current
);
274 /* defined in command.c */
275 int command_init(void);
276 int command_add(char* name
, int (*func
)(array_t
*args
));
277 int command_apply(char* name
, char* value
);
278 int command_exec(char* str
);
279 int command_execf(char* str
, ...);
280 void command_save(file_t
*f
);
282 /* defined in main.c */
283 int client_state(int s
);