Fix double-scaling by locking page layout to logical presentation
Pages computed layout from SDL_GetWindowSize() (real window coordinates) while SDL_SetRenderLogicalPresentation() independently remapped every draw call into a 1920x1080 space. The two coordinate systems only agreed when the window happened to be exactly 1920x1080; at any other size, layout coordinates were transformed a second time, so content shrank/grew quadratically toward the top-left on resize or on non-1080p monitors. Commenting the call out masked the bug by making rendering 1:1 with the window, but then nothing scaled: fonts and margins stayed fixed-pixel while backgrounds cover-fit, and HiDPI displays drew at point resolution and relied on blurry compositor upsampling. Restore SDL_SetRenderLogicalPresentation(1920x1080, LETTERBOX) as the single source of scaling, and route all twelve layout sites through a new radiantwave::getLayoutSize() helper (src/logical_size.h) that returns the renderer's logical size, so pages always lay out against the design resolution regardless of window or monitor geometry. Add SDL_WINDOW_HIGH_PIXEL_DENSITY so HiDPI displays render at native pixel density instead of being upscaled by the OS. Cached per-page textures become resolution-independent since layout no longer depends on window size.
This commit is contained in:
+6
-6
@@ -62,12 +62,12 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {
|
||||
// Lock the renderer to a 1920x1080 logical coordinate space. All page
|
||||
// layout code already targets this resolution, so everything renders at
|
||||
// the correct size on any display — the GPU scales to native pixels.
|
||||
// if (!SDL_SetRenderLogicalPresentation(state->renderer, 1920, 1080,
|
||||
// SDL_LOGICAL_PRESENTATION_STRETCH)) {
|
||||
// radiantwave::logger::Logger::instance().warning("Graphics",
|
||||
// "Could not set logical render size; layout may be wrong on HiDPI
|
||||
// displays");
|
||||
// }
|
||||
if (!SDL_SetRenderLogicalPresentation(state->renderer, 1920, 1080,
|
||||
SDL_LOGICAL_PRESENTATION_STRETCH)) {
|
||||
radiantwave::logger::Logger::instance().warning(
|
||||
"Graphics", "Could not set logical render size; layout may be "
|
||||
"wrong on HiDPI displays");
|
||||
}
|
||||
|
||||
SDL_HideCursor();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user