mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
restorable: Ignore the error when restoring failed due to being not ready
(driver.Graphics).BeginFrame tries to restore the images, but the context might be lost at that time yet. If the attempt to restore the context because the driver is not ready, return silently. Fixes #1133
This commit is contained in:
parent
e16a4cd85c
commit
7b77164710
@ -15,6 +15,8 @@
|
||||
package driver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/internal/thread"
|
||||
)
|
||||
@ -37,6 +39,9 @@ type Graphics interface {
|
||||
MaxImageSize() int
|
||||
}
|
||||
|
||||
// GraphicsNotReady represents that the graphics driver is not ready for recovering from the context lost.
|
||||
var GraphicsNotReady = errors.New("graphics not ready")
|
||||
|
||||
type Image interface {
|
||||
Dispose()
|
||||
IsInvalidated() bool
|
||||
|
@ -212,7 +212,7 @@ func (c *context) reset() error {
|
||||
c.gl = js.Value{}
|
||||
c.ensureGL()
|
||||
if c.gl.Call("isContextLost").Bool() {
|
||||
return fmt.Errorf("opengl: the context is lost")
|
||||
return driver.GraphicsNotReady
|
||||
}
|
||||
gl := c.gl
|
||||
gl.Call("enable", blend)
|
||||
|
@ -17,6 +17,7 @@ package restorable
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
||||
)
|
||||
|
||||
@ -90,7 +91,11 @@ func RestoreIfNeeded() error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := graphicscommand.ResetGraphicsDriverState(); err != nil {
|
||||
err := graphicscommand.ResetGraphicsDriverState()
|
||||
if err == driver.GraphicsNotReady {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return theImages.restore()
|
||||
|
Loading…
Reference in New Issue
Block a user