mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-27 21:49:57 +03:00
Fixed a raylib-d bug with DUB.
This commit is contained in:
parent
5ca28d6340
commit
1b4e5f4736
3 changed files with 183 additions and 179 deletions
|
@ -53,6 +53,7 @@ While DUB simplifies the setup process, Popka itself doesn't require DUB.
|
||||||
```
|
```
|
||||||
|
|
||||||
Popka doesn't require raylib-d, but we include it as a dependency for its convenient raylib download script.
|
Popka doesn't require raylib-d, but we include it as a dependency for its convenient raylib download script.
|
||||||
|
It is recommended to remove raylib-d from your dub.json file after the installation is complete.
|
||||||
|
|
||||||
2. **Compile example**
|
2. **Compile example**
|
||||||
|
|
||||||
|
|
359
source/popka/vendor/ray/raylibpp.d
vendored
359
source/popka/vendor/ray/raylibpp.d
vendored
|
@ -7,203 +7,206 @@ module popka.vendor.ray.raylibpp;
|
||||||
|
|
||||||
import popka.vendor.ray.raylib;
|
import popka.vendor.ray.raylib;
|
||||||
|
|
||||||
// Basic shapes drawing functions
|
enum isRaylibPackageAvailable = is(typeof((){import raylib;}));
|
||||||
alias drawPixel = DrawPixel;
|
|
||||||
alias drawPixel = DrawPixelV;
|
|
||||||
|
|
||||||
alias drawLine = DrawLine;
|
static if (!isRaylibPackageAvailable) {
|
||||||
alias drawLine = DrawLineV;
|
// Basic shapes drawing functions
|
||||||
alias drawLine = DrawLineEx;
|
alias drawPixel = DrawPixel;
|
||||||
alias drawLine = DrawLineStrip;
|
alias drawPixel = DrawPixelV;
|
||||||
alias drawLineBezier = DrawLineBezier;
|
|
||||||
|
|
||||||
alias drawCircle = DrawCircle;
|
alias drawLine = DrawLine;
|
||||||
alias drawCircleSector = DrawCircleSector;
|
alias drawLine = DrawLineV;
|
||||||
alias drawCircleSectorLines = DrawCircleSectorLines;
|
alias drawLine = DrawLineEx;
|
||||||
alias drawCircle = DrawCircleGradient;
|
alias drawLine = DrawLineStrip;
|
||||||
alias drawCircle = DrawCircleV;
|
alias drawLineBezier = DrawLineBezier;
|
||||||
alias drawCircleLines = DrawCircleLines;
|
|
||||||
alias drawCircleLines = DrawCircleLinesV;
|
|
||||||
|
|
||||||
alias drawEllipse = DrawEllipse;
|
alias drawCircle = DrawCircle;
|
||||||
alias drawEllipseLines = DrawEllipseLines;
|
alias drawCircleSector = DrawCircleSector;
|
||||||
|
alias drawCircleSectorLines = DrawCircleSectorLines;
|
||||||
|
alias drawCircle = DrawCircleGradient;
|
||||||
|
alias drawCircle = DrawCircleV;
|
||||||
|
alias drawCircleLines = DrawCircleLines;
|
||||||
|
alias drawCircleLines = DrawCircleLinesV;
|
||||||
|
|
||||||
alias drawRing = DrawRing;
|
alias drawEllipse = DrawEllipse;
|
||||||
alias drawRingLines = DrawRingLines;
|
alias drawEllipseLines = DrawEllipseLines;
|
||||||
|
|
||||||
alias drawRectangle = DrawRectangle;
|
alias drawRing = DrawRing;
|
||||||
alias drawRectangle = DrawRectangleV;
|
alias drawRingLines = DrawRingLines;
|
||||||
alias drawRectangle = DrawRectangleRec;
|
|
||||||
alias drawRectangle = DrawRectanglePro;
|
|
||||||
alias drawRectangleGradientV = DrawRectangleGradientV;
|
|
||||||
alias drawRectangleGradientH = DrawRectangleGradientH;
|
|
||||||
alias drawRectangle = DrawRectangleGradientEx;
|
|
||||||
alias drawRectangleLines = DrawRectangleLines;
|
|
||||||
alias drawRectangleLines = DrawRectangleLinesEx;
|
|
||||||
alias drawRectangleRounded = DrawRectangleRounded;
|
|
||||||
alias drawRectangleRoundedLines = DrawRectangleRoundedLines;
|
|
||||||
|
|
||||||
alias drawTriangle = DrawTriangle;
|
alias drawRectangle = DrawRectangle;
|
||||||
alias drawTriangleLines = DrawTriangleLines;
|
alias drawRectangle = DrawRectangleV;
|
||||||
alias drawTriangleFan = DrawTriangleFan;
|
alias drawRectangle = DrawRectangleRec;
|
||||||
alias drawTriangleStrip = DrawTriangleStrip;
|
alias drawRectangle = DrawRectanglePro;
|
||||||
alias drawPoly = DrawPoly;
|
alias drawRectangleGradientV = DrawRectangleGradientV;
|
||||||
alias drawPolyLines = DrawPolyLines;
|
alias drawRectangleGradientH = DrawRectangleGradientH;
|
||||||
alias drawPolyLines = DrawPolyLinesEx;
|
alias drawRectangle = DrawRectangleGradientEx;
|
||||||
|
alias drawRectangleLines = DrawRectangleLines;
|
||||||
|
alias drawRectangleLines = DrawRectangleLinesEx;
|
||||||
|
alias drawRectangleRounded = DrawRectangleRounded;
|
||||||
|
alias drawRectangleRoundedLines = DrawRectangleRoundedLines;
|
||||||
|
|
||||||
// Splines drawing functions
|
alias drawTriangle = DrawTriangle;
|
||||||
alias drawSplineLinear = DrawSplineLinear;
|
alias drawTriangleLines = DrawTriangleLines;
|
||||||
alias drawSplineBasis = DrawSplineBasis;
|
alias drawTriangleFan = DrawTriangleFan;
|
||||||
alias drawSplineCatmullRom = DrawSplineCatmullRom;
|
alias drawTriangleStrip = DrawTriangleStrip;
|
||||||
alias drawSplineBezierQuadratic = DrawSplineBezierQuadratic;
|
alias drawPoly = DrawPoly;
|
||||||
alias drawSplineBezierCubic = DrawSplineBezierCubic;
|
alias drawPolyLines = DrawPolyLines;
|
||||||
alias drawSplineSegmentLinear = DrawSplineSegmentLinear;
|
alias drawPolyLines = DrawPolyLinesEx;
|
||||||
alias drawSplineSegmentBasis = DrawSplineSegmentBasis;
|
|
||||||
alias drawSplineSegmentCatmullRom = DrawSplineSegmentCatmullRom;
|
|
||||||
alias drawSplineSegmentBezierQuadratic = DrawSplineSegmentBezierQuadratic;
|
|
||||||
alias drawSplineSegmentBezierCubic = DrawSplineSegmentBezierCubic;
|
|
||||||
|
|
||||||
// Texture drawing functions
|
// Splines drawing functions
|
||||||
alias drawTexture = DrawTexture;
|
alias drawSplineLinear = DrawSplineLinear;
|
||||||
alias drawTexture = DrawTextureV;
|
alias drawSplineBasis = DrawSplineBasis;
|
||||||
alias drawTexture = DrawTextureEx;
|
alias drawSplineCatmullRom = DrawSplineCatmullRom;
|
||||||
alias drawTexture = DrawTextureRec;
|
alias drawSplineBezierQuadratic = DrawSplineBezierQuadratic;
|
||||||
alias drawTexture = DrawTexturePro;
|
alias drawSplineBezierCubic = DrawSplineBezierCubic;
|
||||||
alias drawTexture = DrawTextureNPatch;
|
alias drawSplineSegmentLinear = DrawSplineSegmentLinear;
|
||||||
|
alias drawSplineSegmentBasis = DrawSplineSegmentBasis;
|
||||||
|
alias drawSplineSegmentCatmullRom = DrawSplineSegmentCatmullRom;
|
||||||
|
alias drawSplineSegmentBezierQuadratic = DrawSplineSegmentBezierQuadratic;
|
||||||
|
alias drawSplineSegmentBezierCubic = DrawSplineSegmentBezierCubic;
|
||||||
|
|
||||||
// Text drawing functions
|
// Texture drawing functions
|
||||||
alias drawFPS = DrawFPS;
|
alias drawTexture = DrawTexture;
|
||||||
|
alias drawTexture = DrawTextureV;
|
||||||
|
alias drawTexture = DrawTextureEx;
|
||||||
|
alias drawTexture = DrawTextureRec;
|
||||||
|
alias drawTexture = DrawTexturePro;
|
||||||
|
alias drawTexture = DrawTextureNPatch;
|
||||||
|
|
||||||
@nogc nothrow
|
// Text drawing functions
|
||||||
void drawText(const(char)[] text, float posX, float posY, float fontSize, Color color) {
|
alias drawFPS = DrawFPS;
|
||||||
drawText(GetFontDefault(), text, Vector2(posX, posY), Vector2(0.0f, 0.0f), 0.0f, fontSize, 2.0f, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@nogc nothrow
|
@nogc nothrow
|
||||||
void drawText(Font font, const(char)[] text, Vector2 position, float fontSize, float spacing, Color tint) {
|
void drawText(const(char)[] text, float posX, float posY, float fontSize, Color color) {
|
||||||
drawText(font, text, position, Vector2(0.0f, 0.0f), 0.0f, fontSize, spacing, tint);
|
drawText(GetFontDefault(), text, Vector2(posX, posY), Vector2(0.0f, 0.0f), 0.0f, fontSize, 2.0f, color);
|
||||||
}
|
|
||||||
|
|
||||||
@nogc nothrow
|
|
||||||
void drawText(Font font, const(char)[] text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint) {
|
|
||||||
static char[1024] buffer = void;
|
|
||||||
auto text2 = buffer[];
|
|
||||||
foreach (i, c; text) {
|
|
||||||
text2[i] = c;
|
|
||||||
}
|
}
|
||||||
text2[text.length] = '\0';
|
|
||||||
DrawTextPro(font, text2.ptr, position, origin, rotation, fontSize, spacing, tint);
|
|
||||||
}
|
|
||||||
|
|
||||||
alias drawText = DrawTextCodepoint;
|
@nogc nothrow
|
||||||
|
void drawText(Font font, const(char)[] text, Vector2 position, float fontSize, float spacing, Color tint) {
|
||||||
@nogc nothrow
|
drawText(font, text, position, Vector2(0.0f, 0.0f), 0.0f, fontSize, spacing, tint);
|
||||||
void drawText(Font font, const(int)[] codepoints, Vector2 position, float fontSize, float spacing, Color tint) {
|
|
||||||
DrawTextCodepoints(font, codepoints.ptr, cast(int) codepoints.length, position, fontSize, spacing, tint);
|
|
||||||
}
|
|
||||||
|
|
||||||
@nogc nothrow
|
|
||||||
float measureText(const(char)[] text, float fontSize) {
|
|
||||||
return measureText(GetFontDefault(), text, fontSize, 2.0f).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
@nogc nothrow
|
|
||||||
Vector2 measureText(Font font, const(char)[] text, float fontSize, float spacing) {
|
|
||||||
static char[1024] buffer = void;
|
|
||||||
auto text2 = buffer[];
|
|
||||||
foreach (i, c; text) {
|
|
||||||
text2[i] = c;
|
|
||||||
}
|
}
|
||||||
text2[text.length] = '\0';
|
|
||||||
return MeasureTextEx(font, text2.ptr, fontSize, spacing);
|
@nogc nothrow
|
||||||
|
void drawText(Font font, const(char)[] text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint) {
|
||||||
|
static char[1024] buffer = void;
|
||||||
|
auto text2 = buffer[];
|
||||||
|
foreach (i, c; text) {
|
||||||
|
text2[i] = c;
|
||||||
|
}
|
||||||
|
text2[text.length] = '\0';
|
||||||
|
DrawTextPro(font, text2.ptr, position, origin, rotation, fontSize, spacing, tint);
|
||||||
|
}
|
||||||
|
|
||||||
|
alias drawText = DrawTextCodepoint;
|
||||||
|
|
||||||
|
@nogc nothrow
|
||||||
|
void drawText(Font font, const(int)[] codepoints, Vector2 position, float fontSize, float spacing, Color tint) {
|
||||||
|
DrawTextCodepoints(font, codepoints.ptr, cast(int) codepoints.length, position, fontSize, spacing, tint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@nogc nothrow
|
||||||
|
float measureText(const(char)[] text, float fontSize) {
|
||||||
|
return measureText(GetFontDefault(), text, fontSize, 2.0f).x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@nogc nothrow
|
||||||
|
Vector2 measureText(Font font, const(char)[] text, float fontSize, float spacing) {
|
||||||
|
static char[1024] buffer = void;
|
||||||
|
auto text2 = buffer[];
|
||||||
|
foreach (i, c; text) {
|
||||||
|
text2[i] = c;
|
||||||
|
}
|
||||||
|
text2[text.length] = '\0';
|
||||||
|
return MeasureTextEx(font, text2.ptr, fontSize, spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Basic geometric 3D shapes drawing functions
|
||||||
|
alias drawLine3D = DrawLine3D;
|
||||||
|
alias drawPoint3D = DrawPoint3D;
|
||||||
|
alias drawCircle3D = DrawCircle3D;
|
||||||
|
|
||||||
|
alias drawTriangle3D = DrawTriangle3D;
|
||||||
|
alias drawTriangle3D = DrawTriangleStrip3D;
|
||||||
|
|
||||||
|
alias drawCube = DrawCube;
|
||||||
|
alias drawCube = DrawCubeV;
|
||||||
|
alias drawCubeWires = DrawCubeWires;
|
||||||
|
alias drawCubeWires = DrawCubeWiresV;
|
||||||
|
|
||||||
|
alias drawSphere = DrawSphere;
|
||||||
|
alias drawSphere = DrawSphereEx;
|
||||||
|
alias drawSphereWires = DrawSphereWires;
|
||||||
|
|
||||||
|
alias drawCylinder = DrawCylinder;
|
||||||
|
alias drawCylinder = DrawCylinderEx;
|
||||||
|
alias drawCylinderWires = DrawCylinderWires;
|
||||||
|
alias drawCylinderWires = DrawCylinderWiresEx;
|
||||||
|
|
||||||
|
alias drawCapsule = DrawCapsule;
|
||||||
|
alias drawCapsuleWires = DrawCapsuleWires;
|
||||||
|
alias drawPlane = DrawPlane;
|
||||||
|
alias drawRay = DrawRay;
|
||||||
|
alias drawGrid = DrawGrid;
|
||||||
|
|
||||||
|
// Model drawing functions
|
||||||
|
alias drawModel = DrawModel;
|
||||||
|
alias drawModel = DrawModelEx;
|
||||||
|
alias drawModelWires = DrawModelWires;
|
||||||
|
alias drawModelWires = DrawModelWiresEx;
|
||||||
|
|
||||||
|
alias drawBoundingBox = DrawBoundingBox;
|
||||||
|
|
||||||
|
alias drawBillboard = DrawBillboard;
|
||||||
|
alias drawBillboard = DrawBillboardRec;
|
||||||
|
alias drawBillboard = DrawBillboardPro;
|
||||||
|
|
||||||
|
// Mesh management functions
|
||||||
|
alias drawMesh = DrawMesh;
|
||||||
|
alias drawMeshInstanced = DrawMeshInstanced;
|
||||||
|
|
||||||
|
void updateWindow(alias loopFunc)() {
|
||||||
|
version(WebAssembly) {
|
||||||
|
static void __loopFunc() {
|
||||||
|
loopFunc();
|
||||||
|
}
|
||||||
|
emscripten_set_main_loop(&__loopFunc, 0, 1);
|
||||||
|
} else {
|
||||||
|
while (true) {
|
||||||
|
if (WindowShouldClose || loopFunc()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mixin template addRayStart(alias startFunc) {
|
||||||
|
version (D_BetterC) {
|
||||||
|
extern(C)
|
||||||
|
void main(int argc, immutable(char)** argv) {
|
||||||
|
@trusted @nogc nothrow
|
||||||
|
static string __helper(immutable(char)* strz) {
|
||||||
|
size_t length = 0;
|
||||||
|
while (strz[length] != '\0') {
|
||||||
|
length += 1;
|
||||||
|
}
|
||||||
|
return strz[0 .. length];
|
||||||
|
}
|
||||||
|
startFunc(__helper(argv[0]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
void main(string[] args) {
|
||||||
|
startFunc(args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pragma(msg, "Helper functions are not available when raylib-d is a DUB dependecy. Remove raylib-d from your dub.json file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic geometric 3D shapes drawing functions
|
|
||||||
alias drawLine3D = DrawLine3D;
|
|
||||||
alias drawPoint3D = DrawPoint3D;
|
|
||||||
alias drawCircle3D = DrawCircle3D;
|
|
||||||
|
|
||||||
alias drawTriangle3D = DrawTriangle3D;
|
|
||||||
alias drawTriangle3D = DrawTriangleStrip3D;
|
|
||||||
|
|
||||||
alias drawCube = DrawCube;
|
|
||||||
alias drawCube = DrawCubeV;
|
|
||||||
alias drawCubeWires = DrawCubeWires;
|
|
||||||
alias drawCubeWires = DrawCubeWiresV;
|
|
||||||
|
|
||||||
alias drawSphere = DrawSphere;
|
|
||||||
alias drawSphere = DrawSphereEx;
|
|
||||||
alias drawSphereWires = DrawSphereWires;
|
|
||||||
|
|
||||||
alias drawCylinder = DrawCylinder;
|
|
||||||
alias drawCylinder = DrawCylinderEx;
|
|
||||||
alias drawCylinderWires = DrawCylinderWires;
|
|
||||||
alias drawCylinderWires = DrawCylinderWiresEx;
|
|
||||||
|
|
||||||
alias drawCapsule = DrawCapsule;
|
|
||||||
alias drawCapsuleWires = DrawCapsuleWires;
|
|
||||||
alias drawPlane = DrawPlane;
|
|
||||||
alias drawRay = DrawRay;
|
|
||||||
alias drawGrid = DrawGrid;
|
|
||||||
|
|
||||||
// Model drawing functions
|
|
||||||
alias drawModel = DrawModel;
|
|
||||||
alias drawModel = DrawModelEx;
|
|
||||||
alias drawModelWires = DrawModelWires;
|
|
||||||
alias drawModelWires = DrawModelWiresEx;
|
|
||||||
|
|
||||||
alias drawBoundingBox = DrawBoundingBox;
|
|
||||||
|
|
||||||
alias drawBillboard = DrawBillboard;
|
|
||||||
alias drawBillboard = DrawBillboardRec;
|
|
||||||
alias drawBillboard = DrawBillboardPro;
|
|
||||||
|
|
||||||
// Mesh management functions
|
|
||||||
alias drawMesh = DrawMesh;
|
|
||||||
alias drawMeshInstanced = DrawMeshInstanced;
|
|
||||||
|
|
||||||
version (WebAssembly) {
|
version (WebAssembly) {
|
||||||
@nogc nothrow extern(C)
|
@nogc nothrow extern(C)
|
||||||
void emscripten_set_main_loop(void* ptr, int fps, int loop);
|
void emscripten_set_main_loop(void* ptr, int fps, int loop);
|
||||||
@nogc nothrow extern(C)
|
@nogc nothrow extern(C)
|
||||||
void emscripten_cancel_main_loop();
|
void emscripten_cancel_main_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We intentionally leave attributes out to provide maximum flexibility for any use case.
|
|
||||||
// The given function should return a bool value.
|
|
||||||
// A return value of true will exit the loop, while false will allow it to continue.
|
|
||||||
void updateWindow(alias loopFunc)() {
|
|
||||||
version(WebAssembly) {
|
|
||||||
static void __loopFunc() {
|
|
||||||
loopFunc();
|
|
||||||
}
|
|
||||||
emscripten_set_main_loop(&__loopFunc, 0, 1);
|
|
||||||
} else {
|
|
||||||
while (true) {
|
|
||||||
if (WindowShouldClose || loopFunc()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mixin template addRayStart(alias startFunc) {
|
|
||||||
version (D_BetterC) {
|
|
||||||
extern(C)
|
|
||||||
void main(int argc, immutable(char)** argv) {
|
|
||||||
@trusted @nogc nothrow
|
|
||||||
static string __helper(immutable(char)* strz) {
|
|
||||||
size_t length = 0;
|
|
||||||
while (strz[length] != '\0') {
|
|
||||||
length += 1;
|
|
||||||
}
|
|
||||||
return strz[0 .. length];
|
|
||||||
}
|
|
||||||
startFunc(__helper(argv[0]));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
void main(string[] args) {
|
|
||||||
startFunc(args[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ int main(string[] args) {
|
||||||
auto mode = args.length > 1 ? args[1] : "";
|
auto mode = args.length > 1 ? args[1] : "";
|
||||||
if (mode != "build" && mode != "run") {
|
if (mode != "build" && mode != "run") {
|
||||||
writeln("Error: `", mode, "` isn't a mode.\nAvailable modes: [build, run]");
|
writeln("Error: `", mode, "` isn't a mode.\nAvailable modes: [build, run]");
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can pass extra flags to ldc if needed.
|
// Can pass extra flags to ldc if needed.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue