HIDPI in projects

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

We became available Godot 2.1 RC1 link
One of the expected changes is the support for HIDPI screens in the Godot editor.

Dear developers, huge, huge… extremely huge to you thanks! :slight_smile:

In connection with this change becoming a pressing issue:
How to support HIDPI in your project?

I’m developing a 3D game which works only in full screen mode. It incorporated the switch from 1280x720 to 3840x2160. How to perform a theme, icons, fonts, whatever they are displayed correctly in all screen resolutions? What are the necessary settings?

Project Settings > Display > Stretch mode > 2d
Is this setting not enough?

volzhs | 2016-07-26 10:33

The problem is that this setting doesn’t let you provide your own hi-DPI graphics for theme items and other sprites, so everything is either pixelated or blurry when upscaled.

Calinou | 2016-07-26 12:58

I resolved the issue with support for screens of different densities. In this matter, I did not rely on the mechanism of Godot HIDPI. I have a global script which switches the resolution viewport, there it is possible to obtain data on the current screen resolution.

Next, I drew in SVG format elements of a theme and exported it to a raster for three different size theme: “low density”, “medium density” and “high density”.

Next, I added in script the variable, in which the loaded theme as a resource. I update this variable automatically when you switch screen resolutions.

And last… in:

func _ready():

all scenes interface I prescribed the application of themes from the variable global script.

This enough :wink:

DimitriyPS | 2016-08-08 07:02

:bust_in_silhouette: Reply From: bitbloom

An alternative to changing the stretch mode is to determine the scaleFactor.

var displaySize = Vector2(Globals.get("display/width"), Globals.get("display/height"))
var scaleFactor = OS.get_window_size() / displaySize
OS.set_window_size(displaySize / scaleFactor)

You shouldn’t set the window size, I just added it so you could see the effect. Instead, you can use scaleFactor to determine what resources you should load. It’s a Vector2 which returns (2, 2) on my Retina display. So in this case, I would load resources that are twice as big.