diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 92677209..b4dd3ae0 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -215,8 +215,13 @@ const float camera_t::near_z = 1.f; 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 ) ); + float half_width = static_cast( near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ) ); + const bool swap = height > width; + if( swap ) + std::swap( width, height ); + float half_height = half_width * ( static_cast( height ) / static_cast( width ) ); + if( swap ) + std::swap( half_width, half_height ); return matrix4_frustum( -half_width,