ui: less error adjustment is better

This commit is contained in:
Hajime Hoshi 2016-04-09 19:08:19 +09:00
parent e608837943
commit c2d1f99e7e

5
run.go
View File

@ -206,7 +206,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
// As t is not accurate 1/60[sec], errors are accumulated // As t is not accurate 1/60[sec], errors are accumulated
// (generally, errors are positive values). // (generally, errors are positive values).
// To make the FPS stable, set tt 1 if t is a little less than 1/60[sec]. // To make the FPS stable, set tt 1 if t is a little less than 1/60[sec].
if tt == 0 && (int64(time.Second)/FPS-int64(10*time.Millisecond)) < t { if tt == 0 && (int64(time.Second)/FPS-int64(5*time.Millisecond)) < t {
tt = 1 tt = 1
} }
for i := 0; i < tt; i++ { for i := 0; i < tt; i++ {
@ -221,8 +221,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
} }
} }
ui.CurrentUI().SwapBuffers() ui.CurrentUI().SwapBuffers()
d := int64(tt) * int64(time.Second) / FPS beforeForUpdate += int64(tt) * int64(time.Second) / FPS
beforeForUpdate += d
frames++ frames++
} }