function setTextureFilteringForSize(gl, tex, options, width, height, internalFormat) {
  options = options || defaults.textureOptions;
  internalFormat = internalFormat || RGBA;
  var target = options.target || TEXTURE_2D;
  width = width || options.width;
  height = height || options.height;
  gl.bindTexture(target, tex);

  if (canGenerateMipmap(gl, width, height, internalFormat)) {
    gl.generateMipmap(target);
  } else {
    var filtering = canFilter(internalFormat) ? LINEAR : NEAREST;
    gl.texParameteri(target, TEXTURE_MIN_FILTER, filtering);
    gl.texParameteri(target, TEXTURE_MAG_FILTER, filtering);
    gl.texParameteri(target, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
    gl.texParameteri(target, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
  }
}
Sets filtering or generates mips for texture based on width or height
If width or height is not passed in uses `options.width` and//or `options.height`

@param {WebGLRenderingContext} gl the WebGLRenderingContext
@param {WebGLTexture} tex the WebGLTexture to set parameters for
@param {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
  This is often the same options you passed in when you created the texture.
@param {number} [width] width of texture
@param {number} [height] height of texture
@param {number} [internalFormat] The internalFormat parameter from texImage2D etc..
@memberOf module:twgl/textures