greggman / twgl.js

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

resizeTexture missed gl.TEXTURE_3D gl.TEXTURE_2D_ARRAY #148

Closed Zaitsev closed 4 years ago

Zaitsev commented 4 years ago

Should it be like this?

function resizeTexture(gl, tex, options, width, height,depth) {
depth = depth || options.depth;
. . .
if (target === gl.TEXTURE_CUBE_MAP) {
    for (var ii = 0; ii < 6; ++ii) {
      gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + ii, level, internalFormat, width, height, 0, format, type, null);
    }
  }else if (target === gl.TEXTURE_3D || target === gl.TEXTURE_2D_ARRAY) {
      gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, null)
  else {
    gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, null);
  }

also it would be nice to extract options from texture itself if it possible and options is undefined|null

greggman commented 4 years ago

https://github.com/greggman/twgl.js/commit/4acd2c99277e3337d8a06db1a60d25e11cadc259