diff options
author | Zach Coleman <ztc0611@gmail.com> | 2022-10-29 23:31:13 -0400 |
---|---|---|
committer | Zach Coleman <ztc0611@gmail.com> | 2022-10-31 09:33:39 -0400 |
commit | 601c42be66c29cac2a546562217afad99a3df581 (patch) | |
tree | a0752f112fab61f884bfb991be9cacbf932450bf | |
parent | 6a9317c9fc8f943586a8cbe6d0d6be6e356add28 (diff) |
Add ProMotion Support to iOS Exports
-rw-r--r-- | doc/classes/ProjectSettings.xml | 3 | ||||
-rw-r--r-- | main/main.cpp | 1 | ||||
-rw-r--r-- | misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist | 1 | ||||
-rw-r--r-- | platform/ios/godot_view.mm | 13 |
4 files changed, 12 insertions, 6 deletions
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 925d4ec7c4..7ac88377fb 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -565,6 +565,9 @@ The default screen orientation to use on mobile devices. See [enum DisplayServer.ScreenOrientation] for possible values. [b]Note:[/b] When set to a portrait orientation, this project setting does not flip the project resolution's width and height automatically. Instead, you have to set [member display/window/size/viewport_width] and [member display/window/size/viewport_height] accordingly. </member> + <member name="display/window/ios/allow_high_refresh_rate" type="bool" setter="" getter="" default="true"> + If [code]true[/code], iOS devices that support high refresh rate/"ProMotion" will be allowed to render at up to 120 frames per second. + </member> <member name="display/window/ios/hide_home_indicator" type="bool" setter="" getter="" default="true"> If [code]true[/code], the home indicator is hidden automatically. This only affects iOS devices without a physical home button. </member> diff --git a/main/main.cpp b/main/main.cpp index a5196da939..17b2e392bd 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1820,6 +1820,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph PROPERTY_HINT_RANGE, "0,33200,1,or_greater")); // No negative numbers + GLOBAL_DEF("display/window/ios/allow_high_refresh_rate", true); GLOBAL_DEF("display/window/ios/hide_home_indicator", true); GLOBAL_DEF("display/window/ios/hide_status_bar", true); GLOBAL_DEF("display/window/ios/suppress_ui_gesture", true); diff --git a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist index e9d22f6b4d..b88dfae5b2 100644 --- a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist +++ b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist @@ -58,5 +58,6 @@ </array> $additional_plist_content $plist_launch_screen_name + <key>CADisableMinimumFrameDurationOnPhone</key><true/> </dict> </plist> diff --git a/platform/ios/godot_view.mm b/platform/ios/godot_view.mm index ff90c05b1d..4537dc2985 100644 --- a/platform/ios/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -30,6 +30,7 @@ #import "godot_view.h" +#include "core/config/project_settings.h" #include "core/os/keyboard.h" #include "core/string/ustring.h" #import "display_layer.h" @@ -205,16 +206,16 @@ static const float earth_gravity = 9.80665; if (self.useCADisplayLink) { self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)]; - // Approximate frame rate - // assumes device refreshes at 60 fps - int displayFPS = (NSInteger)(1.0 / self.renderingInterval); - - self.displayLink.preferredFramesPerSecond = displayFPS; + if (GLOBAL_GET("display/window/ios/allow_high_refresh_rate")) { + self.displayLink.preferredFramesPerSecond = 120; + } else { + self.displayLink.preferredFramesPerSecond = 60; + } // Setup DisplayLink in main thread [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } else { - self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:self.renderingInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 60) target:self selector:@selector(drawView) userInfo:nil repeats:YES]; } } |