godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

Add a window scaling option to keep the window’s aspect ratio #10946

Open rari-teh opened 1 week ago

rari-teh commented 1 week ago

Describe the project you are working on

A card game.

Describe the problem or limitation you are having in your project

There seems to be no way to limit the window size to a specific aspect ratio.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a window scaling mode that limits the window’s aspect ratio to the viewport’s aspect ratio.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think it would be used often, but maybe I’m wrong? I’ve seen a few implementations out there searching for a solution, but they are extremely glitchy on Godot 4. I wrote a script to do it using DisplayServer.window_set_size and root.size_changed and while that technically works, the renderer distorts everything to accomodate for the “wrong” aspect ratio. If that can be worked around by tweaking the script, I am too stupid to do so.

Is there a reason why this should be core and not an add-on in the asset library?

A game’s aspect ratio is an important design choice and having an option to set it in stone while accommodating for different screen resolutions should be a no-brainer.

Calinou commented 1 week ago

I've only seen this implemented in video players like mpv, but not in any game so far. Gamers usually render black bars instead (or some other background image) if they constrain the aspect ratio.

A game’s aspect ratio is an important design choice and having an option to set it in stone while accommodating for different screen resolutions should be a no-brainer.

Constraining the game's aspect ratio is already handled by the keep stretch aspect option. This displays black bars if the window aspect ratio doesn't match the game's aspect ratio, but I'd argue this is better than the alternative since seeing your desktop background while playing the game in a window is often distracting.