internal/ui: remove an error returning value from Game.Draw

This commit is contained in:
Hajime Hoshi 2022-04-01 19:10:10 +09:00
parent 3ae4e873e6
commit 8e40b2562e
2 changed files with 3 additions and 6 deletions

View File

@ -73,7 +73,7 @@ func (c *gameForUI) Update() error {
return c.game.Update()
}
func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, clearScreenEveryFrame, filterEnabled bool) error {
func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, clearScreenEveryFrame, filterEnabled bool) {
c.offscreen.image.SetVolatile(clearScreenEveryFrame)
// Even though updateCount == 0, the offscreen is cleared and Draw is called.
@ -119,5 +119,4 @@ func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsCle
op.Filter = FilterLinear
}
c.screen.DrawImage(c.offscreen, op)
return nil
}

View File

@ -32,7 +32,7 @@ const DefaultTPS = 60
type Game interface {
Layout(outsideWidth, outsideHeight float64, deviceScaleFactor float64) (int, int)
Update() error
Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, screenClearedEveryFrame, filterEnabled bool) error
Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, screenClearedEveryFrame, filterEnabled bool)
}
type context struct {
@ -121,9 +121,7 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
// Draw the game.
screenScale, offsetX, offsetY := c.screenScaleAndOffsets(deviceScaleFactor)
if err := c.game.Draw(screenScale, offsetX, offsetY, graphicsDriver.NeedsClearingScreen(), graphicsDriver.FramebufferYDirection(), theGlobalState.isScreenClearedEveryFrame(), theGlobalState.isScreenFilterEnabled()); err != nil {
return err
}
c.game.Draw(screenScale, offsetX, offsetY, graphicsDriver.NeedsClearingScreen(), graphicsDriver.FramebufferYDirection(), theGlobalState.isScreenClearedEveryFrame(), theGlobalState.isScreenFilterEnabled())
// All the vertices data are consumed at the end of the frame, and the data backend can be
// available after that. Until then, lock the vertices backend.