How to shrink a program (2d) to a lower resolution dynamically

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Starfighter

Hi,

I’am programming a 2d game using a native resolution of 1920 x 1080.

I’d like to be able to make this game working using lower resolutions.

I noticed that a “shrink” option is available in the project settings → Display → Window section, but this option only works when compiling the project.

What i’d like to do is to get the game automatically scale down to the current resolution of the screen.
I’ve got no problem to get the resolution of the screen using get_viewport().size, but what i don’t know is how to reduce the game resolution to the screen’s resolution.

Any help is welcome.

Thanks

:bust_in_silhouette: Reply From: MysteryGM

I’am programming a 2d game using a native resolution of 1920 x 1080.
I’d like to be able to make this game working using lower resolutions.

What do you mean by this? In Godot go to: Project Settings-> Display → Window → Stretch → Mode
Here set the mode to either 2D or Viewport. This will allow the game to be dynamically sized by scaling the window it runs in.

2D: This calculates the polygons inside the screen to fit the screen. works like most 2D engines. (libGDX, Unity etc.)
It is also the only way to really get pixel perfect look on mobile, but will need custom mips.

Viewport: This calculates the size of images on the fly, the same as adjusting the viewport size would. Some data loss happens with this one.

The Godot manual says to use this one with pixel perfect games in the manual, but fail to mention that only works with constant aspect ratios.
Since most Mobiles and Tablets use inconsistent aspect ratios you will need to calibrate the screen ratio first.

To keep aspect ratio just select one of the options under Mode.
Keep_width or Keep_Height will render with a black boarder.

enter image description here

What i’d like to do is to get the game automatically scale down to the current resolution of the screen.

You will make code for this. The Viewport node has what you need.
http://docs.godotengine.org/en/3.0/tutorials/viewports/viewports.html

I hope this answers what you are asking, I don’t understand what you need.

Thank you for your answer.

I’ll try to explain better what I need.

My program resolution is 1920 x 1080 (Full HD).

If I run this program on a computer which can display only a lower resolution (l1600 x 900 for example), only a part of the screen will be visible (the other part is displayed “off screen”).

What I’d like to do is to shrink to resolution of the program automatically to the same the resolution of the computer.

Thanks

Starfighter | 2018-10-03 16:55

I’m having the exact same problem as Starfighter mentions.

GodotUser | 2019-07-25 14:18

I have the same problem as well

Mike Trevor | 2019-10-21 23:59

I have the same issue (Godot v3.4).

I’ve come to think that it’s because I was exporting for WindowsDesktop, which doesn’t include laptops (with smaller screens), instead of UWP. However, knowing this doesn’t help, unless you can afford a code signing certificate.

At least that’s the conclusion I’ve reached.