mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-04 06:54:28 +01:00
example/contextlost: Bug fix: Compilie error on Go 1.14, Should use WebGL2
This commit is contained in:
parent
b09fe7157b
commit
231edfbd3f
@ -53,7 +53,7 @@ func loseAndRestoreContext(context js.Value) {
|
|||||||
// Edge might not support the extension. See
|
// Edge might not support the extension. See
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context
|
// https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context
|
||||||
ext := context.Call("getExtension", "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.")
|
fmt.Println("Fail to force context lost. Edge might not support the extension yet.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -79,11 +79,13 @@ func update(screen *ebiten.Image) error {
|
|||||||
if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
|
if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
|
||||||
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", "webgl2")
|
||||||
if context == js.Null() {
|
if context.IsNull() {
|
||||||
|
context = canvas.Call("getContext", "webgl")
|
||||||
|
if context.IsNull() {
|
||||||
context = canvas.Call("getContext", "experimental-webgl")
|
context = canvas.Call("getContext", "experimental-webgl")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
loseAndRestoreContext(context)
|
loseAndRestoreContext(context)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user