From ba41bb4c61694614d19cab35d81b3c71cbe0823d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 5 Apr 2021 10:34:03 +0200 Subject: [PATCH] - fixed the viewport setup. There were two problems here - the math for calculating the rect was wrong and the initial aspect ratio was also not correct. --- source/core/gamecontrol.cpp | 18 ++++++++++++------ source/core/rendering/hw_entrypoint.cpp | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 5adcd8da3..29c214841 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -225,15 +225,21 @@ static bool System_DisableTextureFilter() static IntRect System_GetSceneRect() { - // Special handling so the view with a visible status bar displays properly - int height = windowxy2.y - windowxy1.y + 1, width = windowxy2.x - windowxy1.x + 1; - int bottomspace = screen->GetHeight() - windowxy2.y; + int viewbottom = windowxy2.y + 1; + int viewheight = viewbottom - windowxy1.y; + int viewright = windowxy2.x + 1; + int viewwidth = viewright - windowxy1.x; + + int renderheight; + + if (viewheight == screen->GetHeight()) renderheight = viewheight; + else renderheight = (viewwidth * screen->GetHeight() / screen->GetWidth()) & ~7; IntRect mSceneViewport; mSceneViewport.left = windowxy1.x; - mSceneViewport.top = (bottomspace - windowxy1.y/2); - mSceneViewport.width = width; - mSceneViewport.height = height; + mSceneViewport.top = screen->GetHeight() - (renderheight + windowxy1.y - ((renderheight - viewheight) / 2)); + mSceneViewport.width = viewwidth; + mSceneViewport.height = renderheight; return mSceneViewport; } diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index 18269e365..f5f97adb8 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -309,7 +309,7 @@ void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sect // now render the main view float fovratio; - float ratio = ActiveRatio(windowxy2.x - windowxy1.x + 1, windowxy2.y - windowxy1.y + 1); + float ratio = ActiveRatio(screen->GetWidth(), screen->GetHeight()); if (ratio >= 1.33f) { fovratio = 1.33f;