summaryrefslogtreecommitdiff
path: root/examples/spheres/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:15:15 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit9bd77e54943d954291b5faef287ccca5dcebd7a4 (patch)
tree3f2d628781441568620b8108fab920713f26f649 /examples/spheres/build.zig
parente997fc3e6b312b30f5af90012fc22365bab701d4 (diff)
downloadsketchbook-9bd77e54943d954291b5faef287ccca5dcebd7a4.tar.gz
sketchbook-9bd77e54943d954291b5faef287ccca5dcebd7a4.zip
examples: micscope and spheres come home, as they were, building
Both lived outside any repository, beside sketchbook, with manifests that pointed at ../01-drat-meout/lib/sketchbook, which no longer exists. They are copied into examples/micscope and examples/spheres (their sources, shaders, tests, test material and web icons; not their caches, builds, packages, state files or .gitignore, which the root's covers), their manifests depend on "../.." as the other examples do, and their READMEs link sketchbook there. Nothing else changed: both build against today's library and pass their own zig build test (micscope 62/62 steps, 11/11 tests, its transport, record, render and tuner scripts; spheres 75/75 steps, 3/3 tests, its play script). The originals are untouched. micscope's test/reference.flac (3.7 MiB, CC BY-SA 3.0, credited in its test/README.md) is the rendering reference its render script opens. The README lists both examples. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'examples/spheres/build.zig')
-rw-r--r--examples/spheres/build.zig55
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/spheres/build.zig b/examples/spheres/build.zig
new file mode 100644
index 0000000..8cc8f60
--- /dev/null
+++ b/examples/spheres/build.zig
@@ -0,0 +1,55 @@
+const std = @import("std");
+const sketchbook = @import("sketchbook");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+ const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize });
+
+ // The simulation, the synthesiser and the sky, as SPIR-V for the native
+ // host and WGSL for the web; their uniforms are src/layouts.zig's structs.
+ const layouts = b.createModule(.{ .root_source_file = b.path("src/layouts.zig") });
+ const shaders = sb.addShaders(.{
+ .layouts = .{ .module = layouts, .types = &.{ "SimParams", "LookParams", "SynthParams", "SkyView", "Fade" } },
+ .sources = &.{
+ b.path("shaders/sim.comp"),
+ b.path("shaders/lookahead.comp"),
+ b.path("shaders/rechord.comp"),
+ b.path("shaders/synth.comp"),
+ b.path("shaders/advance.comp"),
+ b.path("shaders/fullscreen.vert"),
+ b.path("shaders/fade.frag"),
+ b.path("shaders/sprite.vert"),
+ b.path("shaders/sprite.frag"),
+ b.path("shaders/trail.vert"),
+ b.path("shaders/trail.frag"),
+ b.path("shaders/link.vert"),
+ b.path("shaders/link.frag"),
+ },
+ });
+
+ const app = sb.app(.{
+ .name = "spheres",
+ .root_source_file = b.path("src/main.zig"),
+ .imports = &.{
+ .{ .name = "layouts", .module = layouts },
+ .{ .name = "shaders", .module = shaders.module },
+ .{ .name = "scope", .module = sb.modules.scope },
+ },
+ });
+ _ = app.addSteps(.{
+ // Installable, and it opens offline (icons from web/icon.svg).
+ // ReleaseSmall: a third the size of ReleaseSafe's wasm, and Zig
+ // 0.17's LLVM spins for many minutes optimising this sketch for speed.
+ .web = .{ .optimize = .ReleaseSmall, .pwa = .{
+ .description = "The three-body problem on the GPU, heard: each body a voice in FM, PM, AM, ring or additive synthesis.",
+ .background = "#05070d",
+ .theme = "#05070d",
+ .icons = &.{
+ .{ .source = b.path("web/icon-192.png"), .size = 192 },
+ .{ .source = b.path("web/icon-512.png"), .size = 512 },
+ },
+ } },
+ .scripts = &.{b.path("test/play.script")},
+ });
+}