From 681e9a743afb8a1c3fc5430a69fcccc66e11e1bd Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Tue, 21 Nov 2023 16:55:10 +0000 Subject: [PATCH] Fix for video textures (#5836) --- src/platform/graphics/webgl/webgl-texture.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/platform/graphics/webgl/webgl-texture.js b/src/platform/graphics/webgl/webgl-texture.js index 809bcc2b40d..52e4a4e9198 100644 --- a/src/platform/graphics/webgl/webgl-texture.js +++ b/src/platform/graphics/webgl/webgl-texture.js @@ -512,10 +512,13 @@ class WebglTexture { } } + const w = mipObject.width || mipObject.videoWidth; + const h = mipObject.height || mipObject.videoHeight; + // Upload the image, canvas or video device.setUnpackFlipY(texture._flipY); device.setUnpackPremultiplyAlpha(texture._premultiplyAlpha); - if (this._glCreated && mipObject.width === texture._width && mipObject.height === texture._height) { + if (this._glCreated && texture._width === w && texture._height === h) { gl.texSubImage2D( gl.TEXTURE_2D, mipLevel, @@ -533,6 +536,11 @@ class WebglTexture { this._glPixelType, mipObject ); + + if (mipLevel === 0) { + texture._width = w; + texture._height = h; + } } } else { // Upload the byte array