Timing Module Update

- Implement a new timing module
- Utilize the new timing module in glium platform implementation for frame limiting and fixed engine updates timing.
This commit is contained in:
reo 2025-09-24 23:20:51 +03:00
parent 5e8897c271
commit 84ab3a26b1
9 changed files with 221 additions and 11 deletions

View file

@ -1,3 +1,4 @@
use std::fmt::format;
use glam::{Quat, Vec3};
use raidillon_engine::{Engine, system::System};
use raidillon_engine::system::SystemContext;
@ -34,8 +35,8 @@ impl System for UpdateAspectRatioSystem {
#[derive(Default)]
struct RenderingTestSystem;
impl System for RenderingTestSystem {
fn initialize(&mut self) {}
fn load_world(&mut self, ctx: &mut SystemContext) {
ctx.scene.world.spawn((Camera {
eye: Vec3::new(0.0, 0.0, 2.0),
@ -61,9 +62,19 @@ impl System for RenderingTestSystem {
));
}
fn update(&mut self, ctx: &mut SystemContext) {
ctx.debug_ui_buffer.borrow_mut().text("Hello World!".to_owned());
fn frame_update(&mut self, ctx: &mut SystemContext) {
let mut dbg_ui = ctx.debug_ui_buffer.borrow_mut();
dbg_ui.text("Hello World!".to_owned());
dbg_ui.text(format!("Frame Delta: {}", ctx.platform_context.time_ctx.frame_dt));
dbg_ui.text(format!("Fixed Delta: {}", ctx.platform_context.time_ctx.fixed_dt));
}
fn fixed_update(&mut self, ctx: &mut SystemContext) {
ctx.scene.world.query_mut::<(&mut Transform, &ModelHandle)>().into_iter().for_each(|(_, (t, _))| {
t.rotation *= Quat::from_rotation_y(10.0 * ctx.platform_context.time_ctx.fixed_dt);
});
}
}
fn main() {