Fix Vsync

This commit is contained in:
GabsPuNs
2026-05-20 16:40:07 -04:00
parent bbba35362d
commit 3d802ef86b
7 changed files with 212 additions and 257 deletions

View File

@@ -1012,16 +1012,16 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
if (true)
{
// Real window dimensions updated on every WM_SIZE — always current
extern int g_rScreenWidth;
extern int g_rScreenHeight;
extern int g_iScreenWidth;
extern int g_iScreenHeight;
// Set up a fresh projection using physical pixel coordinates so the debug
// text is never distorted regardless of aspect ratio, splitscreen layout,
// or menu state. 1 coordinate unit = 1 physical pixel.
// Compute the actual viewport dimensions for this player's screen section.
// glOrtho must match the viewport exactly for 1 unit = 1 physical pixel.
int vpW = g_rScreenWidth;
int vpH = g_rScreenHeight;
int vpW = g_iScreenWidth;
int vpH = g_iScreenHeight;
switch (minecraft->player->m_iScreenSection)
{
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
@@ -1055,8 +1055,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
// Font was designed for guiScale px/unit; scale up so characters appear
// at the same physical size as the rest of the HUD at 0.5x.
const float fontScale = static_cast<float>(guiScale) * 1.0f;
const float scaleWidth = (g_rScreenWidth / 1920.0f);
const float scaleHeight = (g_rScreenHeight / 1080.0f);
const float scaleWidth = (g_iScreenWidth / 1920.0f);
const float scaleHeight = (g_iScreenHeight / 1080.0f);
const int debugLeft = 1;
const int debugTop = 1;
@@ -1145,7 +1145,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
wfeature[eTerrainFeature_Ravine] = L"Ravine: ";
// maxW in font units: physical width divided by font scale
float maxW = (static_cast<float>(g_rScreenWidth) - debugLeft - 8) / fontScale;
float maxW = (static_cast<float>(g_iScreenWidth) - debugLeft - 8) / fontScale;
float maxWForContent = maxW - static_cast<float>(font->width(L"..."));
bool truncated[eTerrainFeature_Count] = {};