mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-03 22:44: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
|
||||
// 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user