Create window at the end of every frame, if needed

This commit is contained in:
Hanno Braun 2025-03-28 18:52:09 +01:00
parent d9fa21ce86
commit 403068ba6c

View File

@ -59,21 +59,7 @@ struct DisplayState {
}
impl ApplicationHandler for DisplayState {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let mut entry = self.windows.first_entry();
let window = if let Some(window) = &mut entry {
window.get_mut()
} else {
let window = block_on(Window::new(event_loop)).unwrap();
self.windows
.entry(window.winit_window().id())
.or_insert(window)
};
if let Some(tri_mesh) = self.tri_mesh.take() {
window.handle_model_update(tri_mesh);
}
}
fn resumed(&mut self, _: &ActiveEventLoop) {}
fn window_event(
&mut self,
@ -154,6 +140,15 @@ impl ApplicationHandler for DisplayState {
window.winit_window().request_redraw();
}
}
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
if let Some(tri_mesh) = self.tri_mesh.take() {
let mut window = block_on(Window::new(event_loop)).unwrap();
window.handle_model_update(tri_mesh);
self.windows.insert(window.winit_window().id(), window);
}
}
}
fn input_event(event: &WindowEvent, invert_zoom: bool) -> Option<InputEvent> {