greggman / twgl.js

A Tiny WebGL helper Library
http://twgljs.org
MIT License
2.61k stars 258 forks source link

TEXTURE_2D_ARRAY not supported in setTextureFromArray #141

Closed Zaitsev closed 4 years ago

Zaitsev commented 4 years ago

When creating TEXTURE_2D_ARRAY textures with createTextures and src is TypedArray instance, for ex:

          u_y_data: {
            target        : gl.TEXTURE_2D_ARRAY,
            src           : y_data_tex_f,  // Typed array like Uint16Array
            depth         : Layers,
            height        : 1,
            width         : Width,
          },

I've got WebGL:INVALID_ENUM: texImage2D: invalid texture target I found a workaround : patch function setTextureFromArray(gl, tex, src, options)

  } else if (target === gl.TEXTURE_3D || target === gl.TEXTURE_2D_ARRAY) {
    gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
  } else {

I'm not sure I did it right....

greggman commented 4 years ago

Thanks. I think that's correct

https://github.com/greggman/twgl.js/commit/6450935a8d10b9fc7790c9d68f70e86f57e53f1f