From 3f62333d666b337cd863e33a9eb8a1bbeb888a38 Mon Sep 17 00:00:00 2001 From: Till Date: Mon, 29 Jul 2019 11:38:43 +0200 Subject: [PATCH] window size stretching fix --- src/main.rs | 2 +- src/vulkan.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0c8fb6f..9a98428 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,7 +92,7 @@ fn main() { let line_count = 30; vulkan::init( - vec!["models/box.obj", "models/iski51.obj"], + vec!["models/box.obj"], (-line_count..=line_count) .flat_map(|it| vec![ LinePoint { position: [it as f32, -line_count as f32, 0.] }, diff --git a/src/vulkan.rs b/src/vulkan.rs index 9952d73..34e8886 100644 --- a/src/vulkan.rs +++ b/src/vulkan.rs @@ -277,14 +277,14 @@ pub fn init(mesh_paths: Vec<&str>, line_vertices: Vec, game: &mut dyn previous_frame_end.cleanup_finished(); 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(); [dimensions.0, dimensions.1] } else { 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, // 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. @@ -296,7 +296,6 @@ pub fn init(mesh_paths: Vec<&str>, line_vertices: Vec, game: &mut dyn // Because framebuffers contains an Arc on the old swapchain, we need to // recreate framebuffers as well. framebuffers = window_size_dependent_setup(device.clone(), &new_images, render_pass.clone(), &mut dynamic_state); - data.dimensions = images[0].dimensions(); recreate_swapchain = false; }