mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
parent
a92cc0f4b3
commit
569639d485
@ -48,8 +48,17 @@ func update(screen *ebiten.Image) error {
|
|||||||
doc := js.Global.Get("document")
|
doc := js.Global.Get("document")
|
||||||
canvas := doc.Call("getElementsByTagName", "canvas").Index(0)
|
canvas := doc.Call("getElementsByTagName", "canvas").Index(0)
|
||||||
context := canvas.Call("getContext", "webgl")
|
context := canvas.Call("getContext", "webgl")
|
||||||
context.Call("getExtension", "WEBGL_lose_context").Call("loseContext")
|
if context == nil {
|
||||||
fmt.Println("Context Lost!")
|
context = canvas.Call("getContext", "experimental-webgl")
|
||||||
|
}
|
||||||
|
// Edge might not support the extension. See
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context
|
||||||
|
if ext := context.Call("getExtension", "WEBGL_lose_context"); ext != nil {
|
||||||
|
ext.Call("loseContext")
|
||||||
|
fmt.Println("Context Lost!")
|
||||||
|
} else {
|
||||||
|
fmt.Println("Fail to force context lost. Edge might not support the extension yet.")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user