Remove remaining std::mem::replace usages in examples (#1006)

This commit is contained in:
Lucas Kent 2018-08-04 22:38:57 +10:00 committed by Pierre Krieger
parent b0832072fc
commit 257994c7e8
3 changed files with 8 additions and 13 deletions

View File

@ -171,8 +171,8 @@ fn main() {
Err(err) => panic!("{:?}", err)
};
std::mem::replace(&mut swapchain, new_swapchain);
std::mem::replace(&mut images, new_images);
swapchain = new_swapchain;
images = new_images;
framebuffers = None;
@ -186,12 +186,11 @@ fn main() {
}
if framebuffers.is_none() {
let new_framebuffers = Some(images.iter().map(|image| {
framebuffers = Some(images.iter().map(|image| {
Arc::new(vulkano::framebuffer::Framebuffer::start(renderpass.clone())
.add(image.clone()).unwrap()
.build().unwrap())
}).collect::<Vec<_>>());
std::mem::replace(&mut framebuffers, new_framebuffers);
}
let (image_num, future) = match vulkano::swapchain::acquire_next_image(swapchain.clone(),

View File

@ -168,8 +168,7 @@ fn main() {
swapchain = new_swapchain;
images = new_images;
let new_depth_buffer = vulkano::image::attachment::AttachmentImage::transient(device.clone(), dimensions, vulkano::format::D16Unorm).unwrap();
std::mem::replace(&mut depth_buffer, new_depth_buffer);
depth_buffer = vulkano::image::attachment::AttachmentImage::transient(device.clone(), dimensions, vulkano::format::D16Unorm).unwrap();
framebuffers = None;
@ -185,13 +184,12 @@ fn main() {
}
if framebuffers.is_none() {
let new_framebuffers = Some(images.iter().map(|image| {
framebuffers = Some(images.iter().map(|image| {
Arc::new(vulkano::framebuffer::Framebuffer::start(renderpass.clone())
.add(image.clone()).unwrap()
.add(depth_buffer.clone()).unwrap()
.build().unwrap())
}).collect::<Vec<_>>());
std::mem::replace(&mut framebuffers, new_framebuffers);
}
let uniform_buffer_subbuffer = {

View File

@ -57,7 +57,6 @@ use vulkano::sync::now;
use vulkano::sync::GpuFuture;
use std::sync::Arc;
use std::mem;
fn main() {
// The first step of any vulkan program is to create an instance.
@ -364,8 +363,8 @@ void main() {
Err(err) => panic!("{:?}", err)
};
mem::replace(&mut swapchain, new_swapchain);
mem::replace(&mut images, new_images);
swapchain = new_swapchain;
images = new_images;
framebuffers = None;
@ -381,12 +380,11 @@ void main() {
// Because framebuffers contains an Arc on the old swapchain, we need to
// recreate framebuffers as well.
if framebuffers.is_none() {
let new_framebuffers = Some(images.iter().map(|image| {
framebuffers = Some(images.iter().map(|image| {
Arc::new(Framebuffer::start(render_pass.clone())
.add(image.clone()).unwrap()
.build().unwrap())
}).collect::<Vec<_>>());
mem::replace(&mut framebuffers, new_framebuffers);
}
// Before we can draw on the output, we have to *acquire* an image from the swapchain. If