From 21d88fbec5b027eca88a680f3ca80ffda04ddcb3 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 26 Jun 2021 11:20:42 +0200 Subject: [PATCH] FOV is now calculate along the height, not the width (for proper ultrawide support) --- src/camwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/camwindow.cpp b/src/camwindow.cpp index a07fbb5..61dcdf5 100644 --- a/src/camwindow.cpp +++ b/src/camwindow.cpp @@ -179,7 +179,7 @@ struct camera_t { color(0, 0, 0), movementflags(0), m_keymove_handler(0), - fieldOfView(100.0f), + fieldOfView(90.0f), m_mouseMove(motionDelta, this), m_view(view), m_update(update) @@ -192,13 +192,13 @@ camera_draw_mode camera_t::draw_mode = cd_texture; inline Matrix4 projection_for_camera(float near_z, float far_z, float fieldOfView, int width, int height) { const float half_width = static_cast( near_z * tan(degrees_to_radians(fieldOfView * 0.5))); - const float half_height = half_width * (static_cast( height ) / static_cast( width )); + const float half_height = half_width * (static_cast( width ) / static_cast( height )); return matrix4_frustum( - -half_width, - half_width, -half_height, half_height, + -half_width, + half_width, near_z, far_z );