diff --git a/imageimpl.go b/imageimpl.go index f08488c58..b5173b221 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -223,6 +223,11 @@ func (i *imageImpl) flushPixelsIfNeeded(target *imageImpl, context *opengl.Conte if target.isDisposed() { return errors.New("ebiten: target is already disposed") } + if context == nil { + // context is null when this is not initialized yet. + i.pixels.MakeInconsistent() + return nil + } if err := i.pixels.FlushIfNeeded(target.image, context); err != nil { return err } diff --git a/internal/pixels/pixels.go b/internal/pixels/pixels.go index 1be0b3f97..dfe758b00 100644 --- a/internal/pixels/pixels.go +++ b/internal/pixels/pixels.go @@ -148,11 +148,6 @@ func (p *Pixels) FlushIfNeeded(target *graphics.Image, context *opengl.Context) if !p.hasHistoryWith(target) { return nil } - if context == nil { - // context is null when this is not initialized yet. - p.MakeInconsistent() - return nil - } p.inconsistent = false var err error p.basePixels, err = p.image.Pixels(context)