99 lines
2.1 KiB
Markdown
99 lines
2.1 KiB
Markdown
**Includes**
|
|
- Plugins
|
|
- Scheduler
|
|
- Resources
|
|
- Events
|
|
- ECS (Archetype)
|
|
|
|
**Plugin**
|
|
``` zig
|
|
pub const plugin: App.plugin.Plugin = .{
|
|
.name = "Renderer",
|
|
.description = "Vulkan Renderer",
|
|
.build = build,
|
|
};
|
|
```
|
|
|
|
**System**
|
|
``` zig
|
|
pub fn render(ctx: App.scheduler.Context) !void {
|
|
// --- GET RESOURCES ---
|
|
const res = try ctx.app.resources.getMany(struct {
|
|
window: *Window,
|
|
device: *Device,
|
|
render_frame: ?*RenderFrame,
|
|
});
|
|
|
|
if (res.render_frame) |rf| {
|
|
_ = rf;
|
|
}
|
|
}
|
|
```
|
|
|
|
**Simple**
|
|
``` zig
|
|
test "Main" {
|
|
// --- APP ---
|
|
var app: Self = .init(std.testing.allocator);
|
|
defer app.deinit();
|
|
|
|
{ // PLUGINS
|
|
// --- ADD PLUGINS ---
|
|
try app.plugins.addMany(&.{
|
|
example.simple.plugin,
|
|
});
|
|
|
|
// --- BUILD PLUGINS ---
|
|
try app.plugins.build(.{
|
|
.app = &app,
|
|
});
|
|
}
|
|
|
|
{ // SYSTEMS
|
|
try app.schedules.runMany(&.{
|
|
example.simple.stage.Init,
|
|
example.simple.stage.Inputs,
|
|
example.simple.stage.Update,
|
|
example.simple.stage.Draw,
|
|
example.simple.stage.Deinit,
|
|
}, .{
|
|
.app = &app,
|
|
});
|
|
}
|
|
}
|
|
```
|
|
|
|
**Default App Stages**
|
|
``` zig
|
|
pub const stage = struct {
|
|
// --- INIT ---
|
|
pub const pre_init = struct {};
|
|
pub const init = struct {};
|
|
pub const post_init = struct {};
|
|
|
|
// --- DEINIT ---
|
|
pub const pre_deinit = struct {};
|
|
pub const deinit = struct {};
|
|
pub const post_deinit = struct {};
|
|
|
|
// --- INPUTS ---
|
|
pub const pre_inputs = struct {};
|
|
pub const inputs = struct {};
|
|
pub const post_inputs = struct {};
|
|
|
|
// --- FIXED UPDATE ---
|
|
pub const pre_fixed_update = struct {};
|
|
pub const fixed_update = struct {};
|
|
pub const post_fixed_update = struct {};
|
|
|
|
// --- UPDATE ---
|
|
pub const pre_update = struct {};
|
|
pub const update = struct {};
|
|
pub const post_update = struct {};
|
|
|
|
// --- DRAW ---
|
|
pub const pre_draw = struct {};
|
|
pub const draw = struct {};
|
|
pub const post_draw = struct {};
|
|
};
|
|
```
|