Is there some mismatch between Godot window size pixels and OS X window size?

I was also a little confused by this at first being used to working with macOS retina scaling where the windows/controls are sized in some nominal pixel units and the upscaling to higher resolution (and more pixels) is under the hood when rendering to the screen. As this makes more sense to me I’ve set up a little script to emulate this behavior on my windows in godot that you might be able to use as well:

Basically you can use

retina_scale = DisplayServer.screen_get_scale(screen)

to get the screen resolution scale, and then then scale both the window size and and set the content scale using that:

if (window.content_scale_factor != retina_scale):
	#we need to change, calculate the relative change in scale
	var relative_scale:float = retina_scale / window.content_scale_factor
	#apply the change, as well as resizing window based on previous scale and relative scale
	window.content_scale_factor = retina_scale
	window.size = window.size*relative_scale

It works quite well, and I’ve even set it up using the node_added signal on the main tree to catch and correctly scale up popup windows like tooltips as they’re added.

Note however that DisplayServer.screen_get_scale(screen) is currently just implemented for macOS (see Implement `DisplayServer.screen_get_scale()` on Windows, Linux and Android · Issue #2661 · godotengine/godot-proposals · GitHub) so I have a fallback where I make a simple guess if it’s a highDPI monitor based on DisplayServer.screen_get_dpi(screen) that is implemented on other platforms.

3 Likes