From 2926cd26b32638b7f8b4b39ec5bd83c910674f0e Mon Sep 17 00:00:00 2001 From: Nick Kastellanos Date: Sun, 29 May 2022 14:33:05 +0300 Subject: [PATCH] WebGL unbind Texture --- Wasm.Canvas/Canvas/WebGL/WebGLRenderingContext.cs | 3 ++- Wasm.Canvas/wwwroot/js/CanvasGLContext.6.0.0.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Wasm.Canvas/Canvas/WebGL/WebGLRenderingContext.cs b/Wasm.Canvas/Canvas/WebGL/WebGLRenderingContext.cs index 00d8e4c..8bf843f 100644 --- a/Wasm.Canvas/Canvas/WebGL/WebGLRenderingContext.cs +++ b/Wasm.Canvas/Canvas/WebGL/WebGLRenderingContext.cs @@ -248,7 +248,8 @@ public void PixelStore(WebGLPixelParameter pname, int param) public void BindTexture(WebGLTextureTarget target, WebGLTexture texture) { - Invoke("nkCanvasGLContext.BindTexture", (int)target, texture.Uid); + int uid = (texture != null) ? texture.Uid : -1; + Invoke("nkCanvasGLContext.BindTexture", (int)target, uid); } public void BindBuffer(WebGLBufferType type, WebGLBuffer buffer) diff --git a/Wasm.Canvas/wwwroot/js/CanvasGLContext.6.0.0.js b/Wasm.Canvas/wwwroot/js/CanvasGLContext.6.0.0.js index 21df161..c22b27e 100644 --- a/Wasm.Canvas/wwwroot/js/CanvasGLContext.6.0.0.js +++ b/Wasm.Canvas/wwwroot/js/CanvasGLContext.6.0.0.js @@ -685,7 +685,7 @@ window.nkCanvasGLContext = var gc = nkJSObject.GetObject(uid); var tg = Blazor.platform.readInt32Field(d, 0); var txuid = Blazor.platform.readInt32Field(d, 4); - var tx = nkJSObject.GetObject(txuid); + var tx = (txuid != -1) ? nkJSObject.GetObject(txuid) : null; gc.bindTexture(tg, tx); },