Skip to content

Fix SDL3 display modes and window scaling#3671

Merged
LeftofZen merged 5 commits intoOpenLoco:masterfrom
kevinz26:master
Mar 26, 2026
Merged

Fix SDL3 display modes and window scaling#3671
LeftofZen merged 5 commits intoOpenLoco:masterfrom
kevinz26:master

Conversation

@kevinz26
Copy link
Copy Markdown
Contributor

Summary

This fixes several regressions introduced during the SDL3 migration around display mode switching, startup resolution handling, and window scaling.

Changes

  • fix fullscreen and borderless mode transitions on SDL3
  • resolve saved display targets correctly when older configs contain a display index instead of an SDL display ID
  • apply saved fullscreen and borderless state after window creation so startup respects the configured resolution
  • prevent fullscreen transitions from overwriting the saved windowed resolution
  • clamp invalid monitor-sized windowed resolutions back to a sane window size
  • react to SDL3 pixel-size and display-scale window events by triggering a resize refresh
  • restore sharper 2x window scaling by using nearest filtering on the primary software-rendered texture
  • add Visual Studio 2026 CMake presets

Notes

A few of these bugs compounded with each other, which made the behavior feel inconsistent in practice:

  • some mode switches succeeded but were treated as failures due to SDL3 bool-return handling
  • some fullscreen requests used an invalid handcrafted display mode instead of asking SDL3 for the closest valid one
  • some resize events during mode switches polluted the saved window_resolution

Testing

  • built successfully with:
    • cmake --preset windows-vs2026
    • cmake --build --preset windows-vs2026-release
  • manually verified switching between windowed, fullscreen, and borderless
  • verified startup now respects the saved fullscreen resolution
  • verified 2x scaling on 1440p

@kevinz26
Copy link
Copy Markdown
Contributor Author

Updated to store the display index in config and resolve the SDL display ID at runtime.

@kevinz26
Copy link
Copy Markdown
Contributor Author

Removed the VS 2026 preset changes from this PR so it stays focused on the SDL3 display fix.

@ZehMatt
Copy link
Copy Markdown
Contributor

ZehMatt commented Mar 15, 2026

The code seems alright, there are some things I like to change but I can do them after the PR, ideally some people test this before we merge it.

@LeeSpork
Copy link
Copy Markdown
Contributor

Had a play on a CI release artefact, looks good 👍

clamp invalid monitor-sized windowed resolutions back to a sane window size

Maybe worth a changelog?

Copy link
Copy Markdown
Contributor

@LeftofZen LeftofZen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't have any issues with this, but needs some testing by a mac/linux user

@AaronVanGeffen
Copy link
Copy Markdown
Member

Works fine on macOS. Fullscreen setting is not saved, as expected. Reminded me that the screen mode dropdown in the options window is not disabled on macOS, which is a relatively recent regression. (Does not need addressing in this PR, though.)

Will test Linux (Wayland) in a bit.

@AaronVanGeffen
Copy link
Copy Markdown
Member

AaronVanGeffen commented Mar 25, 2026

Linux / Wayland appears to be working fine as well. Nice work!

Perhaps we could add a changelog entry or two for the user-facing changes?

@AaronVanGeffen AaronVanGeffen added the changelog Requires a changelog entry label Mar 25, 2026
@AaronVanGeffen AaronVanGeffen added this to the v26.02+ milestone Mar 25, 2026
@LeftofZen LeftofZen merged commit 6413ab4 into OpenLoco:master Mar 26, 2026
14 checks passed
@AaronVanGeffen
Copy link
Copy Markdown
Member

I think "clamp invalid monitor-sized windowed resolutions back to a sane window size" warrants a changelog entry as well. That was plaguing our SDL2 setup just as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Requires a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants