Fixed a raylib-d bug with DUB.

This commit is contained in:
Kapendev 2024-06-08 09:50:50 +03:00
parent 5ca28d6340
commit 1b4e5f4736
3 changed files with 183 additions and 179 deletions

View file

@ -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.
It is recommended to remove raylib-d from your dub.json file after the installation is complete.
2. **Compile example**

View file

@ -7,6 +7,9 @@ module popka.vendor.ray.raylibpp;
import popka.vendor.ray.raylib;
enum isRaylibPackageAvailable = is(typeof((){import raylib;}));
static if (!isRaylibPackageAvailable) {
// Basic shapes drawing functions
alias drawPixel = DrawPixel;
alias drawPixel = DrawPixelV;
@ -162,16 +165,6 @@ alias drawBillboard = DrawBillboardPro;
alias drawMesh = DrawMesh;
alias drawMeshInstanced = DrawMeshInstanced;
version (WebAssembly) {
@nogc nothrow extern(C)
void emscripten_set_main_loop(void* ptr, int fps, int loop);
@nogc nothrow extern(C)
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() {
@ -207,3 +200,13 @@ mixin template addRayStart(alias startFunc) {
}
}
}
} else {
pragma(msg, "Helper functions are not available when raylib-d is a DUB dependecy. Remove raylib-d from your dub.json file.");
}
version (WebAssembly) {
@nogc nothrow extern(C)
void emscripten_set_main_loop(void* ptr, int fps, int loop);
@nogc nothrow extern(C)
void emscripten_cancel_main_loop();
}

View file

@ -143,7 +143,7 @@ int main(string[] args) {
auto mode = args.length > 1 ? args[1] : "";
if (mode != "build" && mode != "run") {
writeln("Error: `", mode, "` isn't a mode.\nAvailable modes: [build, run]");
return -1;
return 1;
}
// Can pass extra flags to ldc if needed.