blob: a41d110440d26524ac1e8ae71b1ece57e7505cfc (
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
|
typedef struct {
S32 w;
S32 h;
const char *name;
U32 flags;
} PRGEWindow;
typedef enum {
KeyState_RELEASE = 0,
KeyState_PRESS = 1
} KeyStateEnum;
typedef struct {
KeyStateEnum last;
KeyStateEnum state;
} Key;
typedef struct {
V2 mouse_pos;
V2 last_mouse_pos;
V2 mouse_offset;
B32 first_mouse;
B32 capture_mouse;
Key mouse_left;
Key mouse_right;
F32 dt;
Key move_right;
Key move_forward;
Key move_left;
Key move_backward;
Key move_up;
Key move_down;
Key jump;
Key action_right;
Key action_up;
Key action_left;
Key action_down;
Key exit;
} Input;
typedef enum {
TextureType_R = 1,
TextureType_RGB = 3,
TextureType_RGBA = 4
} TextureTypeEnum;
typedef struct {
U32 id;
const char *name;
TextureTypeEnum type;
S32 w;
S32 h;
U8 *data;
} Texture;
typedef struct {
V3 pos;
V2 texc;
} Vertex;
#define PRGE_MAX_TEXTURES 2
#define PRGE_MAX_MESHES 8
#define PRGE_MAX_MODELS 8
typedef struct {
U32 id;
const char *name;
} Shader;
typedef struct {
V3 transl;
V3 rotate;
V3 scale;
} Transform;
typedef struct {
V3 origin;
V3 rotate;
S32 nverts;
Vertex *verts;
S32 nindices;
U32 *indices;
S32 ntextures;
Texture textures[PRGE_MAX_TEXTURES];
U32 vao, vbo, ebo;
} Mesh;
typedef struct {
U32 id;
V3 origin;
V3 rotate;
S32 nmeshes;
Mesh *meshes;
} Model;
typedef struct {
V3 pos;
F32 fov;
F32 near;
F32 far;
F32 yaw;
F32 pitch;
F32 roll;
} Camera;
#define PRGE_MAX_SOUNDS_LOADED 4
#define PRGE_MAX_SOUNDS_PLAYING 2
typedef struct {
S32 channels;
S32 sample_rate;
S32 bytes_per_sample;
S32 size;
U8 *data;
const char *name;
} Sound;
typedef struct SoundQueueNode {
Sound *snd;
struct SoundQueueNode *next;
struct SoundQueueNode *prev;
} SoundQueueNode;
typedef struct {
S32 cnt;
struct SoundQueueNode *first;
struct SoundQueueNode *last;
} SoundQueue;
typedef struct {
B32 should_close;
Arena *pa;
Arena *tmpa;
Input in;
/* TODO(pryazha): Probably a bad idea to have only one window 🙃*/
PRGEWindow wnd;
Sound snds[PRGE_MAX_SOUNDS_LOADED];
SoundQueueNode nodes[PRGE_MAX_SOUNDS_PLAYING];
SoundQueue sndq;
const char *bindir;
} PRGEContext;
|