internal/ui: use a more precise timer for Windows

When SetScreenClearedEveryFalse(false) and SetVsyncEnabled(false),
Draw might not be called as often as expected on Windows due to its
timer precision. This change improves the situation.

Updates #2889
This commit is contained in:
Hajime Hoshi 2024-01-28 14:15:20 +09:00
parent d8af23b437
commit 7e4cdf5211

View File

@ -242,3 +242,13 @@ func (u *UserInterface) skipTaskbar() error {
return nil
}
func init() {
if microsoftgdk.IsXbox() {
// TimeBeginPeriod might not be defined in Xbox.
return
}
// Use a better timer resolution (golang/go#44343).
// TODO: This might not be necessary from Go 1.23.
windows.TimeBeginPeriod(1)
}