mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
examples/contextlost: Use gopherwasm
This commit is contained in:
parent
980055e07a
commit
cc748f15e4
@ -24,7 +24,7 @@ import (
|
||||
"log"
|
||||
"math"
|
||||
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
"github.com/hajimehoshi/gopherwasm/js"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
@ -44,16 +44,16 @@ var (
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeySpace) && js.Global != nil {
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeySpace) && js.Global != js.Null {
|
||||
doc := js.Global.Get("document")
|
||||
canvas := doc.Call("getElementsByTagName", "canvas").Index(0)
|
||||
context := canvas.Call("getContext", "webgl")
|
||||
if context == nil {
|
||||
if context == js.Null {
|
||||
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 {
|
||||
if ext := context.Call("getExtension", "WEBGL_lose_context"); ext != js.Null {
|
||||
ext.Call("loseContext")
|
||||
fmt.Println("Context Lost!")
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user