graphics: Bug fix: Errors should be returned after checking the history

This commit is contained in:
Hajime Hoshi 2016-07-24 00:02:45 +09:00
parent 806eb44258
commit b146e5d1b4

View File

@ -92,15 +92,15 @@ func (p *pixels) hasHistoryWith(target *Image) bool {
} }
func (p *pixels) resetHistoryIfNeeded(image *graphics.Image, target *Image, context *opengl.Context) error { func (p *pixels) resetHistoryIfNeeded(image *graphics.Image, target *Image, context *opengl.Context) error {
if context == nil {
return errors.New("ebiten: OpenGL context is missing: before running the main loop, it is forbidden to manipulate images that is used as a drawing source once.")
}
if p.drawImageHistory == nil { if p.drawImageHistory == nil {
return nil return nil
} }
if !p.hasHistoryWith(target) { if !p.hasHistoryWith(target) {
return nil return nil
} }
if context == nil {
return errors.New("ebiten: OpenGL context is missing: before running the main loop, it is forbidden to manipulate images that is used as a drawing source once.")
}
var err error var err error
p.basePixels, err = image.Pixels(context) p.basePixels, err = image.Pixels(context)
if err != nil { if err != nil {