Unable to change fullscreen resolution?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheSHEEEP
:warning: Old Version Published before Godot 3 was released.

I have been trying since some time now to get Godot 2.1.4 to change the resolution in fullscreen mode (Windows and Linux, doesn’t make a difference), with little luck.

What works is a borderless fullscreen mode (actually a borderless window at screen size) - obviously, you cannot change its size.
What also works is windowed mode - changing resolution via OS.set_window_size() does what you’d expect.

However, I find it pretty much impossible to have the application in true fullscreen mode and at the same time change the resolution. I have tried every combination I could think of from OS.set_window_size(), Viewport.set_size_override, Viewport.set_size_override_stretch, Viewport.set_render_target_to_screen_rect and all the combination of stretching in the project settings. None of it has worked.

What I would like to do is offer an option to users to run the application in true fullscreen mode while setting a resolution that differs from the application’s “default” resolution set in the project settings (in this case 1920x1080). Which can be done in any other game that I’m aware of.
The reason for this is to allow higher resolutions (4K) as well as lower ones for performance (or old monitor) reasons.

Using OS.set_window_size messes up the entire rendering in true fullscreen - just try it with the Window Management demo (go fullscreen and then resize) and you’ll see what I mean.
On Windows, the result is a messed up screen for me and on Linux, pressing resize while in fullscreen messes the screen up for a single frame until returning to the previous resolution. Weird, either way.

So that is out of the question.

The closest that I’ve come to a solution was with the following settings:
Project stretch mode: disabled aspect: ignored

get_viewport().set_size_override(true, Vector2(1366, 768))
# Setting the override_stretch to false results in no change at all, even if above values are something weird like Vector2(20,20)
get_viewport().set_size_override_stretch(true)

What this does is indeed just displaying 1366x768 pixels on the screen. However, it is just the upper left corner of the content that is displayed - obviously, all the UI, etc. is internally still rendered at its default size.
What I could do here is to manually do the layouting of every single screen each time the resolution changes, setting every single UI element’s size, position, etc. This is doable, but a ridiculous amount of work… Surely there must be an easier way?

If I understand this correctly, setting the stretch mode to “2d” and the stretch aspect to ignore should do exactly what I want, but when I do so and set the window size to 1366x768 while in true fullscreen, it just messes up the screen like in the Window Management demo.

I’m not sure if I’ve hit a bug, a missing feature or if I’m just doing it wrong.

Either way, I must say that I do have the feeling there are far too many screws and settings here that one can use to influence how things are rendered, combined with very sparse documentation on the matter (especially the API docs). And I didn’t even start looking at camera settings, yet.
All that would IMO be needed would be a render_size that sets what the game is actually rendered at (this is what influences the performance most) and a display_size (or window size) that sets at what resolution the render target is displayed. And the possibility to automatically stretch/shrink the displayed content to the render_size. So that a 1366x768 rendering could be displayed at a 1920x1080 resolution, for example.
Would look pixelated, but that’s kind of unavoidable when displaying a resolution that is “too small” for your monitor.

:bust_in_silhouette: Reply From: TheSHEEEP

Turns out this is actually a quite surprising missing feature/misunderstanding:

To change resolution in true fullscreen mode, you need to change the resolution of the viewport instead.
Viewport and window size are two entirely different things in Godot.