From d9184f1a99cfee146cbbe195200dcfc8c78d0dd9 Mon Sep 17 00:00:00 2001 From: JuiceyDev Date: Fri, 6 Mar 2026 18:50:28 +0100 Subject: [PATCH] screen size --- Minecraft.Client/Rendering/GameRenderer.cpp | 32 +++++++++++++++---- Minecraft.Client/UI/ScreenSizeCalculator.cpp | 3 +- .../UI/Screens/AchievementPopup.cpp | 6 +++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 0939d7388..b12c51f74 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -627,8 +627,13 @@ void GameRenderer::unZoomRegion() void GameRenderer::getFovAndAspect(float& fov, float& aspect, float a, bool applyEffects) { // 4J - split out aspect ratio and fov here so we can adjust for viewports - we might need to revisit these as - // they are maybe be too generous for performance. - aspect = mc->width / (float) mc->height; + // avoid pixel streching, its UGLEYYY + { + int fbw = mc->width; + int fbh = mc->height; + RenderManager.GetFramebufferSize(fbw, fbh); + aspect = fbw / (float) fbh; + } fov = getFov(a, applyEffects); if( ( mc->player->m_iScreenSection == C4JRender::VIEWPORT_TYPE_SPLIT_TOP ) || @@ -1053,12 +1058,15 @@ 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 +{ + int fbw, fbh; + RenderManager.GetFramebufferSize(fbw, fbh); + glViewport(0, 0, fbw, fbh); ScreenSizeCalculator ssc(mc->options, mc->width, mc->height); int screenWidth = ssc.getWidth(); int screenHeight = ssc.getHeight(); - int xMouse = Mouse::getX() * screenWidth / mc->width; - int yMouse = screenHeight - Mouse::getY() * screenHeight / mc->height - 1; + int xMouse = Mouse::getX() * screenWidth / fbw; + int yMouse = screenHeight - Mouse::getY() * screenHeight / fbh - 1; int maxFps = getFpsCap(mc->options->framerateLimit); @@ -1083,7 +1091,11 @@ void GameRenderer::render(float a, bool bFirst) } else { - glViewport(0, 0, mc->width, mc->height); + { + int fbw, fbh; + RenderManager.GetFramebufferSize(fbw, fbh); + glViewport(0, 0, fbw, fbh); + } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1291,7 +1303,11 @@ void GameRenderer::renderLevel(float a, __int64 until) } - glViewport(0, 0, mc->width, mc->height); + { + int fbw, fbh; + RenderManager.GetFramebufferSize(fbw, fbh); + glViewport(0, 0, fbw, fbh); + } setupClearColor(a); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_CULL_FACE); @@ -1787,6 +1803,8 @@ void GameRenderer::renderSnowAndRain(float a) // 4J - added forceScale parameter void GameRenderer::setupGuiScreen(int forceScale /*=-1*/) { + int fbw, fbh; + RenderManager.GetFramebufferSize(fbw, fbh); ScreenSizeCalculator ssc(mc->options, mc->width, mc->height, forceScale); glClear(GL_DEPTH_BUFFER_BIT); diff --git a/Minecraft.Client/UI/ScreenSizeCalculator.cpp b/Minecraft.Client/UI/ScreenSizeCalculator.cpp index b9fc596cb..b90483271 100644 --- a/Minecraft.Client/UI/ScreenSizeCalculator.cpp +++ b/Minecraft.Client/UI/ScreenSizeCalculator.cpp @@ -2,6 +2,7 @@ #include "ScreenSizeCalculator.h" #include "../GameState/Options.h" +// who the fuck thought this was a good idea ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int height, int forceScale/*=-1*/) { w = width; @@ -12,7 +13,7 @@ ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int heig int maxScale = options->guiScale; if (maxScale == 0) maxScale = 1000; - while (scale < maxScale && w / (scale + 1) >= 320 && h / (scale + 1) >= 240) + while (scale < maxScale && w / (scale + 1) >= 320 && h / (scale + 1) >= 240) // ughh { scale++; } diff --git a/Minecraft.Client/UI/Screens/AchievementPopup.cpp b/Minecraft.Client/UI/Screens/AchievementPopup.cpp index 065349317..402bd3333 100644 --- a/Minecraft.Client/UI/Screens/AchievementPopup.cpp +++ b/Minecraft.Client/UI/Screens/AchievementPopup.cpp @@ -43,7 +43,11 @@ void AchievementPopup::permanent(Achievement *ach) void AchievementPopup::prepareWindow() { - glViewport(0, 0, mc->width, mc->height); + { + int fbw, fbh; + RenderManager.GetFramebufferSize(fbw, fbh); + glViewport(0, 0, fbw, fbh); + } // just future proofing glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW);