Limits of runtime resolution changes in Monogame windowed mode for accessibility
0 reputation · 02 Jan 2021, 03:21 UTC
0 reputation · 02 Jan 2021, 03:21 UTC
Goal: Allow users with low vision to adjust the render resolution at runtime while the game runs in windowed mode, thereby scaling UI elements without restarting the application.
Constraint: Monogame requires GraphicsDeviceManager.IsFullScreen to be set to false and the preferred back buffer dimensions to be changed before calling ApplyChanges(); the exact behavior of the client size after ApplyChanges() and the preservation of existing render targets varies between Monogame 3.6, 3.7, and 3.8 releases.
Questions: Does calling ApplyChanges() after updating PreferredBackBufferWidth and PreferredBackBufferHeight retain the current render target contents? Is the resulting client size guaranteed to match the requested dimensions, or does the window manager add non‑client borders that affect the usable drawing area? Are there any known regressions in windowed mode that prevent proper DPI scaling for accessibility‑focused UI?
35275 reputation · 02 Jan 2021, 04:05 UTC
ApplyChanges() after updating PreferredBackBufferWidth/Height clears the current back buffer. Any content drawn to the back buffer is lost unless you first copy it to a texture.ApplyChanges(), Window.ClientBounds reports the requested dimensions, but the actual window includes OS non‑client borders (title bar, borders). The usable drawing area matches ClientBounds, not the outer window size.GraphicsDeviceManager.ApplyChanges internally calls GraphicsDevice.Reset, which detaches and resets all attached render targets. Developers must recreate or re‑initialize any custom render targets after the call. For layout calculations, always use Window.ClientBounds rather than Window.Size, because the latter includes window decorations that do not affect rendering.
PreferredBackBufferWidth/Height to 800×600, call ApplyChanges(), render a solid color, then change to 1280×720, call ApplyChanges(), and confirm the back buffer is cleared (visible transition or pixel check).Window.ClientBounds and Window.Size before and after ApplyChanges() to verify client bounds match requested dimensions and that the overall window size includes non‑client borders.Which platform (Windows, macOS, Linux) and MonoGame version are you targeting? The behavior of non‑client borders and DPI handling varies by platform, and the device‑reset regression is specific to 3.7+ on Windows.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.