* Make sure aspect ratio is always valid * Do not render while window has an invalid size (e.g. window is minimized)
This commit is contained in:
parent
0dd21a0a20
commit
b26500e1b2
|
@ -352,6 +352,11 @@ fn main2() {
|
||||||
game.tick(delta);
|
game.tick(delta);
|
||||||
game.server.tick(&mut game.renderer, delta);
|
game.server.tick(&mut game.renderer, delta);
|
||||||
|
|
||||||
|
// Check if window is valid, it might be minimized
|
||||||
|
if physical_width == 0 || physical_height == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
game.renderer.update_camera(physical_width, physical_height);
|
game.renderer.update_camera(physical_width, physical_height);
|
||||||
game.server.world.compute_render_list(&mut game.renderer);
|
game.server.world.compute_render_list(&mut game.renderer);
|
||||||
game.chunk_builder.tick(&mut game.server.world, &mut game.renderer, version);
|
game.chunk_builder.tick(&mut game.server.world, &mut game.renderer, version);
|
||||||
|
@ -364,7 +369,6 @@ fn main2() {
|
||||||
ui_container.tick(&mut game.renderer, delta, width as f64, height as f64);
|
ui_container.tick(&mut game.renderer, delta, width as f64, height as f64);
|
||||||
game.renderer.tick(&mut game.server.world, delta, width, height, physical_width, physical_height);
|
game.renderer.tick(&mut game.server.world, delta, width, height, physical_width, physical_height);
|
||||||
|
|
||||||
|
|
||||||
if fps_cap > 0 && !vsync {
|
if fps_cap > 0 && !vsync {
|
||||||
let frame_time = now.elapsed();
|
let frame_time = now.elapsed();
|
||||||
let sleep_interval = Duration::from_millis(1000 / fps_cap as u64);
|
let sleep_interval = Duration::from_millis(1000 / fps_cap as u64);
|
||||||
|
|
|
@ -259,10 +259,13 @@ impl Renderer {
|
||||||
self.height = height;
|
self.height = height;
|
||||||
gl::viewport(0, 0, width as i32, height as i32);
|
gl::viewport(0, 0, width as i32, height as i32);
|
||||||
|
|
||||||
|
let fovy = cgmath::Rad::from(cgmath::Deg(90.0_f32));
|
||||||
|
let aspect = (width as f32 / height as f32).max(1.0);
|
||||||
|
|
||||||
self.perspective_matrix = cgmath::Matrix4::from(
|
self.perspective_matrix = cgmath::Matrix4::from(
|
||||||
cgmath::PerspectiveFov {
|
cgmath::PerspectiveFov {
|
||||||
fovy: cgmath::Rad::from(cgmath::Deg(90f32)),
|
fovy,
|
||||||
aspect: (width as f32 / height as f32),
|
aspect,
|
||||||
near: 0.1f32,
|
near: 0.1f32,
|
||||||
far: 500.0f32,
|
far: 500.0f32,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue