Files
vpinball-wasm/patches/vpinball/0005-window-onresized-backbuffer-sync.patch
valknarandClaude Sonnet 5 b8bf9f1510 Fix back buffer not resizing on fullscreen toggle
Window::OnResized() (called for every SDL window-resize event, including
entering/leaving browser fullscreen) updated the window's own tracked
pixel size but never propagated it to the window's back buffer render
target, whose stale size kept driving glViewport() - so toggling
fullscreen resized the canvas but rendering stayed pinned to the old,
smaller viewport. Mirrors the resize handling the BGFX backend already
does explicitly elsewhere in RenderDevice.cpp.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 18:03:08 +02:00

21 lines
1.0 KiB
Diff

diff --git a/src/renderer/Window.cpp b/src/renderer/Window.cpp
index ad608f8..3dff060 100644
--- a/src/renderer/Window.cpp
+++ b/src/renderer/Window.cpp
@@ -381,6 +381,15 @@ void Window::OnResized()
return;
SDL_GetWindowSize(m_nwnd, &m_width, &m_height);
SDL_GetWindowSizeInPixels(m_nwnd, &m_pixelWidth, &m_pixelHeight);
+ // vpinball-wasm: keep the (GL) default back buffer's tracked size in sync
+ // with the window's actual pixel size, mirroring what the BGFX backend
+ // already does explicitly every frame (RenderDevice.cpp's swapchain
+ // resize handling). Without this, glViewport(0, 0, m_width, m_height) in
+ // RenderTarget::Activate() keeps using the pre-resize size forever, so
+ // e.g. entering browser fullscreen (which resizes the canvas well after
+ // the back buffer was created) only renders into the old, smaller area.
+ if (m_backBuffer)
+ m_backBuffer->SetSize(m_pixelWidth, m_pixelHeight);
}
VPX::Window::VideoMode Window::SDLtoVPXVideoMode(const SDL_DisplayMode* mode)