Dynamically set max fps
This commit is contained in:
@@ -25,6 +25,7 @@ public partial class IdeWindow : Control
|
||||
GD.Print("IdeWindow _Ready called");
|
||||
ResourceLoader.LoadThreadedRequest(SlnPickerScenePath);
|
||||
ResourceLoader.LoadThreadedRequest(IdeRootScenePath);
|
||||
SetMaxFpsForMonitor();
|
||||
// Godot doesn't have an easy equivalent of launchsettings.json, and we also want this to be set for published builds
|
||||
Environment.SetEnvironmentVariable("MSBUILD_PARSE_SLN_WITH_SOLUTIONPERSISTENCE", "1");
|
||||
SharpIdeMsbuildLocator.Register();
|
||||
@@ -45,6 +46,16 @@ public partial class IdeWindow : Control
|
||||
// GC.Collect();
|
||||
// PrintOrphanNodes();
|
||||
}
|
||||
|
||||
public void SetMaxFpsForMonitor()
|
||||
{
|
||||
// Keep max fps below display refresh rate for gsync, to avoid input lag. Currently does not handle window moving across monitors
|
||||
var refreshRate = (int)DisplayServer.ScreenGetRefreshRate();
|
||||
var refreshRateBelowCap = refreshRate - (refreshRate * refreshRate) / 3600.0;
|
||||
var refreshRateBelowCapRoundedDownToInt = (int)refreshRateBelowCap;
|
||||
GD.Print($"Detected display refresh rate: {refreshRate} Hz, setting max FPS to {refreshRateBelowCapRoundedDownToInt} Hz");
|
||||
Engine.MaxFps = refreshRateBelowCapRoundedDownToInt;
|
||||
}
|
||||
|
||||
public void PickSolution(bool fullscreen = false)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ config_version=5
|
||||
config/name="SharpIDE"
|
||||
run/main_scene="uid://b70jhun5a4las"
|
||||
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
|
||||
run/max_fps=157
|
||||
run/max_fps=60
|
||||
boot_splash/fullsize=false
|
||||
boot_splash/image="uid://c58xmy2syss8s"
|
||||
config/icon="uid://tpjfx7mo6cwj"
|
||||
|
||||
Reference in New Issue
Block a user