Stop crash when minimizing

Former-commit-id: ca52ae2520bf5616d24f27d98244a470966f3573
This commit is contained in:
Imbris 2019-05-17 01:13:14 -04:00
parent ba8c8cfdf3
commit c780b85f24
2 changed files with 9 additions and 6 deletions

View File

@ -190,11 +190,14 @@ impl Renderer {
pub fn on_resize(&mut self) -> Result<(), RenderError> {
let dims = self.win_color_view.get_dimensions();
let (tgt_color_view, tgt_depth_view, tgt_color_res) =
Self::create_rt_views(&mut self.factory, (dims.0, dims.1))?;
self.tgt_color_res = tgt_color_res;
self.tgt_color_view = tgt_color_view;
self.tgt_depth_view = tgt_depth_view;
// Panics when creating texture with w,h of 0,0
if dims.0 != 0 && dims.1 != 0 {
let (tgt_color_view, tgt_depth_view, tgt_color_res) =
Self::create_rt_views(&mut self.factory, (dims.0, dims.1))?;
self.tgt_color_res = tgt_color_res;
self.tgt_color_view = tgt_color_view;
self.tgt_depth_view = tgt_depth_view;
}
Ok(())
}

View File

@ -143,7 +143,7 @@ impl Camera {
}
/// Set the aspect ratio of the camera.
pub fn set_aspect_ratio(&mut self, aspect: f32) {
self.aspect = aspect;
self.aspect = if aspect.is_normal() { aspect } else { 1.0 };
}
/// Get the orientation of the camera