mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-16 05:06:11 +00:00
Handle window resize once per frame
This commit is contained in:
parent
085c161ed3
commit
74887df61e
@ -51,6 +51,12 @@ pub fn run(
|
|||||||
let mut camera = Camera::new(&Default::default());
|
let mut camera = Camera::new(&Default::default());
|
||||||
let mut camera_update_once = watcher.is_some();
|
let mut camera_update_once = watcher.is_some();
|
||||||
|
|
||||||
|
// Only handle resize events once every frame. This filters out spurious
|
||||||
|
// resize events that can lead to wgpu warnings. See this issue for some
|
||||||
|
// context:
|
||||||
|
// https://github.com/rust-windowing/winit/issues/2094
|
||||||
|
let mut new_size = None;
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
trace!("Handling event: {:?}", event);
|
trace!("Handling event: {:?}", event);
|
||||||
|
|
||||||
@ -147,11 +153,10 @@ pub fn run(
|
|||||||
event: WindowEvent::Resized(size),
|
event: WindowEvent::Resized(size),
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let size = Size {
|
new_size = Some(Size {
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
};
|
});
|
||||||
renderer.handle_resize(size);
|
|
||||||
}
|
}
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::MouseInput { state, button, .. },
|
event: WindowEvent::MouseInput { state, button, .. },
|
||||||
@ -169,6 +174,9 @@ pub fn run(
|
|||||||
if let Some(shape) = &shape {
|
if let Some(shape) = &shape {
|
||||||
camera.update_planes(&shape.aabb);
|
camera.update_planes(&shape.aabb);
|
||||||
}
|
}
|
||||||
|
if let Some(size) = new_size.take() {
|
||||||
|
renderer.handle_resize(size);
|
||||||
|
}
|
||||||
|
|
||||||
let egui_input =
|
let egui_input =
|
||||||
egui_winit_state.take_egui_input(window.window());
|
egui_winit_state.take_egui_input(window.window());
|
||||||
|
Loading…
Reference in New Issue
Block a user