Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Disable V-Sync and use optimized FPS limit #153

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions main/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ func _ready():
OS.window_fullscreen = Settings.fullscreen
go_to_main_menu()

var max_refresh_rate = 60.0
for screen in OS.get_screen_count():
max_refresh_rate = max(max_refresh_rate, OS.get_screen_refresh_rate(screen))

# Cap framerate to (roughly) the refresh rate of the monitor with the highest refresh rate.
# This allows for smooth operation while reducing power usage when V-Sync is disabled.
Engine.target_fps = max_refresh_rate + 1.0
print("Limiting FPS to %d." % Engine.target_fps)


func go_to_main_menu():
var menu = ResourceLoader.load("res://menu/menu.tscn")
Expand Down
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Settings="*res://menu/settings.gd"
window/size/width=1920
window/size/height=1080
window/size/fullscreen=true
window/vsync/use_vsync=false
window/stretch/mode="2d"
window/stretch/aspect="expand"

Expand Down