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
|
#pragma once
#include "TZR_resource.h"
#include "TZR_render.h"
#include "TZR_events.h"
#include <SDL2/SDL_main.h>
/* TZR manages all loaded resources internally and tries to avoid duplicate.
* A resource can be loaded multiple times if asked, identification doesn't rely
* on filepath. In doubt, use TZR_LoadResource ONCE per asset and store the ID.
* Resources are exposed as ID instead of pointer, as a future proof measure in
* case TZR needs to rearrange memory at runtime in the future. */
#define TZR_Init(...) _TZR_Init(&(const TZR_Config){ \
.width=256, \
.height=224, \
.scale=2, \
.target_fps=60, \
.pixel_perfect=true, \
.hd_render=false, \
.scale_linear=false, \
.show_cursor=false, \
.mixer=TZR_MIXER_ON, \
.title="TZR", \
._=0, __VA_ARGS__ })
/* Should be called only once before usage of any other function unless
* otherwise specified. On error this calls TZR_Quit and returns -1.
* `config` will be duplicated internally and can be safely discarded. */
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
int _TZR_Init(const TZR_Config *config);
/* Destroy and free everything created by TZR. */
void TZR_Quit(void);
/* Return non-zero value when a quit event has been received. */
int TZR_ShouldQuit(void);
int TZR_MainLoop(int (*main_loop)(void *udata), void *udata);
unsigned long TZR_GetTick(void);
|