WebGL: use an ArrayBufferView of type Int16Array with texImage2D

100 Views Asked by At

I'm trying to use the texImage2d, my ArrayBufferView have a type Int16Array and when I'm using the texImage2D with type INT return me this error:

WebGL: INVALID_ENUM: texImage2D: invalid type

this is the declaration of my texImage2D:

this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture);

this.gl.texImage2D(
   this.gl.TEXTURE_2D,
   0,
   this.gl.LUMINANCE,
   imageH,
   imageW,
   0,
   this.gl.LUMINANCE,
   this.gl.INT,
   texture_array_buffer
);

If I use UNSIGNED_BYTE or UNSIGNED_INT I always have the same problem.

I need to use a BufferView of type Int16Array instead of Float32Array.

How can specify a type INT with this ArrayBufferView with Int16Array??

1

There are 1 best solutions below

0
LJᛃ On

LUMINANCE is a WebGL 1 unsized format and doesn't support any type other than UNSIGNED_BYTE. You need to use WebGL 2s R16I format and SHORT as datatype.