SpritePipeline: make .init and .deinit explicit
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
3504dfcab6
commit
ed9137fe98
4 changed files with 22 additions and 10 deletions
|
|
@ -34,6 +34,7 @@ pub const Mod = mach.Mod(@This());
|
|||
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
|
|
@ -42,9 +43,16 @@ pub const local_events = .{
|
|||
.end_frame = .{ .handler = endFrame },
|
||||
};
|
||||
|
||||
fn init(glyphs: *Glyphs.Mod, game: *Mod) !void {
|
||||
// Prepare which glyphs we will render
|
||||
fn deinit(sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod) !void {
|
||||
sprite_pipeline.send(.deinit, .{});
|
||||
glyphs.send(.deinit, .{});
|
||||
}
|
||||
|
||||
fn init(sprite_pipeline: *gfx.SpritePipeline.Mod, glyphs: *Glyphs.Mod, game: *Mod) !void {
|
||||
sprite_pipeline.send(.init, .{});
|
||||
glyphs.send(.init, .{});
|
||||
|
||||
// Prepare which glyphs we will render
|
||||
glyphs.send(.prepare, .{&[_]u21{ '?', '!', 'a', 'b', '#', '@', '%', '$', '&', '^', '*', '+', '=', '<', '>', '/', ':', ';', 'Q', '~' }});
|
||||
|
||||
// Run our init code after glyphs module is initialized.
|
||||
|
|
|
|||
|
|
@ -8,12 +8,9 @@ const assets = @import("assets");
|
|||
pub const name = .glyphs;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub const global_events = .{
|
||||
.deinit = .{ .handler = deinit },
|
||||
};
|
||||
|
||||
pub const local_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.prepare = .{ .handler = prepare },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ pub const Mod = mach.Mod(@This());
|
|||
|
||||
pub const global_events = .{
|
||||
.init = .{ .handler = init },
|
||||
.deinit = .{ .handler = deinit },
|
||||
.tick = .{ .handler = tick },
|
||||
};
|
||||
|
||||
|
|
@ -45,12 +46,20 @@ pub const local_events = .{
|
|||
.end_frame = .{ .handler = endFrame },
|
||||
};
|
||||
|
||||
fn deinit(
|
||||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
) !void {
|
||||
sprite_pipeline.send(.init, .{});
|
||||
}
|
||||
|
||||
fn init(
|
||||
core: *mach.Core.Mod,
|
||||
sprite: *gfx.Sprite.Mod,
|
||||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
game: *Mod,
|
||||
) !void {
|
||||
sprite_pipeline.send(.init, .{});
|
||||
|
||||
// We can create entities, and set components on them. Note that components live in a module
|
||||
// namespace, e.g. the `.mach_gfx_sprite` module could have a 3D `.location` component with a different
|
||||
// type than the `.physics2d` module's `.location` component if you desire.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue