examples: simplify dependencies, mach depends on Opus
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
8578613adc
commit
0200bed7ec
3 changed files with 14 additions and 13 deletions
18
build.zig
18
build.zig
|
|
@ -97,6 +97,13 @@ pub fn build(b: *std.Build) !void {
|
||||||
module.addImport("mach-freetype", dep.module("mach-freetype"));
|
module.addImport("mach-freetype", dep.module("mach-freetype"));
|
||||||
module.addImport("mach-harfbuzz", dep.module("mach-harfbuzz"));
|
module.addImport("mach-harfbuzz", dep.module("mach-harfbuzz"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b.lazyDependency("mach_opus", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
})) |dep| {
|
||||||
|
module.addImport("mach-opus", dep.module("mach-opus"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (b.lazyDependency("font_assets", .{})) |dep| module.addImport("font-assets", dep.module("font-assets"));
|
if (b.lazyDependency("font_assets", .{})) |dep| module.addImport("font-assets", dep.module("font-assets"));
|
||||||
|
|
||||||
|
|
@ -554,7 +561,6 @@ fn buildExamples(
|
||||||
) !void {
|
) !void {
|
||||||
const Dependency = enum {
|
const Dependency = enum {
|
||||||
assets,
|
assets,
|
||||||
opus,
|
|
||||||
model3d,
|
model3d,
|
||||||
freetype,
|
freetype,
|
||||||
zigimg,
|
zigimg,
|
||||||
|
|
@ -570,9 +576,9 @@ fn buildExamples(
|
||||||
.{ .name = "custom-renderer", .deps = &.{} },
|
.{ .name = "custom-renderer", .deps = &.{} },
|
||||||
.{ .name = "glyphs", .deps = &.{ .freetype, .assets } },
|
.{ .name = "glyphs", .deps = &.{ .freetype, .assets } },
|
||||||
.{ .name = "piano", .deps = &.{} },
|
.{ .name = "piano", .deps = &.{} },
|
||||||
.{ .name = "play-opus", .deps = &.{ .opus, .assets } },
|
.{ .name = "play-opus", .deps = &.{.assets} },
|
||||||
.{ .name = "sprite", .deps = &.{ .zigimg, .assets } },
|
.{ .name = "sprite", .deps = &.{ .zigimg, .assets } },
|
||||||
.{ .name = "text", .deps = &.{ .freetype, .assets } },
|
.{ .name = "text", .deps = &.{.assets} },
|
||||||
}) |example| {
|
}) |example| {
|
||||||
if (target.result.cpu.arch == .wasm32 and !example.wasm) continue;
|
if (target.result.cpu.arch == .wasm32 and !example.wasm) continue;
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
|
|
@ -594,12 +600,6 @@ fn buildExamples(
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
})) |dep| exe.root_module.addImport("assets", dep.module("mach-example-assets"));
|
})) |dep| exe.root_module.addImport("assets", dep.module("mach-example-assets"));
|
||||||
},
|
},
|
||||||
.opus => {
|
|
||||||
if (b.lazyDependency("mach_opus", .{
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
})) |dep| exe.root_module.addImport("opus", dep.module("mach-opus"));
|
|
||||||
},
|
|
||||||
.model3d => {
|
.model3d => {
|
||||||
if (b.lazyDependency("mach_model3d", .{
|
if (b.lazyDependency("mach_model3d", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ const builtin = @import("builtin");
|
||||||
|
|
||||||
const mach = @import("mach");
|
const mach = @import("mach");
|
||||||
const assets = @import("assets");
|
const assets = @import("assets");
|
||||||
const Opus = @import("opus");
|
|
||||||
const gpu = mach.gpu;
|
const gpu = mach.gpu;
|
||||||
const math = mach.math;
|
const math = mach.math;
|
||||||
const sysaudio = mach.sysaudio;
|
const sysaudio = mach.sysaudio;
|
||||||
|
|
@ -30,7 +29,7 @@ pub const components = .{
|
||||||
.is_bgm = .{ .type = void },
|
.is_bgm = .{ .type = void },
|
||||||
};
|
};
|
||||||
|
|
||||||
sfx: Opus,
|
sfx: mach.Audio.Opus,
|
||||||
|
|
||||||
fn init(
|
fn init(
|
||||||
entities: *mach.Entities.Mod,
|
entities: *mach.Entities.Mod,
|
||||||
|
|
@ -45,10 +44,10 @@ fn init(
|
||||||
const sfx_fbs = std.io.fixedBufferStream(assets.sfx.sword1);
|
const sfx_fbs = std.io.fixedBufferStream(assets.sfx.sword1);
|
||||||
|
|
||||||
var sound_stream = std.io.StreamSource{ .const_buffer = bgm_fbs };
|
var sound_stream = std.io.StreamSource{ .const_buffer = bgm_fbs };
|
||||||
const bgm = try Opus.decodeStream(gpa.allocator(), sound_stream);
|
const bgm = try mach.Audio.Opus.decodeStream(gpa.allocator(), sound_stream);
|
||||||
|
|
||||||
sound_stream = std.io.StreamSource{ .const_buffer = sfx_fbs };
|
sound_stream = std.io.StreamSource{ .const_buffer = sfx_fbs };
|
||||||
const sfx = try Opus.decodeStream(gpa.allocator(), sound_stream);
|
const sfx = try mach.Audio.Opus.decodeStream(gpa.allocator(), sound_stream);
|
||||||
|
|
||||||
// Initialize module state
|
// Initialize module state
|
||||||
app.init(.{ .sfx = sfx });
|
app.init(.{ .sfx = sfx });
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ const builtin = @import("builtin");
|
||||||
const mach = @import("main.zig");
|
const mach = @import("main.zig");
|
||||||
const sysaudio = mach.sysaudio;
|
const sysaudio = mach.sysaudio;
|
||||||
|
|
||||||
|
pub const Opus = @import("mach-opus");
|
||||||
|
|
||||||
pub const name = .mach_audio;
|
pub const name = .mach_audio;
|
||||||
pub const Mod = mach.Mod(@This());
|
pub const Mod = mach.Mod(@This());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue