diff --git a/examples/contextlost/main.go b/examples/contextlost/main.go index 2f15a72f6..2c252def3 100644 --- a/examples/contextlost/main.go +++ b/examples/contextlost/main.go @@ -53,7 +53,7 @@ func loseAndRestoreContext(context js.Value) { // Edge might not support the extension. See // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context ext := context.Call("getExtension", "WEBGL_lose_context") - if ext == js.Null() { + if ext.IsNull() { fmt.Println("Fail to force context lost. Edge might not support the extension yet.") return } @@ -79,11 +79,13 @@ func update(screen *ebiten.Image) error { if inpututil.IsKeyJustPressed(ebiten.KeySpace) { doc := js.Global().Get("document") canvas := doc.Call("getElementsByTagName", "canvas").Index(0) - context := canvas.Call("getContext", "webgl") - if context == js.Null() { - context = canvas.Call("getContext", "experimental-webgl") + context := canvas.Call("getContext", "webgl2") + if context.IsNull() { + context = canvas.Call("getContext", "webgl") + if context.IsNull() { + context = canvas.Call("getContext", "experimental-webgl") + } } - loseAndRestoreContext(context) return nil }