diff --git a/README.md b/README.md index 7b87688..bb36fb5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Auto-generated [D](https://dlang.org) bindings for the [sokol headers](https://g **Required** - [zig](https://ziglang.org/download) v0.12.0 or master -- [ldc](https://ldc-developers.github.io) v1.35.0 or latest-CI (nightly) +- [ldc](https://ldc-developers.github.io) v1.36.0 or latest-CI (nightly) Supported platforms are: Windows, macOS, Linux (with X11) @@ -27,11 +27,11 @@ zig build -Doptimize=ReleaseFast -Dshared zig build run-blend -Doptimize=ReleaseFast zig build run-clear -Doptimize=ReleaseFast zig build run-cube -Doptimize=ReleaseFast -zig build run-debugtext-print -Doptimize=ReleaseFast +zig build run-debugtext_print -Doptimize=ReleaseFast zig build run-mrt -Doptimize=ReleaseFast zig build run-saudio -Doptimize=ReleaseFast -zig build run-sgl-context -Doptimize=ReleaseFast -zig build run-user-data -Doptimize=ReleaseFast +zig build run-sgl_context -Doptimize=ReleaseFast +zig build run-user_data -Doptimize=ReleaseFast zig build run-triangle -Doptimize=ReleaseFast zig build --help @@ -50,8 +50,8 @@ zig build --help # ReleaseFast # ReleaseSmall # -Dshared=[bool] Build sokol dynamic library (default: static) -# -DbetterC=[bool] Omit generating some runtime information and helper functions. (default: false) -# -DzigCC=[bool] Use zig cc as compiler and linker. (default: false) +# -DbetterC=[bool] Omit generating some runtime information and helper functions (default: false) +# -DzigCC=[bool] Use zig cc as compiler and linker (default: false) ``` ## Shaders diff --git a/build.zig b/build.zig index bfd47ec..c90c9e5 100644 --- a/build.zig +++ b/build.zig @@ -224,7 +224,7 @@ pub fn build(b: *Build) !void { "saudio", "sgl_context", "debugtext_print", - // "user_data", // Need GC for user data [associative array] + "user_data", // Need GC for user data [associative array] }; inline for (examples) |example| { @@ -237,8 +237,10 @@ pub fn build(b: *Build) !void { "-w", // warnings as error // more info: ldc2 -preview=help (list all specs) "-preview=all", - "-lowmem", }, + .d_packages = if (target.result.isWasm()) &[_][]const u8{ + b.dependency("wasmd", .{}).path("arsd-webassembly").getPath(b), + } else null, // fixme: https://github.com/kassane/sokol-d/issues/1 - betterC works on darwin .zig_cc = if (target.result.isDarwin() and !enable_betterC) false else enable_zigcc, .target = target, diff --git a/build.zig.zon b/build.zig.zon index e2561eb..6a0c2b5 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -13,5 +13,9 @@ .url = "git+https://github.com/emscripten-core/emsdk#0bbae74935d57ff41739648c12cf90b56668398f", .hash = "1220f1340cd871b444021c600661f921f96091ce0815fa43008528f4844cece7e245", }, + .wasmd = .{ + .url = "git+https://github.com/kassane/webassembly#800870e68be1518eeffbb2c0814e23b9543a89cb", + .hash = "12203c2350903f04a07f746b448abb22824a452e8d81500b2fa11a0c3a5ea896b3f6", + }, }, } diff --git a/dub.json b/dub.json deleted file mode 100644 index 47cb4e8..0000000 --- a/dub.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "sokol-d", - "description": "Autogenerated D bindings for the sokol-headers", - "version": "0.1.0", - "license": "zlib", - "authors": ["Matheus Catarino França"], - "targetType": "sourceLibrary", - - "configurations": [ - { - "name": "debugtext_print", - "targetType": "executable", - "sourceFiles": ["src/examples/debugtext_print.d"], - "buildTypes": { - "debug": { - "buildOptions": ["debugMode", "debugInfo", "optimize"], - "dflags": ["-g"], - "lflags": ["-L$PWD/sokol/lib"], - "libs": ["sokol"], - "libs-posix": ["X11", "GL", "Xi", "Xcursor"] - }, - "release": { - "buildOptions": ["releaseMode", "optimize", "inline"], - "dflags": ["--release", "-boundscheck=on"], - "lflags": ["-L$PWD/sokol/lib"], - "cflags": ["-DSOKOL_GLCORE33"], - "libs": ["sokol","glibc"], - "libs-posix": ["X11", "GL", "Xi", "Xcursor"] - } - } - } - ] -} \ No newline at end of file diff --git a/src/examples/user_data.d b/src/examples/user_data.d index 263c42c..4671a23 100644 --- a/src/examples/user_data.d +++ b/src/examples/user_data.d @@ -26,13 +26,20 @@ void frame_userdata(scope void* userdata) @trusted auto state = cast(ExampleUserData*) userdata; state.data++; - if (state.data % 13 == 0) { - state.map[state.data] = state.data * 13 / 3; + + version(WebAssembly){ + // TODO support } - if (state.data % 12 == 0 && state.data % 15 == 0) { - state.map.clear(); + else + { + if (state.data % 13 == 0) { + state.map[state.data] = state.data * 13 / 3; + } + if (state.data % 12 == 0 && state.data % 15 == 0) { + state.map.clear(); + } } - debug { + debug { import std.stdio : writeln; try { writeln(*state); @@ -52,7 +59,7 @@ void cleanup() @safe void main() { - ExampleUserData userData; + auto userData = ExampleUserData(0, null); sapp.Desc runner = { window_title: "user-data.d",