[v4.7.2] - How Can We Detect If PC Display Is 4K, 1080p, 720p, Etc?

Godot Version

v4.7.2.stable.official [ed1daf0bf] - Linux desktop x86_64

Question

Hi,

How can we detect if PC display is 4K, 1080p, 720p, etc?
Need it for Linux x86_64, Linux arm64, and if possible Web HTML5.

Let us know, thank you!

Savant Savior

get_window().size

Also display server has some info too.

DisplayServer.screen_get_size()

To add to what @pennyloafers said, since you asked for the web, there’s no consistent way to get these informations on the web at all. Some users will not run the game full screen, some users will not even run the web browser as a maximized window, and some users will directly hide a lot of info like this to make themselves more private online. What you should care about is canvas and viewport size instead, not their actual, physical display size, since that information is something you will never be able to consistently query no matter what.

Ok, thanks - I’ll try to figure out something…

This does what we need:

var viewport_size = get_viewport().size
VisualsCore.DisplayWidth = viewport_size.x
VisualsCore.DisplayHeight = viewport_size.y

Thank you!