module: object recycling

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-09-30 01:21:31 -07:00 committed by Emi Gutekanst
parent 8054d03b4d
commit 9d134dc72d
15 changed files with 396 additions and 90 deletions

View file

@ -23,7 +23,7 @@ pub fn deinit(app: *App) void {
pub fn init(
app: *App,
core: *mach.Core,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -11,7 +11,7 @@ pub fn main() !void {
const allocator = std.heap.c_allocator;
// The set of Mach modules our application may use.
var mods = Modules.init(allocator);
var mods = try Modules.init(allocator);
// On some platforms, you can drive the mach.Core main loop yourself - but this isn't possible
// on all platforms. If mach.Core.non_blocking is set to true, and the platform supports

View file

@ -19,7 +19,7 @@ pipeline: *gpu.RenderPipeline,
pub fn init(
core: *mach.Core,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -12,7 +12,7 @@ pub fn main() !void {
const allocator = std.heap.c_allocator;
// The set of Mach modules our application may use.
var mods = Modules.init(allocator);
var mods = try Modules.init(allocator);
// TODO: enable mods.deinit(allocator); for allocator leak detection
// defer mods.deinit(allocator);

View file

@ -49,7 +49,7 @@ fn init(
core: *mach.Core,
renderer: *Renderer,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -56,7 +56,7 @@ fn init(
glyphs: *Glyphs.Mod,
app: *App,
core: *mach.Core,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -80,7 +80,7 @@ fn init(
text: *gfx.Text.Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -42,7 +42,7 @@ fn init(
core: *mach.Core,
audio: *mach.Audio,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -41,7 +41,7 @@ fn init(
core: *mach.Core,
audio: *mach.Audio,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -58,7 +58,7 @@ fn init(
sprite: *gfx.Sprite.Mod,
sprite_pipeline: *gfx.SpritePipeline.Mod,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;

View file

@ -67,7 +67,7 @@ fn init(
text_pipeline: *gfx.TextPipeline.Mod,
text_style: *gfx.TextStyle.Mod,
app: *App,
app_mod: mach.Functions(App),
app_mod: mach.Mod(App),
) !void {
core.on_tick = app_mod.id.tick;
core.on_exit = app_mod.id.deinit;