From 6718cd32a6244593ec7da295a86af0b2288dee89 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 19 Aug 2020 21:15:47 +0900 Subject: [PATCH] examples/contextlost: Skip Draw when the context lost happens Updates #1314 --- examples/contextlost/main.go | 7 +++++++ 1 file changed, 7 insertions(+) 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{}