0 votes

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?

in Engine by (570 points)
edited by

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).

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.