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

enum TZR_ResourceType {
	TZR_RES_RAW,
	TZR_RES_IMAGE,
	___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
};

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_Resource TZR_Resource;
typedef enum TZR_EventType TZR_EventType;
typedef struct TZR_Event TZR_Event;
typedef struct TZR_DrawImageArgs TZR_DrawImageArgs;
typedef enum TZR_KeyState TZR_KeyState;

struct TZR_Config {
	int _;
	int width;
	int height;
	int target_fps;
	bool pixel_perfect;
	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_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;
	};
};

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