From 57c8ce122b3702222803478a9e9aeb0e50d1f636 Mon Sep 17 00:00:00 2001 From: obigu <1794492+obigu@users.noreply.github.com> Date: Sat, 20 Apr 2024 14:20:56 +0200 Subject: [PATCH] Improve preferred FPS setting logic and documentation on iOS backend (#7382) * Generate MobiVM MetalANGLE backend * Generate updated MobiVM MetalANGLE backend (#7377) * Generate MobiVM MetalANGLE backend * feat: Add CHANGES for iOS AudioDevice --------- Co-authored-by: GitHub Action * Improved preferred FPS setting logic and coumentation on iOS backend * Generate MobiVM MetalANGLE backend --------- Co-authored-by: GitHub Action Co-authored-by: Berstanio --- .../gdx/backends/iosrobovm/IOSApplicationConfiguration.java | 4 ++-- .../src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java | 5 +++-- .../gdx/backends/iosrobovm/IOSApplicationConfiguration.java | 4 ++-- .../src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java b/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java index 300a12f0838..f0cb63b9e8d 100644 --- a/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java +++ b/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java @@ -36,8 +36,8 @@ public class IOSApplicationConfiguration { /** the multisample format, None is default * */ public MGLDrawableMultisample multisample = MGLDrawableMultisample.None; - /** preferred/max number of frames per second. Set to "0" to indicate max supported by screen (on standard OpenGL backend (non - * MetalANGLE) Apple has a 60fps cap on most devices). * */ + /** preferred/max number of frames per second. Set to "0" to indicate max supported by screen. Important: On standard OpenGL + * backend FPS is capped to 60. Make sure to use MetalANGLE to support higher FPS. * */ public int preferredFramesPerSecond = 0; /** whether to use the accelerometer, default true * */ diff --git a/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java b/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java index ad4765231c2..0f247f9ad77 100644 --- a/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java +++ b/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java @@ -150,10 +150,11 @@ public void draw (CGRect rect) { viewController.setView(view); viewController.setDelegate(viewDelegate); int preferredFps; + int maxSupportedFPS = (int)(UIScreen.getMainScreen().getMaximumFramesPerSecond()); if (config.preferredFramesPerSecond == 0) { - preferredFps = (int)(UIScreen.getMainScreen().getMaximumFramesPerSecond()); + preferredFps = maxSupportedFPS; } else { - preferredFps = config.preferredFramesPerSecond; + preferredFps = Math.min(config.preferredFramesPerSecond, maxSupportedFPS); } viewController.setPreferredFramesPerSecond(preferredFps); this.app = app; diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java index 2111d4f595c..0de031428fd 100644 --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java @@ -47,8 +47,8 @@ public class IOSApplicationConfiguration { /** the multisample format, None is default **/ public GLKViewDrawableMultisample multisample = GLKViewDrawableMultisample.None; - /** preferred/max number of frames per second. Set to "0" to indicate max supported by screen (on standard OpenGL backend (non - * MetalANGLE) Apple has a 60fps cap on most devices). **/ + /** preferred/max number of frames per second. Set to "0" to indicate max supported by screen. Important: On standard OpenGL + * backend FPS is capped to 60. Make sure to use MetalANGLE to support higher FPS. **/ public int preferredFramesPerSecond = 0; /** whether to use the accelerometer, default true **/ diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java index ef644bdb002..dd9967f97fc 100644 --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java @@ -145,10 +145,11 @@ public void draw (CGRect rect) { viewController.setDelegate(viewDelegate); int preferredFps; + int maxSupportedFPS = (int)(UIScreen.getMainScreen().getMaximumFramesPerSecond()); if (config.preferredFramesPerSecond == 0) { - preferredFps = (int)(UIScreen.getMainScreen().getMaximumFramesPerSecond()); + preferredFps = maxSupportedFPS; } else { - preferredFps = config.preferredFramesPerSecond; + preferredFps = Math.min(config.preferredFramesPerSecond, maxSupportedFPS); } viewController.setPreferredFramesPerSecond(preferredFps);