diff --git a/examples/contextlost/main.go b/examples/contextlost/main.go index e8b799542..34d191b13 100644 --- a/examples/contextlost/main.go +++ b/examples/contextlost/main.go @@ -102,6 +102,13 @@ func (g *Game) Update(screen *ebiten.Image) error { } func (g *Game) Draw(screen *ebiten.Image) { + if g.lost { + // When the context is lost, skip rendering. Usually this logic should not be required, but when the + // context lost happens by the API explicitly, Draw can be called even after the data in GPU is + // disappered. + return + } + w, h := gophersImage.Size() op := &ebiten.DrawImageOptions{}