Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: SDL2 driver goes to random resolution after fullscreen #10309

Closed
rubidium42 opened this issue Jan 2, 2023 · 1 comment
Closed

[Bug]: SDL2 driver goes to random resolution after fullscreen #10309

rubidium42 opened this issue Jan 2, 2023 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@rubidium42
Copy link
Contributor

Version of OpenTTD

13.0-RC1, Linux, SDL2 driver

Expected result

A reasonable SDL window size would be taken, e.g. the original full screen window size, of maybe 90% of that.

Actual result

The SDL window size is "undefined".

For me the result has been a super low and overly wide SDL window. That window is actually lower than the minimum height and wider than my screen.

Though also crash-worthy resolutions such as 22036 x 376383744 have occured.

Steps to reproduce

  1. Start OpenTTD with SDL2 driver and go to the Game Options
  2. Enable full screen
  3. Disable full screen

Problem lies in sdl2_v.cpp's VideoDriver_SDL_Base::ToggleFullscreen where local variables w and h do not get set in case fullscreen = false, but at line 671 w and h are passed to some SDL function.
However, just flipping the expression of the if at line 654 doesn't seem completely right either. So, I hope someone has more inspiration how to fix this issue.

Actually found with the static code analysis that could be introduced by #10299.

@rubidium42 rubidium42 added this to the 13.0 milestone Jan 2, 2023
@2TallTyler 2TallTyler added the bug Something isn't working label Jan 3, 2023
@glx22
Copy link
Contributor

glx22 commented Jan 5, 2023

VideoDriver_SDL_Base::ToggleFullscreen() code is strange, when switching to fullscreen it sets w and h but these are then write only. I think this function needs to be rewritten entirely.

rubidium42 added a commit to rubidium42/OpenTTD that referenced this issue Jan 7, 2023
michicc pushed a commit to michicc/OpenTTD that referenced this issue Jan 27, 2023
michicc pushed a commit to michicc/OpenTTD that referenced this issue Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants