Skip to content

Some fixes for setting resolution#11

Open
thesourcehim wants to merge 4 commits into
perpendicular-dimensions:masterfrom
thesourcehim:fixfullscreen
Open

Some fixes for setting resolution#11
thesourcehim wants to merge 4 commits into
perpendicular-dimensions:masterfrom
thesourcehim:fixfullscreen

Conversation

@thesourcehim

Copy link
Copy Markdown
Contributor

Fix setting fullscreen resolution and switching between fullscreen and windowed modes.

Some window managers may refuse to resize the window beyond taskbars.
Call setResolution twice: before and after setting to fullscreen, otherwise switching back to windowed mode by F10 leads to wrong window size
@thesourcehim

thesourcehim commented Apr 15, 2022

Copy link
Copy Markdown
Contributor Author

Commit [f50b499] address switching resolution and mode issue and also attempts to fix misaligned widgets when rendering resolution is smaller that desktop one in fullscreen mode. I moved viewport to upper left corner from bottom to fix that, additional changes were made to accommodate to that (hud target reticle and boxed items and weapons drawing). Also save selected resolution to config properly in case window is not resized to required size (collided with task bar).

I recommend to test it on several missions to make sure I didn't break any drawing.

@thesourcehim

Copy link
Copy Markdown
Contributor Author

I have an idea how this may be improved. At first I thought to use SDL_SetWindowDisplayMode for fullscreen windows instead of SDL_SetWindowSize. This function is supposed to actually change screen resolution. However, testing showed that under X11 it can switch the display to non-guaranteed mode and disable it (not much can be done about it, that's how modern displays work, they don't officially support anything except native resolution), under wayland changing resolution with SDL_SetWindowDisplayMode is impossible, it behaves exactly like SDL_SetWindowSize instead.
I'm thinking about rendering to an FBO of selected size instead, and then stretch-center resulting image on the screen. Additionally this allows to use SSAA by using FBO's larger that native resolution. This however will require some work on mouse processing too to properly detect widgets position. I'm not sure if this should be done within this PR. Maybe it's better to commit these changes first, finish my previous PR for accum buffers on top of this and then start another PR for FBO's.

@gsliepen

Copy link
Copy Markdown
Contributor

Thanks for the attempts to improve this, but with your current patch, if I switch from windowed to fullscreen, it results in a nearly black screen. It seems things are drawn way too high.

Switching the actual display resolution under X11 is very annoying and not what you want. Also, the fact that it uses SDL_GetDisplayMode() to get a list of resolutions supported by the display driver is rather silly; it makes no sense for windowed mode where we can support arbitrary sizes and just let the user resize the window as desired.

I doubt any contemporary graphics cards, even low-end integrated GPUs, would have any issue rendering this game at full screen resolution, but if we really want to we could add an option to downscale the rendering resolution. That would indeed involve an FBO. So perhaps the best option now is to remove the whole resolution selection thing from the GUI, only have a way to toggle between windowed and fullscreen, and also honour window resize events. Support for downscaling/SSAA could be done in a separate pull request.

What do you think?

@thesourcehim

Copy link
Copy Markdown
Contributor Author

I was leaning towards this myself. SDL_GetDisplayMode() may even return "unsafe" resolutions which actually fail resulting in non-working display. Not sure about downscaling though, does it make sense? Maybe implement SSAA and changing aspect ratio (4:3, 5:4, 16:9, 16:10 etc)?

@thesourcehim thesourcehim changed the title [WIP] Some fixes for setting resolution Some fixes for setting resolution May 29, 2024
@thesourcehim

Copy link
Copy Markdown
Contributor Author

I removed resolution selection as it no longer makes sense. Instead just set window to desktop fullscreen when requested and remember window size if it is resized in windowed mode.

@thesourcehim

Copy link
Copy Markdown
Contributor Author

@gsliepen , I tested the last change under wayland but I don't have X11 session anymore (moved to KDE 6), can you please test?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants