From 9372887aef95bf08b83d1e0d4145fa4a6fd6bc3a Mon Sep 17 00:00:00 2001 From: Fayaz Shaikh <61674751+fayaz12g@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:13:58 -0500 Subject: Fix for any aspect ratio in 3D Environments (#320) * Add initial AnyAspectRatio support * Remove some logic that didn't work * Remove rogue back slash * Remove more remnants * Update UILayer.h * Update some comments * Remove WIP UI changes * Fix diffs * Remove UI resize call from `UpdateAspectRatio` * handle merge conflict * Update to C++ style static cast * Fix syntax --- Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp') diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 0f83fae5..61257b89 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -88,8 +88,7 @@ BOOL g_bWidescreen = TRUE; int g_iScreenWidth = 1920; int g_iScreenHeight = 1080; -UINT g_ScreenWidth = 1920; -UINT g_ScreenHeight = 1080; +float g_iAspectRatio = static_cast(g_iScreenWidth) / g_iScreenHeight; char g_Win64Username[17] = { 0 }; wchar_t g_Win64UsernameW[17] = { 0 }; @@ -98,6 +97,14 @@ wchar_t g_Win64UsernameW[17] = { 0 }; static bool g_isFullscreen = false; static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) }; +//-------------------------------------------------------------------------------------- +// Update the Aspect Ratio to support Any Aspect Ratio +//-------------------------------------------------------------------------------------- +void UpdateAspectRatio(int width, int height) +{ + g_iAspectRatio = static_cast(width) / height; +} + struct Win64LaunchOptions { int screenMode; @@ -468,6 +475,7 @@ ID3D11Texture2D* g_pDepthStencilBuffer = NULL; // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return +// WM_SIZE - handle resizing logic to support Any Aspect Ratio // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -585,6 +593,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } } break; + case WM_SIZE: + { + UpdateAspectRatio(LOWORD(lParam), HIWORD(lParam)); + } + break; default: return DefWindowProc(hWnd, message, wParam, lParam); } @@ -719,7 +732,7 @@ HRESULT InitDevice() //app.DebugPrintf("width: %d, height: %d\n", width, height); width = g_iScreenWidth; height = g_iScreenHeight; -app.DebugPrintf("width: %d, height: %d\n", width, height); +//app.DebugPrintf("width: %d, height: %d\n", width, height); UINT createDeviceFlags = 0; #ifdef _DEBUG -- cgit v1.2.3