[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] Uint8ClampedArray can not be used with WebGL



I forgot why but currently calls to texImage2D check based on `type` that the corresponding ArrayBuffer type.

for type `UNSIGNED_BYTE` currently `Uint8Array` is required which means I get an error if I pass in a `Uint8ClampedArray`

gl = document.createElement("canvas").getContext("webgl");
gl.bindTexture(gl.TEXTURE_2D, gl.createTexture());
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 
         new Uint8ClampedArray(4));

WebGL: INVALID_OPERATION: texImage2D: type UNSIGNED_BYTE but ArrayBufferView not Uint8Array


Should that change? Should it change for WebGL2 if not WebGL1?

How about SharedArrays?