Fix resizing using the wrong value

This commit is contained in:
João Capucho 2021-03-21 21:09:30 +00:00 committed by Avi Weinstock
parent cbddf50a41
commit 4c51dd0147

View File

@ -928,10 +928,12 @@ impl Window {
match event { match event {
WindowEvent::CloseRequested => self.events.push(Event::Close), WindowEvent::CloseRequested => self.events.push(Event::Close),
WindowEvent::Resized(physical) => { WindowEvent::Resized(_) => {
// let (mut color_view, mut depth_view) = self.renderer.win_views_mut(); // We don't use the event provided size because since this event
// self.window.resize(physical); // more could have happened making the value wrong so we query
// self.window.update_gfx(&mut color_view, &mut depth_view); // directly from the window, this prevents some errors
let physical = self.window.inner_size();
self.renderer self.renderer
.on_resize(Vec2::new(physical.width, physical.height)) .on_resize(Vec2::new(physical.width, physical.height))
.unwrap(); .unwrap();
@ -940,9 +942,6 @@ impl Window {
let winit::dpi::PhysicalSize { width, height } = physical; let winit::dpi::PhysicalSize { width, height } = physical;
self.events self.events
.push(Event::Resize(Vec2::new(width as u32, height as u32))); .push(Event::Resize(Vec2::new(width as u32, height as u32)));
// TODO: can get invalid scissor rect
// panic with this + resize several times
// std::thread::sleep_ms(500);
}, },
WindowEvent::ScaleFactorChanged { scale_factor, .. } => { WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
// TODO: is window resized event emitted? or do we need to handle that here? // TODO: is window resized event emitted? or do we need to handle that here?