Clone the context instead of repeating the same code

This commit is contained in:
reo 2025-09-05 16:07:48 +03:00
parent b3b69756e6
commit 1a200e62ef
2 changed files with 13 additions and 8 deletions

View file

@ -65,7 +65,7 @@ impl Platform for GliumPlatform {
frame_width: w as f32,
frame_height: h as f32,
};
self.engine.initialize(ctx);
self.engine.initialize(ctx.clone());
let _ = &self.event_loop.run(move |event, el| {
match event {
Event::WindowEvent { event, .. } => match event {
@ -91,13 +91,9 @@ impl Platform for GliumPlatform {
_ => {},
},
Event::AboutToWait => {
let ctx = PlatformContext {
current_event: event.clone(),
asset_manager: self.asset_manager.clone(),
frame_width: w as f32,
frame_height: h as f32,
};
self.engine.update(ctx);
let mut ctx2 = ctx.clone();
ctx2.current_event = event.clone();
self.engine.update(ctx2);
self.window.request_redraw();
}
_ => {},