examples/contextlost: Skip Draw when the context lost happens

Updates #1314
This commit is contained in:
Hajime Hoshi 2020-08-19 21:15:47 +09:00
parent 7329880f40
commit 6718cd32a6

View File

@ -102,6 +102,13 @@ func (g *Game) Update(screen *ebiten.Image) error {
} }
func (g *Game) Draw(screen *ebiten.Image) { 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() w, h := gophersImage.Size()
op := &ebiten.DrawImageOptions{} op := &ebiten.DrawImageOptions{}