@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/README.md +31 -0
- package/package.json +39 -0
- package/src/Raylib.ts +3679 -0
- package/src/c/audio.c +344 -0
- package/src/c/camera.c +161 -0
- package/src/c/collision.c +176 -0
- package/src/c/color.c +100 -0
- package/src/c/common.h +67 -0
- package/src/c/draw3d.c +222 -0
- package/src/c/filesystem.c +36 -0
- package/src/c/font.c +163 -0
- package/src/c/image.c +458 -0
- package/src/c/input.c +85 -0
- package/src/c/model.c +243 -0
- package/src/c/registries.c +111 -0
- package/src/c/shader.c +56 -0
- package/src/c/shapes.c +283 -0
- package/src/c/texture.c +139 -0
- package/src/c/window.c +150 -0
- package/src/constants.ts +396 -0
- package/src/index.ts +29 -0
- package/src/main.c +15 -0
- package/src/main.d.ts +4 -0
- package/src/symbols/audio.ts +64 -0
- package/src/symbols/camera.ts +46 -0
- package/src/symbols/collision.ts +116 -0
- package/src/symbols/color.ts +22 -0
- package/src/symbols/draw3d.ts +137 -0
- package/src/symbols/filesystem.ts +30 -0
- package/src/symbols/font.ts +40 -0
- package/src/symbols/image.ts +90 -0
- package/src/symbols/input.ts +51 -0
- package/src/symbols/model.ts +38 -0
- package/src/symbols/shader.ts +15 -0
- package/src/symbols/shapes.ts +92 -0
- package/src/symbols/texture.ts +56 -0
- package/src/symbols/window.ts +83 -0
- package/src/symbols.ts +131 -0
- package/src/types.ts +73 -0
- package/src/utils.ts +25 -0
package/src/c/color.c
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#include "common.h"
|
|
2
|
+
|
|
3
|
+
int ColorToIntW(Color color) { return ColorToInt(color); }
|
|
4
|
+
|
|
5
|
+
void ColorNormalizeW(float* out, Color color) {
|
|
6
|
+
Vector4 v = ColorNormalize(color);
|
|
7
|
+
out[0] = v.x; out[1] = v.y; out[2] = v.z; out[3] = v.w;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
int ColorFromNormalizedW(int x, int y, int z, int w) {
|
|
11
|
+
float fx, fy, fz, fw;
|
|
12
|
+
memcpy(&fx, &x, sizeof(float));
|
|
13
|
+
memcpy(&fy, &y, sizeof(float));
|
|
14
|
+
memcpy(&fz, &z, sizeof(float));
|
|
15
|
+
memcpy(&fw, &w, sizeof(float));
|
|
16
|
+
Color c = ColorFromNormalized((Vector4){fx, fy, fz, fw});
|
|
17
|
+
return *((int*)&c);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void ColorToHSWW(float* out, Color color) {
|
|
21
|
+
Vector3 v = ColorToHSV(color);
|
|
22
|
+
out[0] = v.x; out[1] = v.y; out[2] = v.z;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
int ColorFromHSWW(int hue, int saturation, int value) {
|
|
26
|
+
float h, s, v;
|
|
27
|
+
memcpy(&h, &hue, sizeof(float));
|
|
28
|
+
memcpy(&s, &saturation, sizeof(float));
|
|
29
|
+
memcpy(&v, &value, sizeof(float));
|
|
30
|
+
Color c = ColorFromHSV(h, s, v);
|
|
31
|
+
return *((int*)&c);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
int ColorTintW(Color color, Color tint) {
|
|
35
|
+
Color c = ColorTint(color, tint);
|
|
36
|
+
return *((int*)&c);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
int ColorBrightnessW(Color color, int factor) {
|
|
40
|
+
float f;
|
|
41
|
+
memcpy(&f, &factor, sizeof(float));
|
|
42
|
+
Color c = ColorBrightness(color, f);
|
|
43
|
+
return *((int*)&c);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
int ColorContrastW(Color color, int contrast) {
|
|
47
|
+
float c_val;
|
|
48
|
+
memcpy(&c_val, &contrast, sizeof(float));
|
|
49
|
+
Color c = ColorContrast(color, c_val);
|
|
50
|
+
return *((int*)&c);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
int ColorAlphaW(Color color, int alpha) {
|
|
54
|
+
float a;
|
|
55
|
+
memcpy(&a, &alpha, sizeof(float));
|
|
56
|
+
Color c = ColorAlpha(color, a);
|
|
57
|
+
return *((int*)&c);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
int ColorAlphaBlendW(Color dst, Color src, Color tint) {
|
|
61
|
+
Color c = ColorAlphaBlend(dst, src, tint);
|
|
62
|
+
return *((int*)&c);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
int ColorLerpW(Color color1, Color color2, int factor) {
|
|
66
|
+
float f;
|
|
67
|
+
memcpy(&f, &factor, sizeof(float));
|
|
68
|
+
Color c = ColorLerp(color1, color2, f);
|
|
69
|
+
return *((int*)&c);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
int GetColorW(unsigned int hexValue) {
|
|
73
|
+
Color c = GetColor(hexValue);
|
|
74
|
+
return *((int*)&c);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
int FadeW(Color color, int alpha) {
|
|
78
|
+
float a;
|
|
79
|
+
memcpy(&a, &alpha, sizeof(float));
|
|
80
|
+
Color c = Fade(color, a);
|
|
81
|
+
return *((int*)&c);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
bool ColorIsEqualW(Color col1, Color col2) { return ColorIsEqual(col1, col2); }
|
|
85
|
+
|
|
86
|
+
int GetPixelDataSizeW(int width, int height, int format) { return GetPixelDataSize(width, height, format); }
|
|
87
|
+
|
|
88
|
+
void ColorToHSVW(float* out, Color color) {
|
|
89
|
+
Vector3 v = ColorToHSV(color);
|
|
90
|
+
out[0] = v.x; out[1] = v.y; out[2] = v.z;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
int ColorFromHSVW(int hue, int saturation, int value) {
|
|
94
|
+
float h, s, v;
|
|
95
|
+
memcpy(&h, &hue, sizeof(float));
|
|
96
|
+
memcpy(&s, &saturation, sizeof(float));
|
|
97
|
+
memcpy(&v, &value, sizeof(float));
|
|
98
|
+
Color c = ColorFromHSV(h, s, v);
|
|
99
|
+
return *((int*)&c);
|
|
100
|
+
}
|
package/src/c/common.h
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#ifndef COMMON_H
|
|
2
|
+
#define COMMON_H
|
|
3
|
+
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <raylib.h>
|
|
6
|
+
|
|
7
|
+
static inline float i2f(int i) { float f; memcpy(&f, &i, sizeof(float)); return f; }
|
|
8
|
+
|
|
9
|
+
#ifndef CONFIG_H
|
|
10
|
+
#define MAX_MODELS 64
|
|
11
|
+
#define MAX_FONTS 32
|
|
12
|
+
#define MAX_IMAGES 128
|
|
13
|
+
#define MAX_MESHES 64
|
|
14
|
+
#define MAX_MATERIALS 32
|
|
15
|
+
#define MAX_ANIMATIONS 32
|
|
16
|
+
#define MAX_SHADERS 32
|
|
17
|
+
#define MAX_WAVES 32
|
|
18
|
+
#define MAX_SOUNDS 32
|
|
19
|
+
#define MAX_MUSIC 16
|
|
20
|
+
#define MAX_AUDIOSTREAMS 16
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
extern Model modelRegistry[MAX_MODELS];
|
|
24
|
+
extern bool modelUsed[MAX_MODELS];
|
|
25
|
+
int modelAlloc(void);
|
|
26
|
+
|
|
27
|
+
extern Font fontRegistry[MAX_FONTS];
|
|
28
|
+
extern bool fontUsed[MAX_FONTS];
|
|
29
|
+
int fontAlloc(void);
|
|
30
|
+
|
|
31
|
+
extern Image imageRegistry[MAX_IMAGES];
|
|
32
|
+
extern bool imageUsed[MAX_IMAGES];
|
|
33
|
+
int imageAlloc(void);
|
|
34
|
+
|
|
35
|
+
extern Mesh meshRegistry[MAX_MESHES];
|
|
36
|
+
extern bool meshUsed[MAX_MESHES];
|
|
37
|
+
int meshAlloc(void);
|
|
38
|
+
|
|
39
|
+
extern Material materialRegistry[MAX_MATERIALS];
|
|
40
|
+
extern bool materialUsed[MAX_MATERIALS];
|
|
41
|
+
int materialAlloc(void);
|
|
42
|
+
|
|
43
|
+
extern ModelAnimation animRegistry[MAX_ANIMATIONS];
|
|
44
|
+
extern bool animUsed[MAX_ANIMATIONS];
|
|
45
|
+
int animAlloc(void);
|
|
46
|
+
|
|
47
|
+
extern Shader shaderRegistry[MAX_SHADERS];
|
|
48
|
+
extern bool shaderUsed[MAX_SHADERS];
|
|
49
|
+
int shaderAlloc(void);
|
|
50
|
+
|
|
51
|
+
extern Wave waveRegistry[MAX_WAVES];
|
|
52
|
+
extern bool waveUsed[MAX_WAVES];
|
|
53
|
+
int waveAlloc(void);
|
|
54
|
+
|
|
55
|
+
extern Sound soundRegistry[MAX_SOUNDS];
|
|
56
|
+
extern bool soundUsed[MAX_SOUNDS];
|
|
57
|
+
int soundAlloc(void);
|
|
58
|
+
|
|
59
|
+
extern Music musicRegistry[MAX_MUSIC];
|
|
60
|
+
extern bool musicUsed[MAX_MUSIC];
|
|
61
|
+
int musicAlloc(void);
|
|
62
|
+
|
|
63
|
+
extern AudioStream audioStreamRegistry[MAX_AUDIOSTREAMS];
|
|
64
|
+
extern bool audioStreamUsed[MAX_AUDIOSTREAMS];
|
|
65
|
+
int audioStreamAlloc(void);
|
|
66
|
+
|
|
67
|
+
#endif
|
package/src/c/draw3d.c
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#include "common.h"
|
|
2
|
+
|
|
3
|
+
void DrawLine3DW(int sx, int sy, int sz, int ex, int ey, int ez, Color color) {
|
|
4
|
+
DrawLine3D((Vector3){i2f(sx), i2f(sy), i2f(sz)}, (Vector3){i2f(ex), i2f(ey), i2f(ez)}, color);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
void DrawPoint3DW(int px, int py, int pz, Color color) {
|
|
8
|
+
DrawPoint3D((Vector3){i2f(px), i2f(py), i2f(pz)}, color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
void DrawCircle3DW(int cx, int cy, int cz, int radius, int rax, int ray_, int raz, int angle, Color color) {
|
|
12
|
+
DrawCircle3D((Vector3){i2f(cx), i2f(cy), i2f(cz)}, i2f(radius), (Vector3){i2f(rax), i2f(ray_), i2f(raz)}, i2f(angle), color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void DrawTriangle3DW(int v1x, int v1y, int v1z, int v2x, int v2y, int v2z, int v3x, int v3y, int v3z, Color color) {
|
|
16
|
+
DrawTriangle3D(
|
|
17
|
+
(Vector3){i2f(v1x), i2f(v1y), i2f(v1z)},
|
|
18
|
+
(Vector3){i2f(v2x), i2f(v2y), i2f(v2z)},
|
|
19
|
+
(Vector3){i2f(v3x), i2f(v3y), i2f(v3z)},
|
|
20
|
+
color
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void DrawTriangleStrip3DW(const float* points, int pointCount, Color color) {
|
|
25
|
+
DrawTriangleStrip3D((const Vector3*)points, pointCount, color);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void DrawCubeW(int px, int py, int pz, int w, int h, int l, Color color) {
|
|
29
|
+
DrawCube((Vector3){i2f(px), i2f(py), i2f(pz)}, i2f(w), i2f(h), i2f(l), color);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void DrawCubeVW(int px, int py, int pz, int sx, int sy, int sz, Color color) {
|
|
33
|
+
DrawCubeV((Vector3){i2f(px), i2f(py), i2f(pz)}, (Vector3){i2f(sx), i2f(sy), i2f(sz)}, color);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void DrawCubeWiresW(int px, int py, int pz, int w, int h, int l, Color color) {
|
|
37
|
+
DrawCubeWires((Vector3){i2f(px), i2f(py), i2f(pz)}, i2f(w), i2f(h), i2f(l), color);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void DrawCubeWiresVW(int px, int py, int pz, int sx, int sy, int sz, Color color) {
|
|
41
|
+
DrawCubeWiresV((Vector3){i2f(px), i2f(py), i2f(pz)}, (Vector3){i2f(sx), i2f(sy), i2f(sz)}, color);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void DrawSphereW(int cx, int cy, int cz, int radius, Color color) {
|
|
45
|
+
DrawSphere((Vector3){i2f(cx), i2f(cy), i2f(cz)}, i2f(radius), color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void DrawSphereExW(int cx, int cy, int cz, int radius, int rings, int slices, Color color) {
|
|
49
|
+
DrawSphereEx((Vector3){i2f(cx), i2f(cy), i2f(cz)}, i2f(radius), rings, slices, color);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void DrawSphereWiresW(int cx, int cy, int cz, int radius, int rings, int slices, Color color) {
|
|
53
|
+
DrawSphereWires((Vector3){i2f(cx), i2f(cy), i2f(cz)}, i2f(radius), rings, slices, color);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void DrawCylinderW(int px, int py, int pz, int rt, int rb, int h, int slices, Color color) {
|
|
57
|
+
DrawCylinder((Vector3){i2f(px), i2f(py), i2f(pz)}, i2f(rt), i2f(rb), i2f(h), slices, color);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void DrawCylinderExW(int sx, int sy, int sz, int ex, int ey, int ez, int sr, int er, int sides, Color color) {
|
|
61
|
+
DrawCylinderEx((Vector3){i2f(sx), i2f(sy), i2f(sz)}, (Vector3){i2f(ex), i2f(ey), i2f(ez)}, i2f(sr), i2f(er), sides, color);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void DrawCylinderWiresW(int px, int py, int pz, int rt, int rb, int h, int slices, Color color) {
|
|
65
|
+
DrawCylinderWires((Vector3){i2f(px), i2f(py), i2f(pz)}, i2f(rt), i2f(rb), i2f(h), slices, color);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void DrawCylinderWiresExW(int sx, int sy, int sz, int ex, int ey, int ez, int sr, int er, int sides, Color color) {
|
|
69
|
+
DrawCylinderWiresEx((Vector3){i2f(sx), i2f(sy), i2f(sz)}, (Vector3){i2f(ex), i2f(ey), i2f(ez)}, i2f(sr), i2f(er), sides, color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void DrawCapsuleW(int sx, int sy, int sz, int ex, int ey, int ez, int radius, int slices, int rings, Color color) {
|
|
73
|
+
DrawCapsule((Vector3){i2f(sx), i2f(sy), i2f(sz)}, (Vector3){i2f(ex), i2f(ey), i2f(ez)}, i2f(radius), slices, rings, color);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void DrawCapsuleWiresW(int sx, int sy, int sz, int ex, int ey, int ez, int radius, int slices, int rings, Color color) {
|
|
77
|
+
DrawCapsuleWires((Vector3){i2f(sx), i2f(sy), i2f(sz)}, (Vector3){i2f(ex), i2f(ey), i2f(ez)}, i2f(radius), slices, rings, color);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void DrawPlaneW(int cx, int cy, int cz, int sw, int sh, Color color) {
|
|
81
|
+
DrawPlane((Vector3){i2f(cx), i2f(cy), i2f(cz)}, (Vector2){i2f(sw), i2f(sh)}, color);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void DrawRayW(int px, int py, int pz, int dx, int dy, int dz, Color color) {
|
|
85
|
+
Ray ray = { {i2f(px), i2f(py), i2f(pz)}, {i2f(dx), i2f(dy), i2f(dz)} };
|
|
86
|
+
DrawRay(ray, color);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void DrawGridW(int slices, int spacing) {
|
|
90
|
+
DrawGrid(slices, spacing);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void DrawModelW(int id, int posX, int posY, int posZ, int scale, Color tint) {
|
|
94
|
+
if (id < 0 || id >= MAX_MODELS || !modelUsed[id]) return;
|
|
95
|
+
float s;
|
|
96
|
+
memcpy(&s, &scale, sizeof(float));
|
|
97
|
+
DrawModel(modelRegistry[id], (Vector3){i2f(posX), i2f(posY), i2f(posZ)}, s, tint);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void DrawModelExW(int id,
|
|
101
|
+
int posX, int posY, int posZ,
|
|
102
|
+
int rotAxisX, int rotAxisY, int rotAxisZ, int rotAngle,
|
|
103
|
+
int scaleX, int scaleY, int scaleZ, Color tint) {
|
|
104
|
+
if (id < 0 || id >= MAX_MODELS || !modelUsed[id]) return;
|
|
105
|
+
float ra, sx, sy, sz;
|
|
106
|
+
memcpy(&ra, &rotAngle, sizeof(float));
|
|
107
|
+
memcpy(&sx, &scaleX, sizeof(float));
|
|
108
|
+
memcpy(&sy, &scaleY, sizeof(float));
|
|
109
|
+
memcpy(&sz, &scaleZ, sizeof(float));
|
|
110
|
+
DrawModelEx(modelRegistry[id],
|
|
111
|
+
(Vector3){i2f(posX), i2f(posY), i2f(posZ)},
|
|
112
|
+
(Vector3){i2f(rotAxisX), i2f(rotAxisY), i2f(rotAxisZ)}, ra,
|
|
113
|
+
(Vector3){sx, sy, sz}, tint);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void DrawModelWiresW(int id, int posX, int posY, int posZ, int scale, Color tint) {
|
|
117
|
+
if (id < 0 || id >= MAX_MODELS || !modelUsed[id]) return;
|
|
118
|
+
float s;
|
|
119
|
+
memcpy(&s, &scale, sizeof(float));
|
|
120
|
+
DrawModelWires(modelRegistry[id], (Vector3){i2f(posX), i2f(posY), i2f(posZ)}, s, tint);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void DrawModelWiresExW(int id,
|
|
124
|
+
int posX, int posY, int posZ,
|
|
125
|
+
int rotAxisX, int rotAxisY, int rotAxisZ, int rotAngle,
|
|
126
|
+
int scaleX, int scaleY, int scaleZ, Color tint) {
|
|
127
|
+
if (id < 0 || id >= MAX_MODELS || !modelUsed[id]) return;
|
|
128
|
+
float ra, sx, sy, sz;
|
|
129
|
+
memcpy(&ra, &rotAngle, sizeof(float));
|
|
130
|
+
memcpy(&sx, &scaleX, sizeof(float));
|
|
131
|
+
memcpy(&sy, &scaleY, sizeof(float));
|
|
132
|
+
memcpy(&sz, &scaleZ, sizeof(float));
|
|
133
|
+
DrawModelWiresEx(modelRegistry[id],
|
|
134
|
+
(Vector3){i2f(posX), i2f(posY), i2f(posZ)},
|
|
135
|
+
(Vector3){i2f(rotAxisX), i2f(rotAxisY), i2f(rotAxisZ)}, ra,
|
|
136
|
+
(Vector3){sx, sy, sz}, tint);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
void DrawBoundingBoxW(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Color color) {
|
|
140
|
+
BoundingBox bb = {
|
|
141
|
+
{i2f(minX), i2f(minY), i2f(minZ)},
|
|
142
|
+
{i2f(maxX), i2f(maxY), i2f(maxZ)}
|
|
143
|
+
};
|
|
144
|
+
DrawBoundingBox(bb, color);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
void DrawBillboardW(
|
|
148
|
+
int camPosX, int camPosY, int camPosZ,
|
|
149
|
+
int camTarX, int camTarY, int camTarZ,
|
|
150
|
+
int camUpX, int camUpY, int camUpZ,
|
|
151
|
+
int camFovy, int camProj,
|
|
152
|
+
unsigned int texId, int texW, int texH,
|
|
153
|
+
int posX, int posY, int posZ,
|
|
154
|
+
int scale, Color tint) {
|
|
155
|
+
Camera3D cam = {
|
|
156
|
+
{i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
|
|
157
|
+
{i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
|
|
158
|
+
{i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
|
|
159
|
+
i2f(camFovy), camProj
|
|
160
|
+
};
|
|
161
|
+
Texture2D tex = { texId, texW, texH, 1, 7 };
|
|
162
|
+
float s;
|
|
163
|
+
memcpy(&s, &scale, sizeof(float));
|
|
164
|
+
DrawBillboard(cam, tex, (Vector3){i2f(posX), i2f(posY), i2f(posZ)}, s, tint);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void DrawBillboardRecW(
|
|
168
|
+
int camPosX, int camPosY, int camPosZ,
|
|
169
|
+
int camTarX, int camTarY, int camTarZ,
|
|
170
|
+
int camUpX, int camUpY, int camUpZ,
|
|
171
|
+
int camFovy, int camProj,
|
|
172
|
+
unsigned int texId, int texW, int texH,
|
|
173
|
+
int srcX, int srcY, int srcW, int srcH,
|
|
174
|
+
int posX, int posY, int posZ,
|
|
175
|
+
int sizeX, int sizeY, Color tint) {
|
|
176
|
+
Camera3D cam = {
|
|
177
|
+
{i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
|
|
178
|
+
{i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
|
|
179
|
+
{i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
|
|
180
|
+
i2f(camFovy), camProj
|
|
181
|
+
};
|
|
182
|
+
Texture2D tex = { texId, texW, texH, 1, 7 };
|
|
183
|
+
Rectangle src = { srcX, srcY, srcW, srcH };
|
|
184
|
+
float sx, sy;
|
|
185
|
+
memcpy(&sx, &sizeX, sizeof(float));
|
|
186
|
+
memcpy(&sy, &sizeY, sizeof(float));
|
|
187
|
+
DrawBillboardRec(cam, tex, src, (Vector3){i2f(posX), i2f(posY), i2f(posZ)}, (Vector2){sx, sy}, tint);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
void DrawBillboardProW(
|
|
191
|
+
int camPosX, int camPosY, int camPosZ,
|
|
192
|
+
int camTarX, int camTarY, int camTarZ,
|
|
193
|
+
int camUpX, int camUpY, int camUpZ,
|
|
194
|
+
int camFovy, int camProj,
|
|
195
|
+
unsigned int texId, int texW, int texH,
|
|
196
|
+
int srcX, int srcY, int srcW, int srcH,
|
|
197
|
+
int posX, int posY, int posZ,
|
|
198
|
+
int upX, int upY, int upZ,
|
|
199
|
+
int sizeX, int sizeY,
|
|
200
|
+
int originX, int originY,
|
|
201
|
+
int rotation, Color tint) {
|
|
202
|
+
Camera3D cam = {
|
|
203
|
+
{i2f(camPosX), i2f(camPosY), i2f(camPosZ)},
|
|
204
|
+
{i2f(camTarX), i2f(camTarY), i2f(camTarZ)},
|
|
205
|
+
{i2f(camUpX), i2f(camUpY), i2f(camUpZ)},
|
|
206
|
+
i2f(camFovy), camProj
|
|
207
|
+
};
|
|
208
|
+
Texture2D tex = { texId, texW, texH, 1, 7 };
|
|
209
|
+
Rectangle src = { srcX, srcY, srcW, srcH };
|
|
210
|
+
float sx, sy, ox, oy, rot;
|
|
211
|
+
memcpy(&sx, &sizeX, sizeof(float));
|
|
212
|
+
memcpy(&sy, &sizeY, sizeof(float));
|
|
213
|
+
memcpy(&ox, &originX, sizeof(float));
|
|
214
|
+
memcpy(&oy, &originY, sizeof(float));
|
|
215
|
+
memcpy(&rot, &rotation, sizeof(float));
|
|
216
|
+
DrawBillboardPro(cam, tex, src,
|
|
217
|
+
(Vector3){i2f(posX), i2f(posY), i2f(posZ)},
|
|
218
|
+
(Vector3){i2f(upX), i2f(upY), i2f(upZ)},
|
|
219
|
+
(Vector2){sx, sy},
|
|
220
|
+
(Vector2){ox, oy},
|
|
221
|
+
rot, tint);
|
|
222
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#include "common.h"
|
|
2
|
+
|
|
3
|
+
bool FileExistsW(const char* fileName) { return FileExists(fileName); }
|
|
4
|
+
bool DirectoryExistsW(const char* dirPath) { return DirectoryExists(dirPath); }
|
|
5
|
+
bool IsFileExtensionW(const char* fileName, const char* ext) { return IsFileExtension(fileName, ext); }
|
|
6
|
+
int GetFileLengthW(const char* fileName) { return GetFileLength(fileName); }
|
|
7
|
+
const char* GetFileExtensionW(const char* fileName) { return GetFileExtension(fileName); }
|
|
8
|
+
const char* GetFileNameW(const char* filePath) { return GetFileName(filePath); }
|
|
9
|
+
const char* GetFileNameWithoutExtW(const char* filePath) { return GetFileNameWithoutExt(filePath); }
|
|
10
|
+
const char* GetDirectoryPathW(const char* filePath) { return GetDirectoryPath(filePath); }
|
|
11
|
+
const char* GetPrevDirectoryPathW(const char* dirPath) { return GetPrevDirectoryPath(dirPath); }
|
|
12
|
+
const char* GetWorkingDirectoryW() { return GetWorkingDirectory(); }
|
|
13
|
+
const char* GetApplicationDirectoryW() { return GetApplicationDirectory(); }
|
|
14
|
+
int MakeDirectoryW(const char* dirPath) { return MakeDirectory(dirPath); }
|
|
15
|
+
bool ChangeDirectoryW(const char* dir) { return ChangeDirectory(dir); }
|
|
16
|
+
bool IsPathFileW(const char* path) { return IsPathFile(path); }
|
|
17
|
+
bool IsFileNameValidW(const char* fileName) { return IsFileNameValid(fileName); }
|
|
18
|
+
long GetFileModTimeW(const char* fileName) { return GetFileModTime(fileName); }
|
|
19
|
+
|
|
20
|
+
const char* LoadFileTextW(const char* fileName) { return LoadFileText(fileName); }
|
|
21
|
+
void UnloadFileTextW(const char* text) { UnloadFileText((char*)text); }
|
|
22
|
+
bool SaveFileTextW(const char* fileName, const char* text) { return SaveFileText((char*)fileName, (char*)text); }
|
|
23
|
+
|
|
24
|
+
unsigned int ComputeCRC32W(const unsigned char* data, int dataSize) { return ComputeCRC32((unsigned char*)data, dataSize); }
|
|
25
|
+
|
|
26
|
+
void UnloadRandomSequenceW(int* sequence) { UnloadRandomSequence(sequence); }
|
|
27
|
+
void MemFreeW(void* ptr) { MemFree(ptr); }
|
|
28
|
+
void UnloadFileDataW(unsigned char* data) { UnloadFileData(data); }
|
|
29
|
+
|
|
30
|
+
bool SaveFileDataW(const char* fileName, const void* data, int dataSize) {
|
|
31
|
+
return SaveFileData(fileName, (void*)data, dataSize);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bool ExportDataAsCodeW(const unsigned char* data, int dataSize, const char* fileName) {
|
|
35
|
+
return ExportDataAsCode(data, dataSize, fileName);
|
|
36
|
+
}
|
package/src/c/font.c
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#include "common.h"
|
|
2
|
+
|
|
3
|
+
int LoadFontW(const char* fileName) {
|
|
4
|
+
int slot = fontAlloc();
|
|
5
|
+
if (slot < 0) return -1;
|
|
6
|
+
fontRegistry[slot] = LoadFont(fileName);
|
|
7
|
+
return slot;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
int LoadFontExW(const char* fileName, int fontSize) {
|
|
11
|
+
int slot = fontAlloc();
|
|
12
|
+
if (slot < 0) return -1;
|
|
13
|
+
fontRegistry[slot] = LoadFontEx(fileName, fontSize, NULL, 0);
|
|
14
|
+
return slot;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
int GetFontDefaultW() {
|
|
18
|
+
int slot = fontAlloc();
|
|
19
|
+
if (slot < 0) return -1;
|
|
20
|
+
fontRegistry[slot] = GetFontDefault();
|
|
21
|
+
return slot;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void UnloadFontW(int id) {
|
|
25
|
+
if (id < 0 || id >= MAX_FONTS || !fontUsed[id]) return;
|
|
26
|
+
UnloadFont(fontRegistry[id]);
|
|
27
|
+
fontUsed[id] = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
bool IsFontValidW(int id) {
|
|
31
|
+
if (id < 0 || id >= MAX_FONTS || !fontUsed[id]) return false;
|
|
32
|
+
return IsFontValid(fontRegistry[id]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
int MeasureTextW(const char* text, int fontSize) {
|
|
36
|
+
return MeasureText(text, fontSize);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void MeasureTextExW(float* out, int fontId, const char* text, int fontSize, int spacing) {
|
|
40
|
+
float sp;
|
|
41
|
+
memcpy(&sp, &spacing, sizeof(float));
|
|
42
|
+
Vector2 v = MeasureTextEx(fontRegistry[fontId], text, fontSize, sp);
|
|
43
|
+
out[0] = v.x; out[1] = v.y;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void DrawTextExW(int fontId, const char* text, int posX, int posY, int fontSize, int spacing, Color tint) {
|
|
47
|
+
float sp;
|
|
48
|
+
memcpy(&sp, &spacing, sizeof(float));
|
|
49
|
+
DrawTextEx(fontRegistry[fontId], text, (Vector2){posX, posY}, fontSize, sp, tint);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void DrawTextProW(int fontId, const char* text, int posX, int posY, int originX, int originY, int rotation, int fontSize, int spacing, Color tint) {
|
|
53
|
+
float rot, sp;
|
|
54
|
+
memcpy(&rot, &rotation, sizeof(float));
|
|
55
|
+
memcpy(&sp, &spacing, sizeof(float));
|
|
56
|
+
DrawTextPro(fontRegistry[fontId], text, (Vector2){posX, posY}, (Vector2){originX, originY}, rot, fontSize, sp, tint);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void SetTextLineSpacingW(int spacing) { SetTextLineSpacing(spacing); }
|
|
60
|
+
|
|
61
|
+
int LoadFontFromImageW(int imageId, Color key, int firstChar) {
|
|
62
|
+
if (imageId < 0 || imageId >= MAX_IMAGES || !imageUsed[imageId]) return -1;
|
|
63
|
+
int slot = fontAlloc();
|
|
64
|
+
if (slot < 0) return -1;
|
|
65
|
+
fontRegistry[slot] = LoadFontFromImage(imageRegistry[imageId], key, firstChar);
|
|
66
|
+
return slot;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
int LoadFontFromMemoryW(const char* fileType, const unsigned char* fileData, int dataSize, int fontSize) {
|
|
70
|
+
int slot = fontAlloc();
|
|
71
|
+
if (slot < 0) return -1;
|
|
72
|
+
fontRegistry[slot] = LoadFontFromMemory(fileType, fileData, dataSize, fontSize, NULL, 0);
|
|
73
|
+
return slot;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
bool ExportFontAsCodeW(int fontId, const char* fileName) {
|
|
77
|
+
if (fontId < 0 || fontId >= MAX_FONTS || !fontUsed[fontId]) return false;
|
|
78
|
+
return ExportFontAsCode(fontRegistry[fontId], fileName);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void DrawTextCodepointW(int fontId, int codepoint, int posX, int posY, int fontSize, Color tint) {
|
|
82
|
+
float fs;
|
|
83
|
+
memcpy(&fs, &fontSize, sizeof(float));
|
|
84
|
+
DrawTextCodepoint(fontRegistry[fontId], codepoint, (Vector2){posX, posY}, fs, tint);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void DrawTextCodepointsW(int fontId, const int* codepoints, int count, int posX, int posY, int fontSize, int spacing, Color tint) {
|
|
88
|
+
float fs, sp;
|
|
89
|
+
memcpy(&fs, &fontSize, sizeof(float));
|
|
90
|
+
memcpy(&sp, &spacing, sizeof(float));
|
|
91
|
+
DrawTextCodepoints(fontRegistry[fontId], codepoints, count, (Vector2){posX, posY}, fs, sp, tint);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
int GetGlyphIndexW(int fontId, int codepoint) {
|
|
95
|
+
return GetGlyphIndex(fontRegistry[fontId], codepoint);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void GetGlyphInfoW(int* outValue, int* outOffsetX, int* outOffsetY, int* outAdvanceX, int* outImageSlot, int fontId, int codepoint) {
|
|
99
|
+
GlyphInfo info = GetGlyphInfo(fontRegistry[fontId], codepoint);
|
|
100
|
+
*outValue = info.value;
|
|
101
|
+
*outOffsetX = info.offsetX;
|
|
102
|
+
*outOffsetY = info.offsetY;
|
|
103
|
+
*outAdvanceX = info.advanceX;
|
|
104
|
+
int imgSlot = imageAlloc();
|
|
105
|
+
if (imgSlot >= 0) {
|
|
106
|
+
imageRegistry[imgSlot] = info.image;
|
|
107
|
+
}
|
|
108
|
+
*outImageSlot = imgSlot;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void GetGlyphAtlasRecW(float* out, int fontId, int codepoint) {
|
|
112
|
+
Rectangle rec = GetGlyphAtlasRec(fontRegistry[fontId], codepoint);
|
|
113
|
+
out[0] = rec.x; out[1] = rec.y; out[2] = rec.width; out[3] = rec.height;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
int GetCodepointW(const char* text, int* outSize) {
|
|
117
|
+
return GetCodepoint(text, outSize);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
int GetCodepointNextW(const char* text, int* outSize) {
|
|
121
|
+
return GetCodepointNext(text, outSize);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
int GetCodepointPreviousW(const char* text, int* outSize) {
|
|
125
|
+
return GetCodepointPrevious(text, outSize);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
int GetCodepointCountW(const char* text) {
|
|
129
|
+
return GetCodepointCount(text);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
bool TextIsEqualW(const char* text1, const char* text2) {
|
|
133
|
+
return TextIsEqual(text1, text2);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
unsigned int TextLengthW(const char* text) {
|
|
137
|
+
return TextLength(text);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
int TextToIntegerW(const char* text) {
|
|
141
|
+
return TextToInteger(text);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
float TextToFloatW(const char* text) {
|
|
145
|
+
return TextToFloat(text);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
int TextFindIndexW(const char* text, const char* find) {
|
|
149
|
+
return TextFindIndex(text, find);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void UnloadFontDataW(void* ptr, int glyphCount) {
|
|
153
|
+
UnloadFontData((GlyphInfo*)ptr, glyphCount);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void UnloadUTF8W(char* text) { UnloadUTF8(text); }
|
|
157
|
+
void UnloadCodepointsW(int* codepoints) { UnloadCodepoints(codepoints); }
|
|
158
|
+
|
|
159
|
+
int TextCopyW(char* dst, const char* src) { return TextCopy(dst, src); }
|
|
160
|
+
|
|
161
|
+
void TextAppendW(char* text, const char* append, int* position) {
|
|
162
|
+
TextAppend(text, append, position);
|
|
163
|
+
}
|