@dayme/bunraylib 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/c/audio.c ADDED
@@ -0,0 +1,344 @@
1
+ #include "common.h"
2
+
3
+ void InitAudioDeviceW() {
4
+ InitAudioDevice();
5
+ }
6
+
7
+ void CloseAudioDeviceW() {
8
+ CloseAudioDevice();
9
+ }
10
+
11
+ bool IsAudioDeviceReadyW() {
12
+ return IsAudioDeviceReady();
13
+ }
14
+
15
+ void SetMasterVolumeW(int volume) {
16
+ float f;
17
+ memcpy(&f, &volume, sizeof(float));
18
+ SetMasterVolume(f);
19
+ }
20
+
21
+ int GetMasterVolumeW() {
22
+ float f = GetMasterVolume();
23
+ int i;
24
+ memcpy(&i, &f, sizeof(float));
25
+ return i;
26
+ }
27
+
28
+ int LoadWaveW(const char* fileName) {
29
+ int slot = waveAlloc();
30
+ if (slot < 0) return -1;
31
+ waveRegistry[slot] = LoadWave(fileName);
32
+ return slot;
33
+ }
34
+
35
+ int LoadWaveFromMemoryW(const char* fileType, const unsigned char* fileData, int dataSize) {
36
+ int slot = waveAlloc();
37
+ if (slot < 0) return -1;
38
+ waveRegistry[slot] = LoadWaveFromMemory(fileType, fileData, dataSize);
39
+ return slot;
40
+ }
41
+
42
+ bool IsWaveValidW(int id) {
43
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return false;
44
+ return IsWaveValid(waveRegistry[id]);
45
+ }
46
+
47
+ void UnloadWaveW(int id) {
48
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return;
49
+ UnloadWave(waveRegistry[id]);
50
+ waveUsed[id] = false;
51
+ }
52
+
53
+ bool ExportWaveW(int id, const char* fileName) {
54
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return false;
55
+ return ExportWave(waveRegistry[id], fileName);
56
+ }
57
+
58
+ bool ExportWaveAsCodeW(int id, const char* fileName) {
59
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return false;
60
+ return ExportWaveAsCode(waveRegistry[id], fileName);
61
+ }
62
+
63
+ int WaveCopyW(int id) {
64
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return -1;
65
+ int slot = waveAlloc();
66
+ if (slot < 0) return -1;
67
+ waveRegistry[slot] = WaveCopy(waveRegistry[id]);
68
+ return slot;
69
+ }
70
+
71
+ void WaveCropW(int id, int initFrame, int finalFrame) {
72
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return;
73
+ WaveCrop(&waveRegistry[id], initFrame, finalFrame);
74
+ }
75
+
76
+ void WaveFormatW(int id, int sampleRate, int sampleSize, int channels) {
77
+ if (id < 0 || id >= MAX_WAVES || !waveUsed[id]) return;
78
+ WaveFormat(&waveRegistry[id], sampleRate, sampleSize, channels);
79
+ }
80
+
81
+ int LoadSoundW(const char* fileName) {
82
+ int slot = soundAlloc();
83
+ if (slot < 0) return -1;
84
+ soundRegistry[slot] = LoadSound(fileName);
85
+ return slot;
86
+ }
87
+
88
+ int LoadSoundFromWaveW(int waveId) {
89
+ if (waveId < 0 || waveId >= MAX_WAVES || !waveUsed[waveId]) return -1;
90
+ int slot = soundAlloc();
91
+ if (slot < 0) return -1;
92
+ soundRegistry[slot] = LoadSoundFromWave(waveRegistry[waveId]);
93
+ return slot;
94
+ }
95
+
96
+ int LoadSoundAliasW(int sourceId) {
97
+ if (sourceId < 0 || sourceId >= MAX_SOUNDS || !soundUsed[sourceId]) return -1;
98
+ int slot = soundAlloc();
99
+ if (slot < 0) return -1;
100
+ soundRegistry[slot] = LoadSoundAlias(soundRegistry[sourceId]);
101
+ return slot;
102
+ }
103
+
104
+ bool IsSoundValidW(int id) {
105
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return false;
106
+ return IsSoundValid(soundRegistry[id]);
107
+ }
108
+
109
+ void UnloadSoundW(int id) {
110
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
111
+ UnloadSound(soundRegistry[id]);
112
+ soundUsed[id] = false;
113
+ }
114
+
115
+ void UnloadSoundAliasW(int id) {
116
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
117
+ UnloadSoundAlias(soundRegistry[id]);
118
+ soundUsed[id] = false;
119
+ }
120
+
121
+ void PlaySoundW(int id) {
122
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
123
+ PlaySound(soundRegistry[id]);
124
+ }
125
+
126
+ void StopSoundW(int id) {
127
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
128
+ StopSound(soundRegistry[id]);
129
+ }
130
+
131
+ void PauseSoundW(int id) {
132
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
133
+ PauseSound(soundRegistry[id]);
134
+ }
135
+
136
+ void ResumeSoundW(int id) {
137
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
138
+ ResumeSound(soundRegistry[id]);
139
+ }
140
+
141
+ bool IsSoundPlayingW(int id) {
142
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return false;
143
+ return IsSoundPlaying(soundRegistry[id]);
144
+ }
145
+
146
+ void SetSoundVolumeW(int id, int volume) {
147
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
148
+ float f;
149
+ memcpy(&f, &volume, sizeof(float));
150
+ SetSoundVolume(soundRegistry[id], f);
151
+ }
152
+
153
+ void SetSoundPitchW(int id, int pitch) {
154
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
155
+ float f;
156
+ memcpy(&f, &pitch, sizeof(float));
157
+ SetSoundPitch(soundRegistry[id], f);
158
+ }
159
+
160
+ void SetSoundPanW(int id, int pan) {
161
+ if (id < 0 || id >= MAX_SOUNDS || !soundUsed[id]) return;
162
+ float f;
163
+ memcpy(&f, &pan, sizeof(float));
164
+ SetSoundPan(soundRegistry[id], f);
165
+ }
166
+
167
+ int LoadMusicStreamW(const char* fileName) {
168
+ int slot = musicAlloc();
169
+ if (slot < 0) return -1;
170
+ musicRegistry[slot] = LoadMusicStream(fileName);
171
+ return slot;
172
+ }
173
+
174
+ int LoadMusicStreamFromMemoryW(const char* fileType, const unsigned char* data, int dataSize) {
175
+ int slot = musicAlloc();
176
+ if (slot < 0) return -1;
177
+ musicRegistry[slot] = LoadMusicStreamFromMemory(fileType, data, dataSize);
178
+ return slot;
179
+ }
180
+
181
+ bool IsMusicValidW(int id) {
182
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return false;
183
+ return IsMusicValid(musicRegistry[id]);
184
+ }
185
+
186
+ void UnloadMusicStreamW(int id) {
187
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
188
+ UnloadMusicStream(musicRegistry[id]);
189
+ musicUsed[id] = false;
190
+ }
191
+
192
+ void PlayMusicStreamW(int id) {
193
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
194
+ PlayMusicStream(musicRegistry[id]);
195
+ }
196
+
197
+ bool IsMusicStreamPlayingW(int id) {
198
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return false;
199
+ return IsMusicStreamPlaying(musicRegistry[id]);
200
+ }
201
+
202
+ void UpdateMusicStreamW(int id) {
203
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
204
+ UpdateMusicStream(musicRegistry[id]);
205
+ }
206
+
207
+ void StopMusicStreamW(int id) {
208
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
209
+ StopMusicStream(musicRegistry[id]);
210
+ }
211
+
212
+ void PauseMusicStreamW(int id) {
213
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
214
+ PauseMusicStream(musicRegistry[id]);
215
+ }
216
+
217
+ void ResumeMusicStreamW(int id) {
218
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
219
+ ResumeMusicStream(musicRegistry[id]);
220
+ }
221
+
222
+ void SeekMusicStreamW(int id, int position) {
223
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
224
+ float f;
225
+ memcpy(&f, &position, sizeof(float));
226
+ SeekMusicStream(musicRegistry[id], f);
227
+ }
228
+
229
+ void SetMusicVolumeW(int id, int volume) {
230
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
231
+ float f;
232
+ memcpy(&f, &volume, sizeof(float));
233
+ SetMusicVolume(musicRegistry[id], f);
234
+ }
235
+
236
+ void SetMusicPitchW(int id, int pitch) {
237
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
238
+ float f;
239
+ memcpy(&f, &pitch, sizeof(float));
240
+ SetMusicPitch(musicRegistry[id], f);
241
+ }
242
+
243
+ void SetMusicPanW(int id, int pan) {
244
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return;
245
+ float f;
246
+ memcpy(&f, &pan, sizeof(float));
247
+ SetMusicPan(musicRegistry[id], f);
248
+ }
249
+
250
+ int GetMusicTimeLengthW(int id) {
251
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return 0;
252
+ float f = GetMusicTimeLength(musicRegistry[id]);
253
+ int i;
254
+ memcpy(&i, &f, sizeof(float));
255
+ return i;
256
+ }
257
+
258
+ int GetMusicTimePlayedW(int id) {
259
+ if (id < 0 || id >= MAX_MUSIC || !musicUsed[id]) return 0;
260
+ float f = GetMusicTimePlayed(musicRegistry[id]);
261
+ int i;
262
+ memcpy(&i, &f, sizeof(float));
263
+ return i;
264
+ }
265
+
266
+ int LoadAudioStreamW(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels) {
267
+ int slot = audioStreamAlloc();
268
+ if (slot < 0) return -1;
269
+ audioStreamRegistry[slot] = LoadAudioStream(sampleRate, sampleSize, channels);
270
+ return slot;
271
+ }
272
+
273
+ bool IsAudioStreamValidW(int id) {
274
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return false;
275
+ return IsAudioStreamValid(audioStreamRegistry[id]);
276
+ }
277
+
278
+ void UnloadAudioStreamW(int id) {
279
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
280
+ UnloadAudioStream(audioStreamRegistry[id]);
281
+ audioStreamUsed[id] = false;
282
+ }
283
+
284
+ bool IsAudioStreamProcessedW(int id) {
285
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return false;
286
+ return IsAudioStreamProcessed(audioStreamRegistry[id]);
287
+ }
288
+
289
+ void PlayAudioStreamW(int id) {
290
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
291
+ PlayAudioStream(audioStreamRegistry[id]);
292
+ }
293
+
294
+ void PauseAudioStreamW(int id) {
295
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
296
+ PauseAudioStream(audioStreamRegistry[id]);
297
+ }
298
+
299
+ void ResumeAudioStreamW(int id) {
300
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
301
+ ResumeAudioStream(audioStreamRegistry[id]);
302
+ }
303
+
304
+ bool IsAudioStreamPlayingW(int id) {
305
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return false;
306
+ return IsAudioStreamPlaying(audioStreamRegistry[id]);
307
+ }
308
+
309
+ void StopAudioStreamW(int id) {
310
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
311
+ StopAudioStream(audioStreamRegistry[id]);
312
+ }
313
+
314
+ void SetAudioStreamVolumeW(int id, int volume) {
315
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
316
+ float f;
317
+ memcpy(&f, &volume, sizeof(float));
318
+ SetAudioStreamVolume(audioStreamRegistry[id], f);
319
+ }
320
+
321
+ void SetAudioStreamPitchW(int id, int pitch) {
322
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
323
+ float f;
324
+ memcpy(&f, &pitch, sizeof(float));
325
+ SetAudioStreamPitch(audioStreamRegistry[id], f);
326
+ }
327
+
328
+ void SetAudioStreamPanW(int id, int pan) {
329
+ if (id < 0 || id >= MAX_AUDIOSTREAMS || !audioStreamUsed[id]) return;
330
+ float f;
331
+ memcpy(&f, &pan, sizeof(float));
332
+ SetAudioStreamPan(audioStreamRegistry[id], f);
333
+ }
334
+
335
+ void SetAudioStreamBufferSizeDefaultW(int size) {
336
+ SetAudioStreamBufferSizeDefault(size);
337
+ }
338
+
339
+ float* LoadWaveSamplesW(int waveId) {
340
+ if (waveId < 0 || waveId >= MAX_WAVES || !waveUsed[waveId]) return NULL;
341
+ return LoadWaveSamples(waveRegistry[waveId]);
342
+ }
343
+
344
+ void UnloadWaveSamplesW(float* samples) { UnloadWaveSamples(samples); }
package/src/c/camera.c ADDED
@@ -0,0 +1,161 @@
1
+ #include "common.h"
2
+
3
+ void BeginMode2DW(int offX, int offY, int tarX, int tarY, int rotation, int zoom) {
4
+ float r, z;
5
+ memcpy(&r, &rotation, sizeof(float));
6
+ memcpy(&z, &zoom, sizeof(float));
7
+ Camera2D cam = { {offX, offY}, {tarX, tarY}, r, z };
8
+ BeginMode2D(cam);
9
+ }
10
+
11
+ void EndMode2DW() {
12
+ EndMode2D();
13
+ }
14
+
15
+ void BeginMode3DW(int posX, int posY, int posZ, int tarX, int tarY, int tarZ, int upX, int upY, int upZ, int fovy, int projection) {
16
+ Camera3D cam = { {i2f(posX), i2f(posY), i2f(posZ)}, {i2f(tarX), i2f(tarY), i2f(tarZ)}, {i2f(upX), i2f(upY), i2f(upZ)}, i2f(fovy), projection };
17
+ BeginMode3D(cam);
18
+ }
19
+
20
+ void EndMode3DW() {
21
+ EndMode3D();
22
+ }
23
+
24
+ void UpdateCameraW(float* pos, float* tar, float* up, float* fovy, int* projection, int mode) {
25
+ Camera3D cam = {
26
+ {pos[0], pos[1], pos[2]},
27
+ {tar[0], tar[1], tar[2]},
28
+ {up[0], up[1], up[2]},
29
+ fovy[0],
30
+ projection[0]
31
+ };
32
+ UpdateCamera(&cam, mode);
33
+ pos[0] = cam.position.x; pos[1] = cam.position.y; pos[2] = cam.position.z;
34
+ tar[0] = cam.target.x; tar[1] = cam.target.y; tar[2] = cam.target.z;
35
+ up[0] = cam.up.x; up[1] = cam.up.y; up[2] = cam.up.z;
36
+ fovy[0] = cam.fovy;
37
+ projection[0] = cam.projection;
38
+ }
39
+
40
+ void UpdateCameraProW(float* pos, float* tar, float* up, float* fovy, int* projection,
41
+ float mx, float my, float mz, float rx, float ry, float rz, float zoom) {
42
+ Camera3D cam = {
43
+ {pos[0], pos[1], pos[2]},
44
+ {tar[0], tar[1], tar[2]},
45
+ {up[0], up[1], up[2]},
46
+ fovy[0],
47
+ projection[0]
48
+ };
49
+ UpdateCameraPro(&cam, (Vector3){mx, my, mz}, (Vector3){rx, ry, rz}, zoom);
50
+ pos[0] = cam.position.x; pos[1] = cam.position.y; pos[2] = cam.position.z;
51
+ tar[0] = cam.target.x; tar[1] = cam.target.y; tar[2] = cam.target.z;
52
+ up[0] = cam.up.x; up[1] = cam.up.y; up[2] = cam.up.z;
53
+ fovy[0] = cam.fovy;
54
+ projection[0] = cam.projection;
55
+ }
56
+
57
+ void GetScreenToWorldRayW(float* outPos, float* outDir, int screenX, int screenY,
58
+ int camPosX, int camPosY, int camPosZ, int camTarX, int camTarY, int camTarZ,
59
+ int camUpX, int camUpY, int camUpZ, int camFovy, int camProj) {
60
+ Camera3D cam = {
61
+ {i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
62
+ {i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
63
+ {i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
64
+ i2f(camFovy), camProj
65
+ };
66
+ Ray r = GetScreenToWorldRay((Vector2){screenX, screenY}, cam);
67
+ outPos[0] = r.position.x; outPos[1] = r.position.y; outPos[2] = r.position.z;
68
+ outDir[0] = r.direction.x; outDir[1] = r.direction.y; outDir[2] = r.direction.z;
69
+ }
70
+
71
+ void GetWorldToScreenW(float* out, int posX, int posY, int posZ,
72
+ int camPosX, int camPosY, int camPosZ, int camTarX, int camTarY, int camTarZ,
73
+ int camUpX, int camUpY, int camUpZ, int camFovy, int camProj) {
74
+ Camera3D cam = {
75
+ {i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
76
+ {i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
77
+ {i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
78
+ i2f(camFovy), camProj
79
+ };
80
+ Vector2 v = GetWorldToScreen((Vector3){i2f(posX), i2f(posY), i2f(posZ)}, cam);
81
+ out[0] = v.x; out[1] = v.y;
82
+ }
83
+
84
+ void GetWorldToScreen2DW(float* out, int posX, int posY,
85
+ int offX, int offY, int tarX, int tarY, int rotation, int zoom) {
86
+ float r, z;
87
+ memcpy(&r, &rotation, sizeof(float));
88
+ memcpy(&z, &zoom, sizeof(float));
89
+ Camera2D cam = { {offX, offY}, {tarX, tarY}, r, z };
90
+ Vector2 v = GetWorldToScreen2D((Vector2){posX, posY}, cam);
91
+ out[0] = v.x; out[1] = v.y;
92
+ }
93
+
94
+ void GetScreenToWorld2DW(float* out, int posX, int posY,
95
+ int offX, int offY, int tarX, int tarY, int rotation, int zoom) {
96
+ float r, z;
97
+ memcpy(&r, &rotation, sizeof(float));
98
+ memcpy(&z, &zoom, sizeof(float));
99
+ Camera2D cam = { {offX, offY}, {tarX, tarY}, r, z };
100
+ Vector2 v = GetScreenToWorld2D((Vector2){posX, posY}, cam);
101
+ out[0] = v.x; out[1] = v.y;
102
+ }
103
+
104
+ void GetScreenToWorldRayExW(float* outPos, float* outDir,
105
+ int screenX, int screenY, int screenW, int screenH,
106
+ int camPosX, int camPosY, int camPosZ,
107
+ int camTarX, int camTarY, int camTarZ,
108
+ int camUpX, int camUpY, int camUpZ,
109
+ int camFovy, int camProj) {
110
+ Camera3D cam = {
111
+ {i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
112
+ {i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
113
+ {i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
114
+ i2f(camFovy), camProj
115
+ };
116
+ Ray r = GetScreenToWorldRayEx((Vector2){screenX, screenY}, cam, screenW, screenH);
117
+ outPos[0] = r.position.x; outPos[1] = r.position.y; outPos[2] = r.position.z;
118
+ outDir[0] = r.direction.x; outDir[1] = r.direction.y; outDir[2] = r.direction.z;
119
+ }
120
+
121
+ void GetWorldToScreenExW(float* out,
122
+ int posX, int posY, int posZ,
123
+ int camPosX, int camPosY, int camPosZ,
124
+ int camTarX, int camTarY, int camTarZ,
125
+ int camUpX, int camUpY, int camUpZ,
126
+ int camFovy, int camProj,
127
+ int screenW, int screenH) {
128
+ Camera3D cam = {
129
+ {i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
130
+ {i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
131
+ {i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
132
+ i2f(camFovy), camProj
133
+ };
134
+ Vector2 v = GetWorldToScreenEx((Vector3){i2f(posX), i2f(posY), i2f(posZ)}, cam, screenW, screenH);
135
+ out[0] = v.x; out[1] = v.y;
136
+ }
137
+
138
+ void GetCameraMatrixW(float* out,
139
+ int camPosX, int camPosY, int camPosZ,
140
+ int camTarX, int camTarY, int camTarZ,
141
+ int camUpX, int camUpY, int camUpZ,
142
+ int camFovy, int camProj) {
143
+ Camera3D cam = {
144
+ {i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
145
+ {i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
146
+ {i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
147
+ i2f(camFovy), camProj
148
+ };
149
+ Matrix m = GetCameraMatrix(cam);
150
+ memcpy(out, &m, sizeof(Matrix));
151
+ }
152
+
153
+ void GetCameraMatrix2DW(float* out,
154
+ int offX, int offY, int tarX, int tarY, int rotation, int zoom) {
155
+ float r, z;
156
+ memcpy(&r, &rotation, sizeof(float));
157
+ memcpy(&z, &zoom, sizeof(float));
158
+ Camera2D cam = { {offX, offY}, {tarX, tarY}, r, z };
159
+ Matrix m = GetCameraMatrix2D(cam);
160
+ memcpy(out, &m, sizeof(Matrix));
161
+ }
@@ -0,0 +1,176 @@
1
+ #include "common.h"
2
+
3
+ bool CheckCollisionRecsW(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) {
4
+ Rectangle r1 = { x1, y1, w1, h1 };
5
+ Rectangle r2 = { x2, y2, w2, h2 };
6
+ return CheckCollisionRecs(r1, r2);
7
+ }
8
+
9
+ bool CheckCollisionCirclesW(int cx1, int cy1, int r1, int cx2, int cy2, int r2) {
10
+ return CheckCollisionCircles((Vector2){cx1, cy1}, r1, (Vector2){cx2, cy2}, r2);
11
+ }
12
+
13
+ bool CheckCollisionCircleRecW(int cx, int cy, int radius, int rx, int ry, int rw, int rh) {
14
+ return CheckCollisionCircleRec((Vector2){cx, cy}, radius, (Rectangle){rx, ry, rw, rh});
15
+ }
16
+
17
+ bool CheckCollisionCircleLineW(int cx, int cy, int radius, int p1x, int p1y, int p2x, int p2y) {
18
+ return CheckCollisionCircleLine((Vector2){cx, cy}, radius, (Vector2){p1x, p1y}, (Vector2){p2x, p2y});
19
+ }
20
+
21
+ bool CheckCollisionPointRecW(int px, int py, int rx, int ry, int rw, int rh) {
22
+ return CheckCollisionPointRec((Vector2){px, py}, (Rectangle){rx, ry, rw, rh});
23
+ }
24
+
25
+ bool CheckCollisionPointCircleW(int px, int py, int cx, int cy, int radius) {
26
+ return CheckCollisionPointCircle((Vector2){px, py}, (Vector2){cx, cy}, radius);
27
+ }
28
+
29
+ bool CheckCollisionPointTriangleW(int px, int py, int p1x, int p1y, int p2x, int p2y, int p3x, int p3y) {
30
+ return CheckCollisionPointTriangle((Vector2){px, py}, (Vector2){p1x, p1y}, (Vector2){p2x, p2y}, (Vector2){p3x, p3y});
31
+ }
32
+
33
+ bool CheckCollisionPointLineW(int px, int py, int p1x, int p1y, int p2x, int p2y, int threshold) {
34
+ return CheckCollisionPointLine((Vector2){px, py}, (Vector2){p1x, p1y}, (Vector2){p2x, p2y}, threshold);
35
+ }
36
+
37
+ bool CheckCollisionPointPolyW(int px, int py, const float* points, int pointCount) {
38
+ return CheckCollisionPointPoly((Vector2){px, py}, (const Vector2*)points, pointCount);
39
+ }
40
+
41
+ bool CheckCollisionLinesW(float* out, int s1x, int s1y, int e1x, int e1y, int s2x, int s2y, int e2x, int e2y) {
42
+ Vector2 cp;
43
+ bool result = CheckCollisionLines((Vector2){s1x, s1y}, (Vector2){e1x, e1y}, (Vector2){s2x, s2y}, (Vector2){e2x, e2y}, &cp);
44
+ out[0] = cp.x;
45
+ out[1] = cp.y;
46
+ return result;
47
+ }
48
+
49
+ void GetCollisionRecW(float* out, int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) {
50
+ Rectangle r1 = { x1, y1, w1, h1 };
51
+ Rectangle r2 = { x2, y2, w2, h2 };
52
+ Rectangle result = GetCollisionRec(r1, r2);
53
+ out[0] = result.x;
54
+ out[1] = result.y;
55
+ out[2] = result.width;
56
+ out[3] = result.height;
57
+ }
58
+
59
+ bool CheckCollisionSpheresW(int cx1, int cy1, int cz1, int r1, int cx2, int cy2, int cz2, int r2) {
60
+ return CheckCollisionSpheres(
61
+ (Vector3){i2f(cx1), i2f(cy1), i2f(cz1)}, i2f(r1),
62
+ (Vector3){i2f(cx2), i2f(cy2), i2f(cz2)}, i2f(r2));
63
+ }
64
+
65
+ bool CheckCollisionBoxesW(
66
+ int minX1, int minY1, int minZ1, int maxX1, int maxY1, int maxZ1,
67
+ int minX2, int minY2, int minZ2, int maxX2, int maxY2, int maxZ2) {
68
+ BoundingBox bb1 = {
69
+ {i2f(minX1), i2f(minY1), i2f(minZ1)},
70
+ {i2f(maxX1), i2f(maxY1), i2f(maxZ1)}
71
+ };
72
+ BoundingBox bb2 = {
73
+ {i2f(minX2), i2f(minY2), i2f(minZ2)},
74
+ {i2f(maxX2), i2f(maxY2), i2f(maxZ2)}
75
+ };
76
+ return CheckCollisionBoxes(bb1, bb2);
77
+ }
78
+
79
+ bool CheckCollisionBoxSphereW(
80
+ int minX, int minY, int minZ, int maxX, int maxY, int maxZ,
81
+ int cx, int cy, int cz, int radius) {
82
+ BoundingBox bb = {
83
+ {i2f(minX), i2f(minY), i2f(minZ)},
84
+ {i2f(maxX), i2f(maxY), i2f(maxZ)}
85
+ };
86
+ return CheckCollisionBoxSphere(bb,
87
+ (Vector3){i2f(cx), i2f(cy), i2f(cz)}, i2f(radius));
88
+ }
89
+
90
+ void GetRayCollisionSphereW(bool* outHit, float* outDist, float* outPt, float* outNorm,
91
+ int rPx, int rPy, int rPz, int rDx, int rDy, int rDz,
92
+ int cx, int cy, int cz, int radius) {
93
+ Ray ray = {
94
+ {i2f(rPx), i2f(rPy), i2f(rPz)},
95
+ {i2f(rDx), i2f(rDy), i2f(rDz)}
96
+ };
97
+ RayCollision rc = GetRayCollisionSphere(ray,
98
+ (Vector3){i2f(cx), i2f(cy), i2f(cz)}, i2f(radius));
99
+ *outHit = rc.hit;
100
+ outDist[0] = rc.distance;
101
+ outPt[0] = rc.point.x; outPt[1] = rc.point.y; outPt[2] = rc.point.z;
102
+ outNorm[0] = rc.normal.x; outNorm[1] = rc.normal.y; outNorm[2] = rc.normal.z;
103
+ }
104
+
105
+ void GetRayCollisionBoxW(bool* outHit, float* outDist, float* outPt, float* outNorm,
106
+ int rPx, int rPy, int rPz, int rDx, int rDy, int rDz,
107
+ int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
108
+ Ray ray = {
109
+ {i2f(rPx), i2f(rPy), i2f(rPz)},
110
+ {i2f(rDx), i2f(rDy), i2f(rDz)}
111
+ };
112
+ BoundingBox bb = {
113
+ {i2f(minX), i2f(minY), i2f(minZ)},
114
+ {i2f(maxX), i2f(maxY), i2f(maxZ)}
115
+ };
116
+ RayCollision rc = GetRayCollisionBox(ray, bb);
117
+ *outHit = rc.hit;
118
+ outDist[0] = rc.distance;
119
+ outPt[0] = rc.point.x; outPt[1] = rc.point.y; outPt[2] = rc.point.z;
120
+ outNorm[0] = rc.normal.x; outNorm[1] = rc.normal.y; outNorm[2] = rc.normal.z;
121
+ }
122
+
123
+ void GetRayCollisionTriangleW(bool* outHit, float* outDist, float* outPt, float* outNorm,
124
+ int rPx, int rPy, int rPz, int rDx, int rDy, int rDz,
125
+ int p1x, int p1y, int p1z, int p2x, int p2y, int p2z, int p3x, int p3y, int p3z) {
126
+ Ray ray = {
127
+ {i2f(rPx), i2f(rPy), i2f(rPz)},
128
+ {i2f(rDx), i2f(rDy), i2f(rDz)}
129
+ };
130
+ RayCollision rc = GetRayCollisionTriangle(ray,
131
+ (Vector3){i2f(p1x), i2f(p1y), i2f(p1z)},
132
+ (Vector3){i2f(p2x), i2f(p2y), i2f(p2z)},
133
+ (Vector3){i2f(p3x), i2f(p3y), i2f(p3z)});
134
+ *outHit = rc.hit;
135
+ outDist[0] = rc.distance;
136
+ outPt[0] = rc.point.x; outPt[1] = rc.point.y; outPt[2] = rc.point.z;
137
+ outNorm[0] = rc.normal.x; outNorm[1] = rc.normal.y; outNorm[2] = rc.normal.z;
138
+ }
139
+
140
+ void GetRayCollisionQuadW(bool* outHit, float* outDist, float* outPt, float* outNorm,
141
+ int rPx, int rPy, int rPz, int rDx, int rDy, int rDz,
142
+ int p1x, int p1y, int p1z, int p2x, int p2y, int p2z,
143
+ int p3x, int p3y, int p3z, int p4x, int p4y, int p4z) {
144
+ Ray ray = {
145
+ {i2f(rPx), i2f(rPy), i2f(rPz)},
146
+ {i2f(rDx), i2f(rDy), i2f(rDz)}
147
+ };
148
+ RayCollision rc = GetRayCollisionQuad(ray,
149
+ (Vector3){i2f(p1x), i2f(p1y), i2f(p1z)},
150
+ (Vector3){i2f(p2x), i2f(p2y), i2f(p2z)},
151
+ (Vector3){i2f(p3x), i2f(p3y), i2f(p3z)},
152
+ (Vector3){i2f(p4x), i2f(p4y), i2f(p4z)});
153
+ *outHit = rc.hit;
154
+ outDist[0] = rc.distance;
155
+ outPt[0] = rc.point.x; outPt[1] = rc.point.y; outPt[2] = rc.point.z;
156
+ outNorm[0] = rc.normal.x; outNorm[1] = rc.normal.y; outNorm[2] = rc.normal.z;
157
+ }
158
+
159
+ void GetRayCollisionMeshW(bool* outHit, float* outDist, float* outPt, float* outNorm,
160
+ int rPx, int rPy, int rPz, int rDx, int rDy, int rDz,
161
+ int meshId,
162
+ int im0, int im4, int im8, int im12,
163
+ int im1, int im5, int im9, int im13,
164
+ int im2, int im6, int im10, int im14,
165
+ int im3, int im7, int im11, int im15) {
166
+ Ray ray = { { i2f(rPx), i2f(rPy), i2f(rPz) }, { i2f(rDx), i2f(rDy), i2f(rDz) } };
167
+ Matrix transform = { i2f(im0), i2f(im1), i2f(im2), i2f(im3), i2f(im4), i2f(im5), i2f(im6), i2f(im7), i2f(im8), i2f(im9), i2f(im10), i2f(im11), i2f(im12), i2f(im13), i2f(im14), i2f(im15) };
168
+ if (meshId < 0 || meshId >= MAX_MESHES || !meshUsed[meshId]) {
169
+ *outHit = false; *outDist = 0; return;
170
+ }
171
+ RayCollision rc = GetRayCollisionMesh(ray, meshRegistry[meshId], transform);
172
+ *outHit = rc.hit;
173
+ *outDist = rc.distance;
174
+ outPt[0] = rc.point.x; outPt[1] = rc.point.y; outPt[2] = rc.point.z;
175
+ outNorm[0] = rc.normal.x; outNorm[1] = rc.normal.y; outNorm[2] = rc.normal.z;
176
+ }