mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app,internal/gl: [wasm] fix context lost
Before that change, Gio could crash when the WebGL context was lost unexpectedly. Now, Gio will properly handle such situation and recreate the buffers/resources when context is restored and will wait until context is recovered. Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
+10
-1
@@ -299,7 +299,12 @@ func (f *Functions) BufferSubData(target Enum, offset int, src []byte) {
|
||||
f._bufferSubData.Invoke(int(target), offset, f.byteArrayOf(src))
|
||||
}
|
||||
func (f *Functions) CheckFramebufferStatus(target Enum) Enum {
|
||||
return Enum(f._checkFramebufferStatus.Invoke(int(target)).Int())
|
||||
status := Enum(f._checkFramebufferStatus.Invoke(int(target)).Int())
|
||||
if status != FRAMEBUFFER_COMPLETE && f.Ctx.Call("isContextLost").Bool() {
|
||||
// If the context is lost, we say that everything is fine. That saves internal/opengl/opengl.go from panic.
|
||||
return FRAMEBUFFER_COMPLETE
|
||||
}
|
||||
return status
|
||||
}
|
||||
func (f *Functions) Clear(mask Enum) {
|
||||
f._clear.Invoke(int(mask))
|
||||
@@ -633,6 +638,10 @@ func paramVal(v js.Value) int {
|
||||
}
|
||||
case js.TypeNumber:
|
||||
return v.Int()
|
||||
case js.TypeUndefined:
|
||||
return 0
|
||||
case js.TypeNull:
|
||||
return 0
|
||||
default:
|
||||
panic("unknown parameter type")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user