mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
Refactoring: Remove postUpdate
This commit is contained in:
parent
e2f528d206
commit
8788c8439f
@ -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
8
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()
|
||||
|
Loading…
Reference in New Issue
Block a user