Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_screen_refresh_rate() to OS #58812

Merged

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Mar 5, 2022

This method can be used to get the refresh rate of a given screen. It is supported on Windows, macOS, Linux, Android and iOS (but not HTML5).

3.x version of #57335.

I've only tested this on Linux, Windows (via WINE) and Android so far, so testing on other platforms is welcome.

Testing project: test_refresh_rate_3.x.zip

Windows 64-bit export: UnnamedProject-windows.zip
Android export: UnnamedProject-android.zip

Preview

image

@akien-mga
Copy link
Member

Judging by the screenshot, you should also backport the follow up that limited decimal precision to 2 places.

@Calinou Calinou force-pushed the os-add-get-screen-refresh-rate-3.x branch from dc8facd to 3d84d6c Compare March 5, 2022 23:44
@Calinou
Copy link
Member Author

Calinou commented Mar 5, 2022

Judging by the screenshot, you should also backport the follow up that limited decimal precision to 2 places.

I did, but it doesn't appear to work as expected: https://github.com/godotengine/godot/blob/3d84d6c68294a992ea5b829042ec94414da5c32c/platform/x11/os_x11.cpp#L1368-L1369

It's strange because in GDScript, print(143.91) does print 143.91 without any extraneous numbers (and so does print(stepify(143.91, 0.01))).

@Calinou Calinou force-pushed the os-add-get-screen-refresh-rate-3.x branch from 3d84d6c to 574673e Compare March 5, 2022 23:56
@Calinou Calinou force-pushed the os-add-get-screen-refresh-rate-3.x branch from 574673e to 362871d Compare March 7, 2022 21:39
doc/classes/OS.xml Outdated Show resolved Hide resolved
This method can be used to get the refresh rate of a given screen.
It is supported on Windows, macOS, Linux, Android and iOS (but not
HTML5).
@Calinou Calinou force-pushed the os-add-get-screen-refresh-rate-3.x branch from 362871d to cec7c90 Compare March 10, 2022 21:10
Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Android section looks good!

@akien-mga akien-mga merged commit eb36566 into godotengine:3.x Mar 11, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants