window size stretching fix

This commit is contained in:
2019-07-29 11:38:43 +02:00
parent 49285a71ce
commit 3f62333d66
2 changed files with 3 additions and 4 deletions

View File

@@ -92,7 +92,7 @@ fn main() {
let line_count = 30; let line_count = 30;
vulkan::init( vulkan::init(
vec!["models/box.obj", "models/iski51.obj"], vec!["models/box.obj"],
(-line_count..=line_count) (-line_count..=line_count)
.flat_map(|it| vec![ .flat_map(|it| vec![
LinePoint { position: [it as f32, -line_count as f32, 0.] }, LinePoint { position: [it as f32, -line_count as f32, 0.] },

View File

@@ -277,14 +277,14 @@ pub fn init(mesh_paths: Vec<&str>, line_vertices: Vec<LinePoint>, game: &mut dyn
previous_frame_end.cleanup_finished(); previous_frame_end.cleanup_finished();
if recreate_swapchain { if recreate_swapchain {
let dimensions = if let Some(dimensions) = window.get_inner_size() { data.dimensions = if let Some(dimensions) = window.get_inner_size() {
let dimensions: (u32, u32) = dimensions.to_physical(window.get_hidpi_factor()).into(); let dimensions: (u32, u32) = dimensions.to_physical(window.get_hidpi_factor()).into();
[dimensions.0, dimensions.1] [dimensions.0, dimensions.1]
} else { } else {
return; return;
}; };
let (new_swapchain, new_images) = match swapchain.recreate_with_dimension(dimensions) { let (new_swapchain, new_images) = match swapchain.recreate_with_dimension(data.dimensions) {
Ok(r) => r, Ok(r) => r,
// This error tends to happen when the user is manually resizing the window. // This error tends to happen when the user is manually resizing the window.
// Simply restarting the loop is the easiest way to fix this issue. // Simply restarting the loop is the easiest way to fix this issue.
@@ -296,7 +296,6 @@ pub fn init(mesh_paths: Vec<&str>, line_vertices: Vec<LinePoint>, game: &mut dyn
// Because framebuffers contains an Arc on the old swapchain, we need to // Because framebuffers contains an Arc on the old swapchain, we need to
// recreate framebuffers as well. // recreate framebuffers as well.
framebuffers = window_size_dependent_setup(device.clone(), &new_images, render_pass.clone(), &mut dynamic_state); framebuffers = window_size_dependent_setup(device.clone(), &new_images, render_pass.clone(), &mut dynamic_state);
data.dimensions = images[0].dimensions();
recreate_swapchain = false; recreate_swapchain = false;
} }