Fix split-screen world rendering aspect ratio

gluPerspective was hardcoded to use g_iAspectRatio (always 16:9)
instead of the aspect parameter from getFovAndAspect, which adjusts
for split-screen viewports. The 3D world was horizontally stretched
in top/bottom split because the projection used 16:9 while the
viewport was 32:9.
This commit is contained in:
MrTheShy 2026-03-06 19:46:38 +01:00
parent 4b579686e8
commit 8c3eaff0f4
2 changed files with 5 additions and 4 deletions

View file

@ -1147,7 +1147,7 @@ void GameRenderer::render(float a, bool bFirst)
if (mc->noRender) return;
GameRenderer::anaglyph3d = mc->options->anaglyph3d;
glViewport(0, 0, mc->width, mc->height); // 4J - added
glViewport(0, 0, mc->width, mc->height); // 4J - added (no-op on Win64, viewport set by StateSetViewport)
ScreenSizeCalculator ssc(mc->options, mc->width, mc->height);
int screenWidth = ssc.getWidth();
int screenHeight = ssc.getHeight();

View file

@ -48,11 +48,12 @@ void glLoadIdentity()
RenderManager.MatrixSetIdentity();
}
// AAR - Use calculated aspect ratio to support dynamic resizing
extern float g_iAspectRatio;
// AAR - Use the aspect ratio passed by the caller. For single-player this
// equals g_iAspectRatio (screen width / height), but for split-screen
// getFovAndAspect adjusts it to match the viewport dimensions.
void gluPerspective(float fovy, float aspect, float zNear, float zFar)
{
RenderManager.MatrixPerspective(fovy, g_iAspectRatio, zNear, zFar);
RenderManager.MatrixPerspective(fovy, aspect, zNear, zFar);
}
void glOrtho(float left,float right,float bottom,float top,float zNear,float zFar)