Skip to content

Commit

Permalink
Allows resizing of windows (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
bilsen authored Jul 1, 2021
1 parent 5de75a5 commit bbb69ea
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pipelined/bevy_render2/src/view/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,22 @@ pub fn prepare_windows(
.entry(window.id)
.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() {
swap_chain_frame
} else {
let swap_chain = window_surfaces
.swap_chains
.entry(window.id)
.or_insert_with(|| {
render_device.create_swap_chain(surface, &swap_chain_descriptor)
});

swap_chain
.get_current_frame()
.expect("Failed to acquire next swap chain texture!")
let frame = match swap_chain.get_current_frame() {
Ok(swap_chain_frame) => {
swap_chain_frame
},
Err(wgpu::SwapChainError::Outdated) => {
let new_swap_chain = render_device.create_swap_chain(surface, &swap_chain_descriptor);
let frame = new_swap_chain.get_current_frame().expect("Error recreating swap chain");
window_surfaces.swap_chains.insert(
window.id,
new_swap_chain
);
frame
},
err => {
err.expect("Failed to acquire next swap chain texture!")
}
};

window.swap_chain_frame = Some(TextureView::from(frame));
Expand Down

0 comments on commit bbb69ea

Please sign in to comment.