Refactoring: Remove postUpdate

This commit is contained in:
Hajime Hoshi 2016-02-28 00:11:27 +09:00
parent e2f528d206
commit 8788c8439f
2 changed files with 3 additions and 10 deletions

View File

@ -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)

8
run.go
View File

@ -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()