0

I have a problem I just discovered in chrome and used to work. Uploaded video textures to webgl from screen capture MediaStream is failing with a diagonal green line and the picture is diagonal.

If I choose to share a browser tab its a correct picture and format.

I'm not sure if it's a problem with the buffer array setup or something else. It is ok with Webcam MediaStream input. I had a feature to overlay webcam in the foreground with screen capture as the background texture but it is broken now.

The jsfiddle is here

https://jsfiddle.net/danrossi303/txpqrsgv/2/

The texture upload format is

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, screenVideo);

enter image description here

Dan Rossi
  • 51
  • 1
  • 4

1 Answers1

0

I figured out screen capture supplies odd dimensions. And according to Kronos the texture will produce a fault if its not even divisible by 4. It started working magically, but I came up with a simple method to format the dimensions using bitwise modulus.

https://jsfiddle.net/danrossi303/txpqrsgv/12/

function formatTextureSize(value) {
    return value + (value & (4 - 1));
}
Dan Rossi
  • 51
  • 1
  • 4