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")}, }); }