mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Stop crash when minimizing
Former-commit-id: ca52ae2520bf5616d24f27d98244a470966f3573
This commit is contained in:
parent
ba8c8cfdf3
commit
c780b85f24
@ -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(())
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user