diff --git a/graphicscontext.go b/graphicscontext.go index 88ebcbce1..62fa7a0b3 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -39,15 +39,10 @@ func (c *graphicsContext) update(f func(*Image) error) error { if err := f(c.screen); err != nil { return err } - return nil -} - -func (c *graphicsContext) postUpdate() error { // TODO: In WebGL, we don't need to clear the image here. if err := c.defaultRenderTarget.Clear(); err != nil { return err } - scale := float64(c.screenScale) options := &DrawImageOptions{} options.GeoM.Scale(scale, scale) diff --git a/run.go b/run.go index ccc0cd3c7..e7c76fee1 100644 --- a/run.go +++ b/run.go @@ -96,15 +96,13 @@ func Run(f func(*Image) error, width, height, scale int, title string) error { if int64(5*time.Second/60) < now-gameTime { gameTime = now } - for gameTime < now { - gameTime += int64(time.Second / 60) + c := int((now - gameTime) * 60 / int64(time.Second)) + for i := 0; i < c; i++ { if err := graphicsContext.update(f); err != nil { return err } } - if err := graphicsContext.postUpdate(); err != nil { - return err - } + gameTime += int64(c) * int64(time.Second/60) // Note that the current bound framebuffer must be the default one (0). ui.SwapBuffers()