aboutsummaryrefslogtreecommitdiff
path: root/headers/TZR_types.h
blob: f15ce5fb506f6dc74d31efa09df6fce7b6a47f03 (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
#pragma once
#include <stdbool.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_mixer.h>

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

enum TZR_EventType {
	TZR_EV_QUIT,
	TZR_EV_KEYDOWN,
	TZR_EV_KEYUP
};

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

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

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

struct TZR_Sound {
	Mix_Chunk *ptr;
};

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

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 _;
	int id;
	int loop;
	float volume;
};