@dayme/bunraylib 0.1.0 → 1.0.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 +60 -11
- package/package.json +11 -3
- package/src/Raylib.ts +58 -3678
- package/src/c/common.h +0 -2
- package/src/constants.ts +2 -2
- package/src/index.ts +6 -6
- package/src/main.c +0 -1
- package/src/main.d.ts +1 -1
- package/src/modules/audio/AudioModule.ts +197 -0
- package/src/modules/audio/symbols.ts +70 -0
- package/src/{c/audio.c → modules/audio/wrapper.c} +40 -80
- package/src/modules/camera/CameraModule.ts +239 -0
- package/src/modules/camera/symbols.ts +49 -0
- package/src/modules/camera/wrapper.c +141 -0
- package/src/modules/collision/CollisionModule.ts +363 -0
- package/src/modules/collision/symbols.ts +149 -0
- package/src/modules/collision/wrapper.c +176 -0
- package/src/modules/color/ColorModule.ts +65 -0
- package/src/modules/color/symbols.ts +26 -0
- package/src/modules/color/wrapper.c +16 -0
- package/src/modules/draw3d/Draw3DModule.ts +441 -0
- package/src/modules/draw3d/symbols.ts +199 -0
- package/src/modules/draw3d/wrapper.c +202 -0
- package/src/modules/font/FontModule.ts +250 -0
- package/src/modules/font/symbols.ts +46 -0
- package/src/{c/font.c → modules/font/wrapper.c} +50 -70
- package/src/modules/image/ImageModule.ts +451 -0
- package/src/{symbols/image.ts → modules/image/symbols.ts} +15 -12
- package/src/{c/image.c → modules/image/wrapper.c} +23 -45
- package/src/modules/input/InputModule.ts +160 -0
- package/src/modules/input/symbols.ts +54 -0
- package/src/modules/input/wrapper.c +31 -0
- package/src/modules/model/ModelModule.ts +228 -0
- package/src/{symbols/model.ts → modules/model/symbols.ts} +17 -14
- package/src/{c/model.c → modules/model/wrapper.c} +30 -30
- package/src/modules/shader/ShaderModule.ts +78 -0
- package/src/{symbols/shader.ts → modules/shader/symbols.ts} +3 -1
- package/src/{c/shader.c → modules/shader/wrapper.c} +11 -1
- package/src/modules/shapes/ShapesModule.ts +687 -0
- package/src/modules/shapes/symbols.ts +161 -0
- package/src/modules/shapes/wrapper.c +183 -0
- package/src/modules/texture/TextureModule.ts +190 -0
- package/src/{symbols/texture.ts → modules/texture/symbols.ts} +15 -9
- package/src/{c/texture.c → modules/texture/wrapper.c} +7 -22
- package/src/modules/window/WindowModule.ts +248 -0
- package/src/modules/window/symbols.ts +85 -0
- package/src/modules/window/wrapper.c +39 -0
- package/src/symbols.ts +87 -47
- package/src/utils.ts +63 -15
- package/src/c/camera.c +0 -161
- package/src/c/collision.c +0 -176
- package/src/c/color.c +0 -100
- package/src/c/draw3d.c +0 -222
- package/src/c/filesystem.c +0 -36
- package/src/c/input.c +0 -85
- package/src/c/shapes.c +0 -283
- package/src/c/window.c +0 -150
- package/src/symbols/audio.ts +0 -64
- package/src/symbols/camera.ts +0 -46
- package/src/symbols/collision.ts +0 -116
- package/src/symbols/color.ts +0 -22
- package/src/symbols/draw3d.ts +0 -137
- package/src/symbols/filesystem.ts +0 -30
- package/src/symbols/font.ts +0 -40
- package/src/symbols/input.ts +0 -51
- package/src/symbols/shapes.ts +0 -92
- package/src/symbols/window.ts +0 -83
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { FFIType } from 'bun:ffi';
|
|
2
|
+
const { i32, ptr, f32 } = FFIType;
|
|
3
|
+
|
|
4
|
+
export const shapesDirectSymbols = {
|
|
5
|
+
DrawFPS: { args: [i32, i32], returns: FFIType.void },
|
|
6
|
+
DrawRectangle: { args: [i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
7
|
+
DrawText: { args: [FFIType.cstring, i32, i32, i32, i32], returns: FFIType.void },
|
|
8
|
+
DrawPixel: { args: [i32, i32, i32], returns: FFIType.void },
|
|
9
|
+
DrawLine: { args: [i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
10
|
+
DrawLineStrip: { args: [ptr, i32, i32], returns: FFIType.void },
|
|
11
|
+
DrawCircle: { args: [i32, i32, f32, i32], returns: FFIType.void },
|
|
12
|
+
DrawCircleLines: { args: [i32, i32, f32, i32], returns: FFIType.void },
|
|
13
|
+
DrawEllipse: { args: [i32, i32, f32, f32, i32], returns: FFIType.void },
|
|
14
|
+
DrawEllipseLines: { args: [i32, i32, f32, f32, i32], returns: FFIType.void },
|
|
15
|
+
DrawRectangleGradientV: { args: [i32, i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
16
|
+
DrawRectangleGradientH: { args: [i32, i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
17
|
+
DrawRectangleLines: { args: [i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
18
|
+
DrawTriangleFan: { args: [ptr, i32, i32], returns: FFIType.void },
|
|
19
|
+
DrawTriangleStrip: { args: [ptr, i32, i32], returns: FFIType.void },
|
|
20
|
+
DrawSplineLinear: { args: [ptr, i32, f32, i32], returns: FFIType.void },
|
|
21
|
+
DrawSplineBasis: { args: [ptr, i32, f32, i32], returns: FFIType.void },
|
|
22
|
+
DrawSplineCatmullRom: { args: [ptr, i32, f32, i32], returns: FFIType.void },
|
|
23
|
+
DrawSplineBezierQuadratic: { args: [ptr, i32, f32, i32], returns: FFIType.void },
|
|
24
|
+
DrawSplineBezierCubic: { args: [ptr, i32, f32, i32], returns: FFIType.void },
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
export const shapesWrapperSymbols = {
|
|
28
|
+
DrawLineExW: {
|
|
29
|
+
args: [f32, f32, f32, f32, f32, i32],
|
|
30
|
+
returns: FFIType.void,
|
|
31
|
+
},
|
|
32
|
+
DrawLineBezierW: {
|
|
33
|
+
args: [f32, f32, f32, f32, f32, i32],
|
|
34
|
+
returns: FFIType.void,
|
|
35
|
+
},
|
|
36
|
+
DrawLineDashedW: { args: [f32, f32, f32, f32, i32, i32, i32], returns: FFIType.void },
|
|
37
|
+
DrawCircleSectorW: {
|
|
38
|
+
args: [f32, f32, f32, f32, f32, i32, i32],
|
|
39
|
+
returns: FFIType.void,
|
|
40
|
+
},
|
|
41
|
+
DrawCircleSectorLinesW: {
|
|
42
|
+
args: [f32, f32, f32, f32, f32, i32, i32],
|
|
43
|
+
returns: FFIType.void,
|
|
44
|
+
},
|
|
45
|
+
DrawCircleGradientW: {
|
|
46
|
+
args: [f32, f32, f32, i32, i32],
|
|
47
|
+
returns: FFIType.void,
|
|
48
|
+
},
|
|
49
|
+
DrawEllipseVW: { args: [f32, f32, f32, f32, i32], returns: FFIType.void },
|
|
50
|
+
DrawEllipseLinesVW: { args: [f32, f32, f32, f32, i32], returns: FFIType.void },
|
|
51
|
+
DrawRingW: {
|
|
52
|
+
args: [f32, f32, f32, f32, f32, f32, i32, i32],
|
|
53
|
+
returns: FFIType.void,
|
|
54
|
+
},
|
|
55
|
+
DrawRingLinesW: {
|
|
56
|
+
args: [f32, f32, f32, f32, f32, f32, i32, i32],
|
|
57
|
+
returns: FFIType.void,
|
|
58
|
+
},
|
|
59
|
+
DrawRectangleProW: {
|
|
60
|
+
args: [f32, f32, f32, f32, f32, f32, f32, i32],
|
|
61
|
+
returns: FFIType.void,
|
|
62
|
+
},
|
|
63
|
+
DrawRectangleGradientExW: {
|
|
64
|
+
args: [f32, f32, f32, f32, i32, i32, i32, i32],
|
|
65
|
+
returns: FFIType.void,
|
|
66
|
+
},
|
|
67
|
+
DrawRectangleLinesExW: {
|
|
68
|
+
args: [f32, f32, f32, f32, f32, i32],
|
|
69
|
+
returns: FFIType.void,
|
|
70
|
+
},
|
|
71
|
+
DrawRectangleRoundedW: {
|
|
72
|
+
args: [f32, f32, f32, f32, f32, i32, i32],
|
|
73
|
+
returns: FFIType.void,
|
|
74
|
+
},
|
|
75
|
+
DrawRectangleRoundedLinesW: {
|
|
76
|
+
args: [f32, f32, f32, f32, f32, i32, i32],
|
|
77
|
+
returns: FFIType.void,
|
|
78
|
+
},
|
|
79
|
+
DrawRectangleRoundedLinesExW: {
|
|
80
|
+
args: [f32, f32, f32, f32, f32, i32, f32, i32],
|
|
81
|
+
returns: FFIType.void,
|
|
82
|
+
},
|
|
83
|
+
DrawTriangleW: {
|
|
84
|
+
args: [f32, f32, f32, f32, f32, f32, i32],
|
|
85
|
+
returns: FFIType.void,
|
|
86
|
+
},
|
|
87
|
+
DrawTriangleLinesW: {
|
|
88
|
+
args: [f32, f32, f32, f32, f32, f32, i32],
|
|
89
|
+
returns: FFIType.void,
|
|
90
|
+
},
|
|
91
|
+
DrawPolyW: {
|
|
92
|
+
args: [f32, f32, i32, f32, f32, i32],
|
|
93
|
+
returns: FFIType.void,
|
|
94
|
+
},
|
|
95
|
+
DrawPolyLinesW: {
|
|
96
|
+
args: [f32, f32, i32, f32, f32, i32],
|
|
97
|
+
returns: FFIType.void,
|
|
98
|
+
},
|
|
99
|
+
DrawPolyLinesExW: {
|
|
100
|
+
args: [f32, f32, i32, f32, f32, f32, i32],
|
|
101
|
+
returns: FFIType.void,
|
|
102
|
+
},
|
|
103
|
+
DrawSplineSegmentLinearW: {
|
|
104
|
+
args: [f32, f32, f32, f32, f32, i32],
|
|
105
|
+
returns: FFIType.void,
|
|
106
|
+
},
|
|
107
|
+
DrawSplineSegmentBasisW: {
|
|
108
|
+
args: [f32, f32, f32, f32, f32, f32, f32, f32, f32, i32],
|
|
109
|
+
returns: FFIType.void,
|
|
110
|
+
},
|
|
111
|
+
DrawSplineSegmentCatmullRomW: {
|
|
112
|
+
args: [f32, f32, f32, f32, f32, f32, f32, f32, f32, i32],
|
|
113
|
+
returns: FFIType.void,
|
|
114
|
+
},
|
|
115
|
+
DrawSplineSegmentBezierQuadraticW: {
|
|
116
|
+
args: [f32, f32, f32, f32, f32, f32, f32, i32],
|
|
117
|
+
returns: FFIType.void,
|
|
118
|
+
},
|
|
119
|
+
DrawSplineSegmentBezierCubicW: {
|
|
120
|
+
args: [f32, f32, f32, f32, f32, f32, f32, f32, f32, i32],
|
|
121
|
+
returns: FFIType.void,
|
|
122
|
+
},
|
|
123
|
+
GetSplinePointLinearW: {
|
|
124
|
+
args: [ptr, f32, f32, f32, f32, f32],
|
|
125
|
+
returns: FFIType.void,
|
|
126
|
+
},
|
|
127
|
+
GetSplinePointBasisW: {
|
|
128
|
+
args: [ptr, f32, f32, f32, f32, f32, f32, f32, f32, f32],
|
|
129
|
+
returns: FFIType.void,
|
|
130
|
+
},
|
|
131
|
+
GetSplinePointCatmullRomW: {
|
|
132
|
+
args: [ptr, f32, f32, f32, f32, f32, f32, f32, f32, f32],
|
|
133
|
+
returns: FFIType.void,
|
|
134
|
+
},
|
|
135
|
+
GetSplinePointBezierQuadW: {
|
|
136
|
+
args: [ptr, f32, f32, f32, f32, f32, f32, f32],
|
|
137
|
+
returns: FFIType.void,
|
|
138
|
+
},
|
|
139
|
+
GetSplinePointBezierCubicW: {
|
|
140
|
+
args: [ptr, f32, f32, f32, f32, f32, f32, f32, f32, f32],
|
|
141
|
+
returns: FFIType.void,
|
|
142
|
+
},
|
|
143
|
+
DrawPixelVW: { args: [f32, f32, i32], returns: FFIType.void },
|
|
144
|
+
DrawLineVW: {
|
|
145
|
+
args: [f32, f32, f32, f32, i32],
|
|
146
|
+
returns: FFIType.void,
|
|
147
|
+
},
|
|
148
|
+
DrawCircleVW: { args: [i32, i32, f32, i32], returns: FFIType.void },
|
|
149
|
+
DrawCircleLinesVW: { args: [f32, f32, f32, i32], returns: FFIType.void },
|
|
150
|
+
DrawRectangleVW: {
|
|
151
|
+
args: [f32, f32, f32, f32, i32],
|
|
152
|
+
returns: FFIType.void,
|
|
153
|
+
},
|
|
154
|
+
DrawRectangleRecW: {
|
|
155
|
+
args: [f32, f32, f32, f32, i32],
|
|
156
|
+
returns: FFIType.void,
|
|
157
|
+
},
|
|
158
|
+
SetShapesTextureW: { args: [i32, i32, i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
159
|
+
GetShapesTextureW: { args: [ptr, ptr, ptr], returns: FFIType.void },
|
|
160
|
+
GetShapesTextureRectangleW: { args: [ptr], returns: FFIType.void },
|
|
161
|
+
} as const;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#include <raylib.h>
|
|
2
|
+
|
|
3
|
+
void DrawPixelVW(float x, float y, Color color) {
|
|
4
|
+
DrawPixelV((Vector2){x, y}, color);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
void DrawLineVW(float startX, float startY, float endX, float endY, Color color) {
|
|
8
|
+
DrawLineV((Vector2){startX, startY}, (Vector2){endX, endY}, color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
void DrawLineExW(float startX, float startY, float endX, float endY, float thick, Color color) {
|
|
12
|
+
DrawLineEx((Vector2){startX, startY}, (Vector2){endX, endY}, thick, color);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void DrawLineBezierW(float startX, float startY, float endX, float endY, float thick, Color color) {
|
|
16
|
+
DrawLineBezier((Vector2){startX, startY}, (Vector2){endX, endY}, thick, color);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void DrawLineDashedW(float startX, float startY, float endX, float endY, int dashSize, int spaceSize, Color color) {
|
|
20
|
+
DrawLineDashed((Vector2){startX, startY}, (Vector2){endX, endY}, dashSize, spaceSize, color);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void DrawCircleVW(int x, int y, float radius, Color color) {
|
|
24
|
+
DrawCircleV((Vector2){x, y}, radius, color);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void DrawCircleSectorW(float centerX, float centerY, float radius, float startAngle, float endAngle, int segments, Color color) {
|
|
28
|
+
DrawCircleSector((Vector2){centerX, centerY}, radius, startAngle, endAngle, segments, color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void DrawCircleSectorLinesW(float centerX, float centerY, float radius, float startAngle, float endAngle, int segments, Color color) {
|
|
32
|
+
DrawCircleSectorLines((Vector2){centerX, centerY}, radius, startAngle, endAngle, segments, color);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void DrawCircleGradientW(float centerX, float centerY, float radius, Color inner, Color outer) {
|
|
36
|
+
DrawCircleGradient((Vector2){centerX, centerY}, radius, inner, outer);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void DrawCircleLinesVW(float x, float y, float radius, Color color) {
|
|
40
|
+
DrawCircleLinesV((Vector2){x, y}, radius, color);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void DrawEllipseVW(float centerX, float centerY, float radiusH, float radiusV, Color color) {
|
|
44
|
+
DrawEllipseV((Vector2){ centerX, centerY }, radiusH, radiusV, color);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void DrawEllipseLinesVW(float centerX, float centerY, float radiusH, float radiusV, Color color) {
|
|
48
|
+
DrawEllipseLinesV((Vector2){ centerX, centerY }, radiusH, radiusV, color);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void DrawRingW(float centerX, float centerY, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color) {
|
|
52
|
+
DrawRing((Vector2){centerX, centerY}, innerRadius, outerRadius, startAngle, endAngle, segments, color);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void DrawRingLinesW(float centerX, float centerY, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color) {
|
|
56
|
+
DrawRingLines((Vector2){centerX, centerY}, innerRadius, outerRadius, startAngle, endAngle, segments, color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void DrawRectangleVW(float posX, float posY, float sizeX, float sizeY, Color color) {
|
|
60
|
+
DrawRectangleV((Vector2){posX, posY}, (Vector2){sizeX, sizeY}, color);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void DrawRectangleRecW(float x, float y, float w, float h, Color color) {
|
|
64
|
+
DrawRectangleRec((Rectangle){x, y, w, h}, color);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void DrawRectangleProW(float x, float y, float width, float height, float originX, float originY, float rotation, Color color) {
|
|
68
|
+
Rectangle rec = {x, y, width, height};
|
|
69
|
+
DrawRectanglePro(rec, (Vector2){originX, originY}, rotation, color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void DrawRectangleGradientExW(float x, float y, float width, float height, Color topLeft, Color bottomLeft, Color topRight, Color bottomRight) {
|
|
73
|
+
Rectangle rec = {x, y, width, height};
|
|
74
|
+
DrawRectangleGradientEx(rec, topLeft, bottomLeft, topRight, bottomRight);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void DrawRectangleLinesExW(float x, float y, float width, float height, float lineThick, Color color) {
|
|
78
|
+
Rectangle rec = {x, y, width, height};
|
|
79
|
+
DrawRectangleLinesEx(rec, lineThick, color);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void DrawRectangleRoundedW(float x, float y, float width, float height, float roundness, int segments, Color color) {
|
|
83
|
+
Rectangle rec = {x, y, width, height};
|
|
84
|
+
DrawRectangleRounded(rec, roundness, segments, color);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void DrawRectangleRoundedLinesW(float x, float y, float width, float height, float roundness, int segments, Color color) {
|
|
88
|
+
Rectangle rec = {x, y, width, height};
|
|
89
|
+
DrawRectangleRoundedLines(rec, roundness, segments, color);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void DrawRectangleRoundedLinesExW(float x, float y, float width, float height, float roundness, int segments, float lineThick, Color color) {
|
|
93
|
+
Rectangle rec = {x, y, width, height};
|
|
94
|
+
DrawRectangleRoundedLinesEx(rec, roundness, segments, lineThick, color);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void DrawTriangleW(float x1, float y1, float x2, float y2, float x3, float y3, Color color) {
|
|
98
|
+
DrawTriangle((Vector2){x1, y1}, (Vector2){x2, y2}, (Vector2){x3, y3}, color);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void DrawTriangleLinesW(float x1, float y1, float x2, float y2, float x3, float y3, Color color) {
|
|
102
|
+
DrawTriangleLines((Vector2){x1, y1}, (Vector2){x2, y2}, (Vector2){x3, y3}, color);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void DrawPolyW(float centerX, float centerY, int sides, float radius, float rotation, Color color) {
|
|
106
|
+
DrawPoly((Vector2){centerX, centerY}, sides, radius, rotation, color);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void DrawPolyLinesW(float centerX, float centerY, int sides, float radius, float rotation, Color color) {
|
|
110
|
+
DrawPolyLines((Vector2){centerX, centerY}, sides, radius, rotation, color);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void DrawPolyLinesExW(float centerX, float centerY, int sides, float radius, float rotation, float lineThick, Color color) {
|
|
114
|
+
DrawPolyLinesEx((Vector2){centerX, centerY}, sides, radius, rotation, lineThick, color);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void DrawSplineSegmentLinearW(float p1x, float p1y, float p2x, float p2y, float thick, Color color) {
|
|
118
|
+
DrawSplineSegmentLinear((Vector2){p1x, p1y}, (Vector2){p2x, p2y}, thick, color);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void DrawSplineSegmentBasisW(float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float p4x, float p4y, float thick, Color color) {
|
|
122
|
+
DrawSplineSegmentBasis((Vector2){p1x, p1y}, (Vector2){p2x, p2y}, (Vector2){p3x, p3y}, (Vector2){p4x, p4y}, thick, color);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void DrawSplineSegmentCatmullRomW(float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float p4x, float p4y, float thick, Color color) {
|
|
126
|
+
DrawSplineSegmentCatmullRom((Vector2){p1x, p1y}, (Vector2){p2x, p2y}, (Vector2){p3x, p3y}, (Vector2){p4x, p4y}, thick, color);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void DrawSplineSegmentBezierQuadraticW(float p1x, float p1y, float c2x, float c2y, float p3x, float p3y, float thick, Color color) {
|
|
130
|
+
DrawSplineSegmentBezierQuadratic((Vector2){p1x, p1y}, (Vector2){c2x, c2y}, (Vector2){p3x, p3y}, thick, color);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
void DrawSplineSegmentBezierCubicW(float p1x, float p1y, float c2x, float c2y, float c3x, float c3y, float p4x, float p4y, float thick, Color color) {
|
|
134
|
+
DrawSplineSegmentBezierCubic((Vector2){p1x, p1y}, (Vector2){c2x, c2y}, (Vector2){c3x, c3y}, (Vector2){p4x, p4y}, thick, color);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
void GetSplinePointLinearW(float* out, float startPx, float startPy, float endPx, float endPy, float t) {
|
|
138
|
+
Vector2 result = GetSplinePointLinear((Vector2){startPx, startPy}, (Vector2){endPx, endPy}, t);
|
|
139
|
+
out[0] = result.x;
|
|
140
|
+
out[1] = result.y;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void GetSplinePointBasisW(float* out, float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float p4x, float p4y, float t) {
|
|
144
|
+
Vector2 result = GetSplinePointBasis((Vector2){p1x, p1y}, (Vector2){p2x, p2y}, (Vector2){p3x, p3y}, (Vector2){p4x, p4y}, t);
|
|
145
|
+
out[0] = result.x;
|
|
146
|
+
out[1] = result.y;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void GetSplinePointCatmullRomW(float* out, float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float p4x, float p4y, float t) {
|
|
150
|
+
Vector2 result = GetSplinePointCatmullRom((Vector2){p1x, p1y}, (Vector2){p2x, p2y}, (Vector2){p3x, p3y}, (Vector2){p4x, p4y}, t);
|
|
151
|
+
out[0] = result.x;
|
|
152
|
+
out[1] = result.y;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void GetSplinePointBezierQuadW(float* out, float p1x, float p1y, float c2x, float c2y, float p3x, float p3y, float t) {
|
|
156
|
+
Vector2 result = GetSplinePointBezierQuad((Vector2){p1x, p1y}, (Vector2){c2x, c2y}, (Vector2){p3x, p3y}, t);
|
|
157
|
+
out[0] = result.x;
|
|
158
|
+
out[1] = result.y;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void GetSplinePointBezierCubicW(float* out, float p1x, float p1y, float c2x, float c2y, float c3x, float c3y, float p4x, float p4y, float t) {
|
|
162
|
+
Vector2 result = GetSplinePointBezierCubic((Vector2){p1x, p1y}, (Vector2){c2x, c2y}, (Vector2){c3x, c3y}, (Vector2){p4x, p4y}, t);
|
|
163
|
+
out[0] = result.x;
|
|
164
|
+
out[1] = result.y;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void SetShapesTextureW(unsigned int texId, int texW, int texH, int recX, int recY, int recW, int recH) {
|
|
168
|
+
Texture2D tex = { texId, texW, texH, 1, 7 };
|
|
169
|
+
Rectangle rec = { recX, recY, recW, recH };
|
|
170
|
+
SetShapesTexture(tex, rec);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
void GetShapesTextureW(unsigned int* outId, int* outW, int* outH) {
|
|
174
|
+
Texture2D tex = GetShapesTexture();
|
|
175
|
+
*outId = tex.id;
|
|
176
|
+
*outW = tex.width;
|
|
177
|
+
*outH = tex.height;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
void GetShapesTextureRectangleW(float* out) {
|
|
181
|
+
Rectangle rec = GetShapesTextureRectangle();
|
|
182
|
+
out[0] = rec.x; out[1] = rec.y; out[2] = rec.width; out[3] = rec.height;
|
|
183
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { getSymbols } from '../../symbols';
|
|
2
|
+
import { bufs as b, cstr, f, i } from '../../utils';
|
|
3
|
+
import type { Vec2, Rectangle, Texture2D, RenderTexture2D, Image, Color } from '../../types';
|
|
4
|
+
|
|
5
|
+
const r = () => getSymbols();
|
|
6
|
+
|
|
7
|
+
export class TextureModule {
|
|
8
|
+
static loadTexture(fileName: string): Texture2D {
|
|
9
|
+
r().symbols.LoadTextureW(b._texOutId, b._texOutW, b._texOutH, cstr(fileName));
|
|
10
|
+
return {
|
|
11
|
+
id: b._texOutId[0]!,
|
|
12
|
+
width: b._texOutW[0]!,
|
|
13
|
+
height: b._texOutH[0]!,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
static unloadTexture(texture: Texture2D): void {
|
|
17
|
+
r().symbols.UnloadTextureW(i(texture.id));
|
|
18
|
+
}
|
|
19
|
+
static isTextureValid(texture: Texture2D): boolean {
|
|
20
|
+
return r().symbols.IsTextureValidW(i(texture.id), i(texture.width), i(texture.height));
|
|
21
|
+
}
|
|
22
|
+
static loadRenderTexture(width: number, height: number): RenderTexture2D {
|
|
23
|
+
r().symbols.LoadRenderTextureW(
|
|
24
|
+
b._texOutId,
|
|
25
|
+
b._texOutTexId,
|
|
26
|
+
b._texOutW,
|
|
27
|
+
b._texOutH,
|
|
28
|
+
i(width),
|
|
29
|
+
i(height),
|
|
30
|
+
);
|
|
31
|
+
return {
|
|
32
|
+
id: b._texOutId[0]!,
|
|
33
|
+
texture: {
|
|
34
|
+
id: b._texOutTexId[0]!,
|
|
35
|
+
width: b._texOutW[0]!,
|
|
36
|
+
height: b._texOutH[0]!,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
static unloadRenderTexture(target: RenderTexture2D): void {
|
|
41
|
+
r().symbols.UnloadRenderTextureW(i(target.id));
|
|
42
|
+
}
|
|
43
|
+
static isRenderTextureValid(target: RenderTexture2D): boolean {
|
|
44
|
+
return r().symbols.IsRenderTextureValidW(i(target.id));
|
|
45
|
+
}
|
|
46
|
+
static genTextureMipmaps(texture: Texture2D): void {
|
|
47
|
+
r().symbols.GenTextureMipmapsW(i(texture.id));
|
|
48
|
+
}
|
|
49
|
+
static setTextureFilter(texture: Texture2D, filter: number): void {
|
|
50
|
+
r().symbols.SetTextureFilterW(i(texture.id), i(filter));
|
|
51
|
+
}
|
|
52
|
+
static setTextureWrap(texture: Texture2D, wrap: number): void {
|
|
53
|
+
r().symbols.SetTextureWrapW(i(texture.id), i(wrap));
|
|
54
|
+
}
|
|
55
|
+
static drawTexture(texture: Texture2D, posX: number, posY: number, tint: Color): void {
|
|
56
|
+
r().symbols.DrawTextureW(
|
|
57
|
+
i(texture.id),
|
|
58
|
+
i(texture.width),
|
|
59
|
+
i(texture.height),
|
|
60
|
+
i(posX),
|
|
61
|
+
i(posY),
|
|
62
|
+
i(tint),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
static drawTextureEx(
|
|
66
|
+
texture: Texture2D,
|
|
67
|
+
position: Vec2,
|
|
68
|
+
rotation: number,
|
|
69
|
+
scale: number,
|
|
70
|
+
tint: Color,
|
|
71
|
+
): void {
|
|
72
|
+
r().symbols.DrawTextureExW(
|
|
73
|
+
i(texture.id),
|
|
74
|
+
i(texture.width),
|
|
75
|
+
i(texture.height),
|
|
76
|
+
i(position.x),
|
|
77
|
+
i(position.y),
|
|
78
|
+
f(rotation),
|
|
79
|
+
f(scale),
|
|
80
|
+
i(tint),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
static drawTextureRec(texture: Texture2D, source: Rectangle, position: Vec2, tint: Color): void {
|
|
84
|
+
r().symbols.DrawTextureRecW(
|
|
85
|
+
i(texture.id),
|
|
86
|
+
i(texture.width),
|
|
87
|
+
i(texture.height),
|
|
88
|
+
i(source.x),
|
|
89
|
+
i(source.y),
|
|
90
|
+
i(source.width),
|
|
91
|
+
i(source.height),
|
|
92
|
+
i(position.x),
|
|
93
|
+
i(position.y),
|
|
94
|
+
i(tint),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
static drawTexturePro(
|
|
98
|
+
texture: Texture2D,
|
|
99
|
+
source: Rectangle,
|
|
100
|
+
dest: Rectangle,
|
|
101
|
+
origin: Vec2,
|
|
102
|
+
rotation: number,
|
|
103
|
+
tint: Color,
|
|
104
|
+
): void {
|
|
105
|
+
r().symbols.DrawTextureProW(
|
|
106
|
+
i(texture.id),
|
|
107
|
+
i(texture.width),
|
|
108
|
+
i(texture.height),
|
|
109
|
+
i(source.x),
|
|
110
|
+
i(source.y),
|
|
111
|
+
i(source.width),
|
|
112
|
+
i(source.height),
|
|
113
|
+
i(dest.x),
|
|
114
|
+
i(dest.y),
|
|
115
|
+
i(dest.width),
|
|
116
|
+
i(dest.height),
|
|
117
|
+
i(origin.x),
|
|
118
|
+
i(origin.y),
|
|
119
|
+
f(rotation),
|
|
120
|
+
i(tint),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
static loadTextureFromImage(image: Image): Texture2D {
|
|
124
|
+
r().symbols.LoadTextureFromImageW(b._texOutId, b._texOutW, b._texOutH, i(image));
|
|
125
|
+
return { id: b._texOutId[0]!, width: b._texOutW[0]!, height: b._texOutH[0]! };
|
|
126
|
+
}
|
|
127
|
+
static loadTextureCubemap(image: Image, layout: number): Texture2D {
|
|
128
|
+
r().symbols.LoadTextureCubemapW(b._texOutId, b._texOutW, b._texOutH, i(image), i(layout));
|
|
129
|
+
return { id: b._texOutId[0]!, width: b._texOutW[0]!, height: b._texOutH[0]! };
|
|
130
|
+
}
|
|
131
|
+
static updateTexture(texture: Texture2D, pixels: Uint8Array): void {
|
|
132
|
+
r().symbols.UpdateTextureW(i(texture.id), i(texture.width), i(texture.height), pixels);
|
|
133
|
+
}
|
|
134
|
+
static updateTextureRec(texture: Texture2D, rec: Rectangle, pixels: Uint8Array): void {
|
|
135
|
+
r().symbols.UpdateTextureRecW(
|
|
136
|
+
i(texture.id),
|
|
137
|
+
i(texture.width),
|
|
138
|
+
i(texture.height),
|
|
139
|
+
i(rec.x),
|
|
140
|
+
i(rec.y),
|
|
141
|
+
i(rec.width),
|
|
142
|
+
i(rec.height),
|
|
143
|
+
pixels,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
static drawTextureNPatch(
|
|
147
|
+
texture: Texture2D,
|
|
148
|
+
nPatchInfo: {
|
|
149
|
+
source: Rectangle;
|
|
150
|
+
left: number;
|
|
151
|
+
top: number;
|
|
152
|
+
right: number;
|
|
153
|
+
bottom: number;
|
|
154
|
+
layout: number;
|
|
155
|
+
},
|
|
156
|
+
dest: Rectangle,
|
|
157
|
+
origin: Vec2,
|
|
158
|
+
rotation: number,
|
|
159
|
+
tint: Color,
|
|
160
|
+
): void {
|
|
161
|
+
r().symbols.DrawTextureNPatchW(
|
|
162
|
+
i(texture.id),
|
|
163
|
+
i(texture.width),
|
|
164
|
+
i(texture.height),
|
|
165
|
+
i(nPatchInfo.source.x),
|
|
166
|
+
i(nPatchInfo.source.y),
|
|
167
|
+
i(nPatchInfo.source.width),
|
|
168
|
+
i(nPatchInfo.source.height),
|
|
169
|
+
i(nPatchInfo.left),
|
|
170
|
+
i(nPatchInfo.top),
|
|
171
|
+
i(nPatchInfo.right),
|
|
172
|
+
i(nPatchInfo.bottom),
|
|
173
|
+
i(nPatchInfo.layout),
|
|
174
|
+
i(dest.x),
|
|
175
|
+
i(dest.y),
|
|
176
|
+
i(dest.width),
|
|
177
|
+
i(dest.height),
|
|
178
|
+
i(origin.x),
|
|
179
|
+
i(origin.y),
|
|
180
|
+
f(rotation),
|
|
181
|
+
i(tint),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
static getPixelColor(srcPtr: number, format: number): Color {
|
|
185
|
+
return r().symbols.GetPixelColor(srcPtr as unknown as Buffer, i(format));
|
|
186
|
+
}
|
|
187
|
+
static setPixelColor(dstPtr: number, color: Color, format: number): void {
|
|
188
|
+
r().symbols.SetPixelColor(dstPtr as unknown as Buffer, i(color), i(format));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { FFIType } from
|
|
2
|
-
const { i32, ptr, bool } = FFIType;
|
|
1
|
+
import { FFIType } from 'bun:ffi';
|
|
2
|
+
const { i32, ptr, bool, cstring, f32 } = FFIType;
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
4
|
+
export const textureDirectSymbols = {
|
|
5
|
+
GetPixelColor: { args: [ptr, i32], returns: i32 },
|
|
6
|
+
SetPixelColor: { args: [ptr, i32, i32], returns: FFIType.void },
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export const textureWrapperSymbols = {
|
|
10
|
+
LoadTextureW: { args: [ptr, ptr, ptr, cstring], returns: FFIType.void },
|
|
6
11
|
UnloadTextureW: { args: [i32], returns: FFIType.void },
|
|
7
12
|
IsTextureValidW: { args: [i32, i32, i32], returns: bool },
|
|
8
13
|
LoadRenderTextureW: { args: [ptr, ptr, ptr, ptr, i32, i32], returns: FFIType.void },
|
|
@@ -13,13 +18,16 @@ export const textureSymbols = {
|
|
|
13
18
|
SetTextureWrapW: { args: [i32, i32], returns: FFIType.void },
|
|
14
19
|
DrawTextureW: { args: [i32, i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
15
20
|
DrawTextureVW: { args: [i32, i32, i32, i32, i32, i32], returns: FFIType.void },
|
|
16
|
-
DrawTextureExW: {
|
|
21
|
+
DrawTextureExW: {
|
|
22
|
+
args: [i32, i32, i32, i32, i32, f32, f32, i32],
|
|
23
|
+
returns: FFIType.void,
|
|
24
|
+
},
|
|
17
25
|
DrawTextureRecW: {
|
|
18
26
|
args: [i32, i32, i32, i32, i32, i32, i32, i32, i32, i32],
|
|
19
27
|
returns: FFIType.void,
|
|
20
28
|
},
|
|
21
29
|
DrawTextureProW: {
|
|
22
|
-
args: [i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
|
|
30
|
+
args: [i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, f32, i32],
|
|
23
31
|
returns: FFIType.void,
|
|
24
32
|
},
|
|
25
33
|
LoadTextureFromImageW: { args: [ptr, ptr, ptr, i32], returns: FFIType.void },
|
|
@@ -46,11 +54,9 @@ export const textureSymbols = {
|
|
|
46
54
|
i32,
|
|
47
55
|
i32,
|
|
48
56
|
i32,
|
|
49
|
-
|
|
57
|
+
f32,
|
|
50
58
|
i32,
|
|
51
59
|
],
|
|
52
60
|
returns: FFIType.void,
|
|
53
61
|
},
|
|
54
|
-
GetPixelColorW: { args: [ptr, i32], returns: i32 },
|
|
55
|
-
SetPixelColorW: { args: [ptr, i32, i32], returns: FFIType.void },
|
|
56
62
|
} as const;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#include "common.h"
|
|
1
|
+
#include "../../c/common.h"
|
|
2
2
|
|
|
3
3
|
void LoadTextureW(unsigned int* outId, int* outW, int* outH, const char* fileName) {
|
|
4
4
|
Texture2D tex = LoadTexture(fileName);
|
|
@@ -60,12 +60,9 @@ void DrawTextureVW(unsigned int id, int w, int h, int posX, int posY, Color tint
|
|
|
60
60
|
DrawTextureV(tex, (Vector2){posX, posY}, tint);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
void DrawTextureExW(unsigned int id, int w, int h, int posX, int posY,
|
|
64
|
-
float r, s;
|
|
65
|
-
memcpy(&r, &rotation, sizeof(float));
|
|
66
|
-
memcpy(&s, &scale, sizeof(float));
|
|
63
|
+
void DrawTextureExW(unsigned int id, int w, int h, int posX, int posY, float rotation, float scale, Color tint) {
|
|
67
64
|
Texture2D tex = { id, w, h, 1, 7 };
|
|
68
|
-
DrawTextureEx(tex, (Vector2){posX, posY},
|
|
65
|
+
DrawTextureEx(tex, (Vector2){posX, posY}, rotation, scale, tint);
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
void DrawTextureRecW(unsigned int id, int w, int h, int srcX, int srcY, int srcW, int srcH, int posX, int posY, Color tint) {
|
|
@@ -77,13 +74,11 @@ void DrawTextureRecW(unsigned int id, int w, int h, int srcX, int srcY, int srcW
|
|
|
77
74
|
void DrawTextureProW(unsigned int id, int w, int h,
|
|
78
75
|
int srcX, int srcY, int srcW, int srcH,
|
|
79
76
|
int dstX, int dstY, int dstW, int dstH,
|
|
80
|
-
int originX, int originY,
|
|
81
|
-
float r;
|
|
82
|
-
memcpy(&r, &rotation, sizeof(float));
|
|
77
|
+
int originX, int originY, float rotation, Color tint) {
|
|
83
78
|
Texture2D tex = { id, w, h, 1, 7 };
|
|
84
79
|
Rectangle src = { srcX, srcY, srcW, srcH };
|
|
85
80
|
Rectangle dst = { dstX, dstY, dstW, dstH };
|
|
86
|
-
DrawTexturePro(tex, src, dst, (Vector2){originX, originY},
|
|
81
|
+
DrawTexturePro(tex, src, dst, (Vector2){originX, originY}, rotation, tint);
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
void LoadTextureFromImageW(unsigned int* outId, int* outW, int* outH, int imageId) {
|
|
@@ -119,21 +114,11 @@ void DrawTextureNPatchW(unsigned int id, int w, int h,
|
|
|
119
114
|
int srcX, int srcY, int srcW, int srcH,
|
|
120
115
|
int left, int top, int right, int bottom, int layout,
|
|
121
116
|
int dstX, int dstY, int dstW, int dstH,
|
|
122
|
-
int originX, int originY,
|
|
123
|
-
float r;
|
|
124
|
-
memcpy(&r, &rotation, sizeof(float));
|
|
117
|
+
int originX, int originY, float rotation, Color tint) {
|
|
125
118
|
Texture2D tex = { id, w, h, 1, 7 };
|
|
126
119
|
Rectangle src = { srcX, srcY, srcW, srcH };
|
|
127
120
|
NPatchInfo npi = { src, left, top, right, bottom, layout };
|
|
128
121
|
Rectangle dst = { dstX, dstY, dstW, dstH };
|
|
129
|
-
DrawTextureNPatch(tex, npi, dst, (Vector2){originX, originY},
|
|
122
|
+
DrawTextureNPatch(tex, npi, dst, (Vector2){originX, originY}, rotation, tint);
|
|
130
123
|
}
|
|
131
124
|
|
|
132
|
-
int GetPixelColorW(const void* srcPtr, int format) {
|
|
133
|
-
Color c = GetPixelColor((void*)srcPtr, format);
|
|
134
|
-
return *((int*)&c);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
void SetPixelColorW(void* dstPtr, Color color, int format) {
|
|
138
|
-
SetPixelColor(dstPtr, color, format);
|
|
139
|
-
}
|