Skip to content

Commit

Permalink
fix unwrap crash when render surface is unavailable (0 height etc) (#117
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Keshi authored Oct 8, 2023
1 parent dfc60ad commit 2ef077e
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions vger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,25 +386,26 @@ impl Renderer for VgerRenderer {
}

fn finish(&mut self) {
let frame = self.surface.get_current_texture().unwrap();
let texture_view = frame
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
let desc = wgpu::RenderPassDescriptor {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
store: true,
},
})],
depth_stencil_attachment: None,
};

self.vger.encode(&desc);
frame.present();
if let Ok(frame) = self.surface.get_current_texture() {
let texture_view = frame
.texture
.create_view(&wgpu::TextureViewDescriptor::default());
let desc = wgpu::RenderPassDescriptor {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
store: true,
},
})],
depth_stencil_attachment: None,
};

self.vger.encode(&desc);
frame.present();
}
}
}

Expand Down

0 comments on commit 2ef077e

Please sign in to comment.