Browse Source

Merge pull request #7870 from sebavan/master

Fix video texture upload
David Catuhe 5 năm trước cách đây
mục cha
commit
c16dcb8f49
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      src/Engines/Extensions/engine.videoTexture.ts

+ 4 - 0
src/Engines/Extensions/engine.videoTexture.ts

@@ -26,6 +26,9 @@ ThinEngine.prototype.updateVideoTexture = function(texture: Nullable<InternalTex
     try {
         // Testing video texture support
         if (this._videoTextureSupported === undefined) {
+            // clear old errors just in case.
+            this._gl.getError();
+
             this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
 
             if (this._gl.getError() !== 0) {
@@ -50,6 +53,7 @@ ThinEngine.prototype.updateVideoTexture = function(texture: Nullable<InternalTex
                 texture._workingCanvas.height = texture.height;
             }
 
+            texture._workingContext!.clearRect(0, 0, texture.width, texture.height);
             texture._workingContext!.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
 
             this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);