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:
parent
5e8897c271
commit
84ab3a26b1
9 changed files with 221 additions and 11 deletions
|
|
@ -44,7 +44,7 @@ impl EngineTrait for Engine {
|
|||
}
|
||||
|
||||
/// Update the engine
|
||||
fn update(&mut self, platform_context: PlatformContext) {
|
||||
fn frame_update(&mut self, platform_context: PlatformContext) {
|
||||
self.debug_ui_buffer.borrow_mut().reset_buffer();
|
||||
let mut ctx = SystemContext {
|
||||
scene: self.scene_manager.current_mut(),
|
||||
|
|
@ -53,7 +53,19 @@ impl EngineTrait for Engine {
|
|||
};
|
||||
|
||||
for system in self.system_manager.systems.values_mut() {
|
||||
system.update(&mut ctx);
|
||||
system.frame_update(&mut ctx);
|
||||
}
|
||||
}
|
||||
|
||||
fn fixed_update(&mut self, platform_context: PlatformContext) {
|
||||
let mut ctx = SystemContext {
|
||||
scene: self.scene_manager.current_mut(),
|
||||
platform_context,
|
||||
debug_ui_buffer: self.debug_ui_buffer.clone(),
|
||||
};
|
||||
|
||||
for system in self.system_manager.systems.values_mut() {
|
||||
system.fixed_update(&mut ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ pub trait System {
|
|||
/// Spawn the first entities of the world.
|
||||
fn load_world(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn handle_event(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn update(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn fixed_update(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn frame_update(&mut self, _ctx: &mut SystemContext) {}
|
||||
}
|
||||
|
||||
pub struct SystemManager {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue