aboutsummaryrefslogtreecommitdiff
path: root/headers/TZR_types.h
blob: 324d655357270ffdcef1d1e01bded90b6c3e401d (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#pragma once
#include <stdbool.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_gamecontroller.h>

enum TZR_ResourceType {
	TZR_RES_RAW,
	TZR_RES_IMAGE,
	TZR_RES_SOUND,
	___TZR_RES_COUNT
};

enum TZR_EventType {
	TZR_EV_NONE,
	TZR_EV_QUIT,
	TZR_EV_KEYDOWN,
	TZR_EV_KEYUP,
	TZR_EV_MOUSEDOWN,
	TZR_EV_MOUSEUP, //unused
	TZR_EV_GAMECONTROLLERDOWN,
	TZR_EV_GAMECONTROLLERUP, //unused
};

enum TZR_KeyState {
	TZR_KEYSTATE_UP,
	TZR_KEYSTATE_DOWN,
	TZR_KEYSTATE_RELEASE,
	TZR_KEYSTATE_PRESS
};

enum TZR_MixerFlags {
	TZR_MIXER_OFF,
	TZR_MIXER_ON,
	TZR_MIXER_FLAC
};

typedef unsigned int TZR_Uint;
typedef struct TZR_Config TZR_Config;
typedef struct TZR_Point TZR_Point;
typedef struct TZR_Color TZR_Color;
typedef struct TZR_Rect TZR_Rect;
typedef enum TZR_ResourceType TZR_ResourceType;
typedef struct TZR_Raw TZR_Raw;
typedef struct TZR_Image TZR_Image;
typedef struct TZR_Sound TZR_Sound;
typedef struct TZR_Font TZR_Font;
typedef struct TZR_Resource TZR_Resource;
typedef enum TZR_EventType TZR_EventType;
typedef struct TZR_Event TZR_Event;
typedef struct TZR_Music TZR_Music;
typedef struct TZR_DrawImageArgs TZR_DrawImageArgs;
typedef struct TZR_DrawRectangleArgs TZR_DrawRectangleArgs;
typedef struct TZR_PlaySoundArgs TZR_PlaySoundArgs;
typedef enum TZR_KeyState TZR_KeyState;
typedef struct TZR_Joystick TZR_Joystick;

struct TZR_Config {
	int _;
	int width;
	int height;
	float scale;
	int target_fps;
	float ratio;
	bool pixel_perfect;
	bool interlace;
	bool hd_render;
	bool scale_linear;
	bool show_cursor;
	unsigned int mixer;
	const char *basepath;
	const char *title;
	bool mipmaps;
};

struct TZR_Point {
	int x;
	int y;
};

struct TZR_Color {
	int _;
	float r;
	float g;
	float b;
	float a;
};

struct TZR_Rect {
	TZR_Point from;
	TZR_Point to;
};

struct TZR_Raw {
	void *data;
	size_t size;
};

struct TZR_Image {
	int width;
	int height;
	SDL_Texture *ptr;
};

#ifdef TZR_SOLOUD
struct TZR_Sound {
	Wav *ptr;
};
#else
struct TZR_Sound {
	Mix_Chunk *ptr;
};
#endif

struct TZR_Font {
	void *ptr;
	int ptsize;
};

struct TZR_Resource {
	TZR_ResourceType type;
	char *path; /* allocated and freed by TZR; can be NULL */
	long mtime;
	union {
		TZR_Raw raw; /* raw file data */
		TZR_Image image;
		TZR_Sound sound;
		TZR_Font ttf;
	};
};

struct TZR_Event {
	TZR_EventType type;
	int button;
};

struct TZR_DrawImageArgs {
	int _;
	TZR_Uint id;
	int x;
	int y;
	int ix;
	int iy;
	int w;
	int h;
	float r;
	float sx;
	float sy;
	bool center;
	bool flip_x;
	bool flip_y;
};

struct TZR_DrawRectangleArgs {
	int _;
	int x;
	int y;
	int w;
	int h;
	bool fill;
	bool center;
};

struct TZR_PlaySoundArgs {
	int _;
	TZR_Uint id;
	int loop;
	float volume;
};

struct TZR_Joystick
{
	SDL_GameController *ptr;
	float leftx;
	float lefty;
	float rightx;
	float righty;
};