From 7a9972afc2373fb903ca83363de68c067f721e1d Mon Sep 17 00:00:00 2001 From: jordi Date: Thu, 10 Feb 2022 13:31:32 -0600 Subject: Change SCREEN_GET_REFRESH_RATE_FALLBACK to -1.0 --- doc/classes/DisplayServer.xml | 10 ++++++++-- servers/display_server.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index 281c218d0d..d28fd5d817 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -403,8 +403,14 @@ - Returns the current refresh rate of the specified screen. If [code]screen[/code] is [code]SCREEN_OF_MAIN_WINDOW[/code] (the default value), a screen with the main window will be used. - [b]Note:[/b] Returns [code]60.0[/code] if the DisplayServer fails to find the refresh rate for the specified screen. On HTML5, [method screen_get_refresh_rate] will always return [code]60.0[/code] as there is no way to retrieve the refresh rate on that platform. + Returns the current refresh rate of the specified screen. If [code]screen[/code] is [constant SCREEN_OF_MAIN_WINDOW] (the default value), a screen with the main window will be used. + [b]Note:[/b] Returns [code]-1.0[/code] if the DisplayServer fails to find the refresh rate for the specified screen. On HTML5, [method screen_get_refresh_rate] will always return [code]-1.0[/code] as there is no way to retrieve the refresh rate on that platform. + To fallback to a default refresh rate if the method fails, try: + [codeblock] + var refresh_rate = DisplayServer.screen_get_refresh_rate() + if refresh_rate < 0: + refresh_rate = 60.0 + [/codeblock] diff --git a/servers/display_server.h b/servers/display_server.h index 19bb111094..bd38f28f17 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -175,7 +175,7 @@ public: SCREEN_OF_MAIN_WINDOW = -1 }; - const float SCREEN_REFRESH_RATE_FALLBACK = 60.0; // Returned by screen_get_refresh_rate if the method fails. Most screens are 60hz as of 2022. + const float SCREEN_REFRESH_RATE_FALLBACK = -1.0; // Returned by screen_get_refresh_rate if the method fails. virtual int get_screen_count() const = 0; virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const = 0; -- cgit v1.2.3