From c1b7ddddb69b1f79b59d37914ca155fd5c3e64d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 10 Oct 2026 03:09:22 +0000 Subject: [PATCH] engine: web video mode is exactly the requested size, never mode 0 The game rendered the menu and the first chamber at 640x480 (the device log said BackBufWidth 640) and the page stretched that 4:3 picture over the 2.16:1 iPhone screen: zoomed, horizontally squashed 3D and oversized menu text, unlike real Portal's wide view. FindVideoMode only honours a custom size if it equals the size requested when the window was created and the game is windowed; anything else falls back to the display mode list, and for a size not in that list, to mode 0 (640x480). A browser canvas has no mode list, so on the web build it now always returns the requested size. ResetCurrentModeForNewResolution logs the chosen mode ([Render360 video]) into the diagnostics error list. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Qy5DKdwTqGQqScWvJyNcft --- emscripten/pre.js | 2 +- engine/sys_getmodes.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/emscripten/pre.js b/emscripten/pre.js index 0cae8d0ed8..7d28bd51e0 100644 --- a/emscripten/pre.js +++ b/emscripten/pre.js @@ -89,7 +89,7 @@ const render360LogTail = [] // Errors and font/audio lines, kept apart so a long run cannot push them out // of the 40-line tail before anyone copies diagnostics. const RENDER360_NOTABLE_KEY = 'render360-ios-notable-v1' -const RENDER360_NOTABLE_RE = /font|error|fail|couldn'?t|cannot|can't|unable|missing|not found|warning|audio|sound/i +const RENDER360_NOTABLE_RE = /font|error|fail|couldn'?t|cannot|can't|unable|missing|not found|warning|audio|sound|Render360 video/i const render360Notable = [] let render360LogTailDirty = false function render360RememberLine(text) { diff --git a/engine/sys_getmodes.cpp b/engine/sys_getmodes.cpp index 43dce4d0ab..f0f6878c45 100644 --- a/engine/sys_getmodes.cpp +++ b/engine/sys_getmodes.cpp @@ -466,6 +466,19 @@ int CVideoMode_Common::FindVideoMode( int nDesiredWidth, int nDesiredHeight, boo #endif // USE_SDL +#ifdef __EMSCRIPTEN__ + // The browser canvas can be any size; there is no display mode list to + // snap to. Snapping sent the game to mode 0 (640x480), which the page then + // stretched across a 2.16:1 iPhone screen: zoomed, squashed 3D and huge + // menu text. Always use exactly the size that was asked for. + if ( nDesiredWidth > 0 && nDesiredHeight > 0 ) + { + RequestedWindowVideoMode().width = nDesiredWidth; + RequestedWindowVideoMode().height = nDesiredHeight; + return VIDEO_MODE_REQUESTED_WINDOW_SIZE; + } +#endif + // Check the default window size.. if ( ( nDesiredWidth == DefaultVideoMode().width) && (nDesiredHeight == DefaultVideoMode().height) ) return VIDEO_MODE_DEFAULT; @@ -528,6 +541,9 @@ void CVideoMode_Common::ResetCurrentModeForNewResolution( int nWidth, int nHeigh m_nUIHeight = pMode->height; m_nStereoWidth = pMode->width; m_nStereoHeight = pMode->height; +#ifdef __EMSCRIPTEN__ + Msg( "[Render360 video] mode %dx%d (asked %dx%d, windowed=%d)\n", m_nModeWidth, m_nModeHeight, nWidth, nHeight, bWindowed ? 1 : 0 ); +#endif // assume we won't be overriding the position m_bVROverride = false;