updated sound engine and fixed rendering on macos
This commit is contained in:
parent
4b259648a1
commit
5ecd94d92f
|
|
@ -26,7 +26,8 @@ pub fn start_module(comptime programSpec: anytype, args: anytype, allocator: std
|
||||||
gSoundLoader.* = soundEngine.SoundLoader.init(gSoundEngine);
|
gSoundLoader.* = soundEngine.SoundLoader.init(gSoundEngine);
|
||||||
|
|
||||||
assets.gAssetSys.registerLoader(gSoundLoader) catch unreachable;
|
assets.gAssetSys.registerLoader(gSoundLoader) catch unreachable;
|
||||||
gSoundEngine.loadSound(core.MakeName("s_test"), "content/sounds/engineTick.wav", .{}) catch unreachable;
|
var name = core.MakeName("s_test");
|
||||||
|
gSoundEngine.loadSound(&name, "content/sounds/engineTick.wav", .{}) catch unreachable;
|
||||||
|
|
||||||
core.engine_logs("sound start_module");
|
core.engine_logs("sound start_module");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ pub fn sound_errs(comptime fmt: []const u8) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const SoundLoader = struct {
|
pub const SoundLoader = struct {
|
||||||
pub var LoaderInterfaceVTable: assets.AssetLoaderInterface = assets.AssetLoaderInterface.from(core.MakeName("Sound"), @This());
|
pub var LoaderInterfaceVTable: assets.AssetLoaderInterface = assets.AssetLoaderInterface.from("Sound", @This());
|
||||||
|
|
||||||
engine: *NeonSoundEngine,
|
engine: *NeonSoundEngine,
|
||||||
|
|
||||||
|
|
@ -42,16 +42,18 @@ pub const SoundLoader = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy(self: *@This(), allocator: std.mem.Allocator) void {
|
pub fn destroy(self: *@This(), allocator: std.mem.Allocator) void {
|
||||||
|
self.engine.deinit();
|
||||||
allocator.destroy(self);
|
allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unfortunately this one is blocking
|
// unfortunately this one is blocking
|
||||||
pub fn loadAsset(self: *@This(), assetRef: assets.AssetRef, properties: ?assets.AssetPropertiesBag) assets.AssetLoaderError!void {
|
pub fn loadAsset(self: *@This(), assetRef: assets.AssetRef, properties: ?assets.AssetPropertiesBag) assets.AssetLoaderError!void {
|
||||||
core.engine_log("loading sound asset {s}", .{properties.?.path});
|
core.engine_log("loading sound asset {s}", .{properties.?.path});
|
||||||
self.engine.loadSound(assetRef.name, properties.?.path, .{
|
var name = assetRef.name;
|
||||||
|
self.engine.loadSound(&name, properties.?.path, .{
|
||||||
.volume = properties.?.soundVolume,
|
.volume = properties.?.soundVolume,
|
||||||
}) catch {
|
}) catch {
|
||||||
core.engine_log("unable to load sound {s}", .{assetRef.name.utf8()});
|
core.engine_log("unable to load sound {s}", .{name.utf8()});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -85,12 +87,12 @@ pub const NeonSoundEngine = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shutdown(self: *@This()) void {
|
pub fn shutdown(self: *@This()) void {
|
||||||
ma.ma_engine_uninit(self.engine);
|
_ = self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn loadSound(
|
pub fn loadSound(
|
||||||
self: *@This(),
|
self: *@This(),
|
||||||
soundName: core.Name,
|
soundName: *core.Name,
|
||||||
fileName: []const u8,
|
fileName: []const u8,
|
||||||
soundParams: struct {
|
soundParams: struct {
|
||||||
looping: bool = false,
|
looping: bool = false,
|
||||||
|
|
@ -141,7 +143,7 @@ pub const NeonSoundEngine = struct {
|
||||||
self.allocator.destroy(sound.value_ptr.*);
|
self.allocator.destroy(sound.value_ptr.*);
|
||||||
}
|
}
|
||||||
self.sounds.deinit(self.allocator);
|
self.sounds.deinit(self.allocator);
|
||||||
// ma.ma_engine_uninit(self.engine);
|
ma.ma_engine_uninit(self.engine);
|
||||||
self.allocator.destroy(self.engine);
|
self.allocator.destroy(self.engine);
|
||||||
self.allocator.destroy(self);
|
self.allocator.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -788,7 +788,7 @@ pub const Renderer = struct {
|
||||||
pub fn drawPostProcess(self: *@This(), cmd: *gpu.GPUCommandBuffer) void {
|
pub fn drawPostProcess(self: *@This(), cmd: *gpu.GPUCommandBuffer) void {
|
||||||
const postProcTargetInfo: gpu.GPUColorTargetInfo = std.mem.zeroInit(gpu.GPUColorTargetInfo, .{
|
const postProcTargetInfo: gpu.GPUColorTargetInfo = std.mem.zeroInit(gpu.GPUColorTargetInfo, .{
|
||||||
.texture = self.state.swapchainTargetTexture.?,
|
.texture = self.state.swapchainTargetTexture.?,
|
||||||
.load_op = .loadopDontCare,
|
.load_op = .loadopClear,
|
||||||
.store_op = .storeopStore,
|
.store_op = .storeopStore,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -799,6 +799,10 @@ pub const Renderer = struct {
|
||||||
.{ .sampler = self.blockySampler, .texture = self.state.targetTexture },
|
.{ .sampler = self.blockySampler, .texture = self.state.targetTexture },
|
||||||
.{ .sampler = self.linearSampler, .texture = self.state.emissiveTarget },
|
.{ .sampler = self.linearSampler, .texture = self.state.emissiveTarget },
|
||||||
}, 2);
|
}, 2);
|
||||||
|
|
||||||
|
postProcPass.bindGPUVertexBuffers(0, &.{ .buffer = self.meshPool.vertexBuffer, .offset = 0 }, 1);
|
||||||
|
postProcPass.bindGPUIndexBuffer(&.{ .buffer = self.meshPool.indexBuffer, .offset = 0 }, .indexelementsize32bit);
|
||||||
|
|
||||||
// postProcPass.bindGPUFragmentSamplers(1, &.{ .sampler = self.blockySampler, .texture = self.state.emissiveTarget }, 1);
|
// postProcPass.bindGPUFragmentSamplers(1, &.{ .sampler = self.blockySampler, .texture = self.state.emissiveTarget }, 1);
|
||||||
|
|
||||||
// post processing + hdr etc...
|
// post processing + hdr etc...
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
|
|
||||||
moveInput: *core.Axis2dBinding = undefined,
|
moveInput: *core.Axis2dBinding = undefined,
|
||||||
|
|
||||||
cameraSpeed: f32 = 10.0,
|
cameraSpeed: f32 = 10.0,
|
||||||
|
|
@ -365,6 +364,7 @@ pub fn main() anyerror!void {
|
||||||
.enabledModules = .{
|
.enabledModules = .{
|
||||||
.imgui = true,
|
.imgui = true,
|
||||||
.physics = true,
|
.physics = true,
|
||||||
|
.audio = true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue