mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphics: Refactoring: no needed returning values
This commit is contained in:
parent
d220e300ab
commit
9d4849e351
@ -120,26 +120,19 @@ func (c *graphicsContext) initializeIfNeeded(context *opengl.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawWithFittingScale(dst *Image, src *Image) error {
|
func drawWithFittingScale(dst *Image, src *Image) {
|
||||||
wd, hd := dst.Size()
|
wd, hd := dst.Size()
|
||||||
ws, hs := src.Size()
|
ws, hs := src.Size()
|
||||||
sw := float64(wd) / float64(ws)
|
sw := float64(wd) / float64(ws)
|
||||||
sh := float64(hd) / float64(hs)
|
sh := float64(hd) / float64(hs)
|
||||||
op := &DrawImageOptions{}
|
op := &DrawImageOptions{}
|
||||||
op.GeoM.Scale(sw, sh)
|
op.GeoM.Scale(sw, sh)
|
||||||
if err := dst.DrawImage(src, op); err != nil {
|
_ = dst.DrawImage(src, op)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *graphicsContext) drawToDefaultRenderTarget(context *opengl.Context) error {
|
func (c *graphicsContext) drawToDefaultRenderTarget(context *opengl.Context) error {
|
||||||
if err := c.screen.Clear(); err != nil {
|
_ = c.screen.Clear()
|
||||||
return err
|
drawWithFittingScale(c.screen, c.offscreen2)
|
||||||
}
|
|
||||||
if err := drawWithFittingScale(c.screen, c.offscreen2); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := graphics.FlushCommands(context); err != nil {
|
if err := graphics.FlushCommands(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -150,6 +143,7 @@ func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int
|
|||||||
if err := c.initializeIfNeeded(context); err != nil {
|
if err := c.initializeIfNeeded(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// TODO: Is it OK to restore images here? The images can be in 'stale' state after c.f().
|
||||||
if err := restorable.ResolveStalePixels(context); err != nil {
|
if err := restorable.ResolveStalePixels(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -161,9 +155,7 @@ func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if 0 < updateCount {
|
if 0 < updateCount {
|
||||||
if err := drawWithFittingScale(c.offscreen2, c.offscreen); err != nil {
|
drawWithFittingScale(c.offscreen2, c.offscreen)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err := c.drawToDefaultRenderTarget(context); err != nil {
|
if err := c.drawToDefaultRenderTarget(context); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user