module: event handlers are defined ahead of time
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
0fc3bf6545
commit
3bfafe102d
12 changed files with 1099 additions and 967 deletions
|
|
@ -20,6 +20,11 @@ pub const components = struct {
|
|||
pub const follower = void;
|
||||
};
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
};
|
||||
|
||||
// Each module must have a globally unique name declared, it is impossible to use two modules with
|
||||
// the same name in a program. To avoid name conflicts, we follow naming conventions:
|
||||
//
|
||||
|
|
@ -33,7 +38,8 @@ pub const components = struct {
|
|||
pub const name = .game;
|
||||
pub const Mod = mach.Mod(@This());
|
||||
|
||||
pub fn init(
|
||||
// TODO(engine): remove need for returning an error here
|
||||
fn init(
|
||||
engine: *mach.Engine.Mod,
|
||||
renderer: *Renderer.Mod,
|
||||
game: *Mod,
|
||||
|
|
@ -56,7 +62,8 @@ pub fn init(
|
|||
};
|
||||
}
|
||||
|
||||
pub fn tick(
|
||||
// TODO(engine): remove need for returning an error here
|
||||
fn tick(
|
||||
engine: *mach.Engine.Mod,
|
||||
renderer: *Renderer.Mod,
|
||||
game: *Mod,
|
||||
|
|
|
|||
|
|
@ -26,13 +26,19 @@ pub const components = struct {
|
|||
pub const scale = f32;
|
||||
};
|
||||
|
||||
pub const events = .{
|
||||
.{ .global = .init, .handler = init },
|
||||
.{ .global = .deinit, .handler = deinit },
|
||||
.{ .global = .tick, .handler = tick },
|
||||
};
|
||||
|
||||
// TODO: this shouldn't be a packed struct, it should be extern.
|
||||
const UniformBufferObject = packed struct {
|
||||
offset: Vec3.Vector,
|
||||
scale: f32,
|
||||
};
|
||||
|
||||
pub fn init(
|
||||
fn init(
|
||||
engine: *mach.Engine.Mod,
|
||||
renderer: *Mod,
|
||||
) !void {
|
||||
|
|
@ -97,7 +103,7 @@ pub fn init(
|
|||
shader_module.release();
|
||||
}
|
||||
|
||||
pub fn deinit(
|
||||
fn deinit(
|
||||
renderer: *Mod,
|
||||
) !void {
|
||||
renderer.state.pipeline.release();
|
||||
|
|
@ -106,7 +112,7 @@ pub fn deinit(
|
|||
renderer.state.uniform_buffer.release();
|
||||
}
|
||||
|
||||
pub fn tick(
|
||||
fn tick(
|
||||
engine: *mach.Engine.Mod,
|
||||
renderer: *Mod,
|
||||
) !void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue