Allows resizing of windows (#8)

This commit is contained in:
bilsen 2021-07-02 01:09:46 +02:00 committed by Carter Anderson
parent 5d0655f84c
commit e1e4055a51

View File

@ -117,19 +117,22 @@ pub fn prepare_windows(
.entry(window.id) .entry(window.id)
.or_insert_with(|| render_device.create_swap_chain(surface, &swap_chain_descriptor)); .or_insert_with(|| render_device.create_swap_chain(surface, &swap_chain_descriptor));
let frame = if let Ok(swap_chain_frame) = swap_chain.get_current_frame() { let frame = match swap_chain.get_current_frame() {
Ok(swap_chain_frame) => {
swap_chain_frame swap_chain_frame
} else { },
let swap_chain = window_surfaces Err(wgpu::SwapChainError::Outdated) => {
.swap_chains let new_swap_chain = render_device.create_swap_chain(surface, &swap_chain_descriptor);
.entry(window.id) let frame = new_swap_chain.get_current_frame().expect("Error recreating swap chain");
.or_insert_with(|| { window_surfaces.swap_chains.insert(
render_device.create_swap_chain(surface, &swap_chain_descriptor) window.id,
}); new_swap_chain
);
swap_chain frame
.get_current_frame() },
.expect("Failed to acquire next swap chain texture!") err => {
err.expect("Failed to acquire next swap chain texture!")
}
}; };
window.swap_chain_frame = Some(TextureView::from(frame)); window.swap_chain_frame = Some(TextureView::from(frame));