Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unwrap crash when render surface is unavailable (0 height etc) #117

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix unwrap crash when render surface is unavailable (0 height etc)
  • Loading branch information
Keshi committed Oct 8, 2023
commit 80b592b52951fba773c7929544c039c7dbc26d56
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
Loading