examples/contextlost: Bug fix: Failed to compile with Go 1.12

This commit is contained in:
Hajime Hoshi 2020-08-16 23:05:33 +09:00
parent 5e1f263d6d
commit 2acb604260

View File

@ -56,7 +56,7 @@ func (g *Game) 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.IsNull() {
if !ext.Truthy() {
fmt.Println("Fail to force context lost. Edge might not support the extension yet.")
return
}
@ -83,9 +83,9 @@ func (g *Game) Update(screen *ebiten.Image) error {
doc := js.Global().Get("document")
canvas := doc.Call("getElementsByTagName", "canvas").Index(0)
context := canvas.Call("getContext", "webgl2")
if context.IsNull() {
if !context.Truthy() {
context = canvas.Call("getContext", "webgl")
if context.IsNull() {
if !context.Truthy() {
context = canvas.Call("getContext", "experimental-webgl")
}
}