2025-05-12 00:21:52 +01:00
|
|
|
const ona = @import("ona");
|
|
|
|
|
|
|
|
const std = @import("std");
|
|
|
|
|
2025-08-12 23:40:21 +01:00
|
|
|
const CRT = extern struct {
|
|
|
|
width: f32,
|
|
|
|
height: f32,
|
|
|
|
time: f32,
|
|
|
|
padding: [4]u8 = undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
const Effects = struct {
|
|
|
|
render_texture: ona.AssetHandle = .default,
|
|
|
|
image_textures: [2]ona.AssetHandle = [_]ona.AssetHandle{.default} ** 2,
|
|
|
|
last_time: f64 = 0,
|
|
|
|
image_index: usize = 0,
|
|
|
|
crt_effect: ona.AssetHandle = .default,
|
|
|
|
};
|
|
|
|
|
2025-05-12 00:21:52 +01:00
|
|
|
pub fn main() void {
|
|
|
|
ona.realtime_app
|
2025-08-05 18:07:09 +01:00
|
|
|
.with(.initModule(ona.hid))
|
2025-05-12 00:21:52 +01:00
|
|
|
.with(.initModule(ona.gfx))
|
2025-08-12 23:40:21 +01:00
|
|
|
// .with(.initSystem(.render, .of(render)))
|
2025-05-12 00:21:52 +01:00
|
|
|
.run();
|
|
|
|
}
|
2025-08-08 13:52:45 +01:00
|
|
|
|
2025-08-12 23:40:21 +01:00
|
|
|
// fn update(effects: ona.Write(Effects), loop: ona.Read(ona.Loop)) void {
|
|
|
|
// const update_seconds = 5;
|
|
|
|
|
|
|
|
// if ((loop.state.elapsed_time - effects.state.last_time) > update_seconds) {
|
|
|
|
// effects.state.image_index = (effects.state.image_index + 1) % effects.state.image_textures.len;
|
|
|
|
// effects.state.last_time = loop.state.elapsed_time;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fn render(commands: ona.gfx.Commands) void {
|
|
|
|
// try commands.setTarget(.{
|
|
|
|
// .texture = effects.state.render_texture,
|
|
|
|
// .clear_color = gfx.colors.black,
|
|
|
|
// .clear_depth = 0,
|
|
|
|
// .clear_stencil = 0,
|
|
|
|
// });
|
|
|
|
|
|
|
|
// const width: f32 = @floatFromInt(display.state.width);
|
|
|
|
// const height: f32 = @floatFromInt(display.state.height);
|
|
|
|
|
|
|
|
// try commands.draw_texture(.{
|
|
|
|
// .texture = effects.state.image_textures[effects.state.image_index],
|
|
|
|
// .size = .{ width, height },
|
|
|
|
// });
|
|
|
|
|
|
|
|
// try commands.set_effect(.{
|
|
|
|
// .effect = effects.state.crt_effect,
|
|
|
|
|
|
|
|
// .properties = std.mem.asBytes(&CRT{
|
|
|
|
// .width = width,
|
|
|
|
// .height = height,
|
|
|
|
// .time = @floatCast(loop.state.elapsed_time),
|
|
|
|
// }),
|
|
|
|
// });
|
|
|
|
|
|
|
|
// try commands.set_target(.{
|
|
|
|
// .clear_color = null,
|
|
|
|
// .clear_depth = null,
|
|
|
|
// .clear_stencil = null,
|
|
|
|
// });
|
|
|
|
|
|
|
|
// try commands.draw_texture(.{
|
|
|
|
// .texture = effects.state.render_texture,
|
|
|
|
// .size = .{ width, height },
|
|
|
|
// });
|
|
|
|
// }
|