Understanding multiple resolutions

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

Hey guys,
I’m looking for a way to scale the project’s resolution to the viewport size so that:

  • aspect ratio remains the same (no stretching)
  • the longer side of the project is scaled to fit
    For example: the project I am working on has a 4:3 ratio. If the game is displayed in a 16:9 viewport, I want it to be fullscreen (no black bars and no stretching), with the height partially cut out outside the viewport.
    Is there an option for this?

I would advise not using the viewport stretch mode as it doesn’t scale the rendering buffer like you’d expect it (resulting in pixelated graphics). I wouldn’t recommend the 2d stretch mode either, because it pretty much requires the use of a keep aspect ratio mode (which means you’ll often get black bars) and will dumbly rescale your GUI (which isn’t always what you want, this is true especially for desktop games).

The best (and most involved) solution is likely to use disabled scaling mode, and ignore aspect ratio, and to handle GUI resizing yourself using control scaling and anchoring. To adjust the game zoom, you can use a camera. This way, you support most aspect ratios without any black bars.

Regardless of what scaling mode you use, properly handling hiDPI is still a problem, unfortunately Godot currently has no hiDPI facilities for games (it’s only for the editor as of 2.1.2).

Calinou | 2017-03-16 12:47

I modified the question since I was not clear.
Useful answer though, thank you!

DodoIta | 2017-03-16 16:41