Skip to content

Commit

Permalink
Demo: disable vsync to reduce input lag
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Jan 11, 2024
1 parent 1baf137 commit 13050f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ config_version=5
config/name="Dear ImGui for Godot Demo"
run/main_scene="res://data/demo.tscn"
config/features=PackedStringArray("4.2", "C#")
run/max_fps=60
config/icon="res://data/icon.svg"

[autoload]
Expand All @@ -26,6 +27,7 @@ window/size/viewport_height=720
window/subwindows/embed_subwindows=false
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
window/vsync/vsync_mode=0

[dotnet]

Expand Down
6 changes: 6 additions & 0 deletions src/MyNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public override void _Ready()
{
_window = GetWindow();
GetNode<Button>("../Button1").Pressed += OnButton1Pressed;

if (DisplayServer.WindowGetVsyncMode() == DisplayServer.VSyncMode.Disabled)
{
int refreshRate = (int)DisplayServer.ScreenGetRefreshRate();
Engine.MaxFps = refreshRate > 0 ? refreshRate : 60;
}
}

public override void _Process(double delta)
Expand Down

0 comments on commit 13050f6

Please sign in to comment.