- 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.
This commit is contained in:
Christoph Oelckers 2021-04-05 10:34:03 +02:00
parent 8055ff1d86
commit ba41bb4c61
2 changed files with 13 additions and 7 deletions

View file

@ -225,15 +225,21 @@ static bool System_DisableTextureFilter()
static IntRect System_GetSceneRect() static IntRect System_GetSceneRect()
{ {
// Special handling so the view with a visible status bar displays properly int viewbottom = windowxy2.y + 1;
int height = windowxy2.y - windowxy1.y + 1, width = windowxy2.x - windowxy1.x + 1; int viewheight = viewbottom - windowxy1.y;
int bottomspace = screen->GetHeight() - windowxy2.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; IntRect mSceneViewport;
mSceneViewport.left = windowxy1.x; mSceneViewport.left = windowxy1.x;
mSceneViewport.top = (bottomspace - windowxy1.y/2); mSceneViewport.top = screen->GetHeight() - (renderheight + windowxy1.y - ((renderheight - viewheight) / 2));
mSceneViewport.width = width; mSceneViewport.width = viewwidth;
mSceneViewport.height = height; mSceneViewport.height = renderheight;
return mSceneViewport; return mSceneViewport;
} }

View file

@ -309,7 +309,7 @@ void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sect
// now render the main view // now render the main view
float fovratio; 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) if (ratio >= 1.33f)
{ {
fovratio = 1.33f; fovratio = 1.33f;