getInternalFormat method

dynamic getInternalFormat(
  1. dynamic internalFormatName,
  2. dynamic glFormat,
  3. dynamic glType,
  4. dynamic encoding, [
  5. bool isVideoTexture = false,
])

Implementation

getInternalFormat(internalFormatName, glFormat, glType, encoding, [bool isVideoTexture = false]) {
  if (isWebGL2 == false) return glFormat;

  if (internalFormatName != null) {
    // if ( gl[ internalFormatName ] != null ) return gl[ internalFormatName ];

    print('three.WebGLRenderer: Attempt to use non-existing WebGL internal format $internalFormatName');
  }

  var internalFormat = glFormat;

  if (glFormat == gl.RED) {
    if (glType == gl.FLOAT) internalFormat = gl.R32F;
    if (glType == gl.HALF_FLOAT) internalFormat = gl.R16F;
    if (glType == gl.UNSIGNED_BYTE) internalFormat = gl.R8;
  }

  if (glFormat == _gl.RG) {
    if (glType == _gl.FLOAT) internalFormat = _gl.RG32F;
    if (glType == _gl.HALF_FLOAT) internalFormat = _gl.RG16F;
    if (glType == _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;
  }

  if (glFormat == _gl.RGB) {
    if (glType == _gl.FLOAT) internalFormat = _gl.RGB32F;
    if (glType == _gl.HALF_FLOAT) internalFormat = _gl.RGB16F;
    if (glType == _gl.UNSIGNED_BYTE) internalFormat = _gl.RGB8;
  }

  if (glFormat == gl.RGBA) {
    if (glType == gl.FLOAT) internalFormat = gl.RGBA32F;
    if (glType == gl.HALF_FLOAT) internalFormat = gl.RGBA16F;
    if (glType == gl.UNSIGNED_BYTE) {
      internalFormat = (encoding == sRGBEncoding && isVideoTexture == false) ? gl.SRGB8_ALPHA8 : gl.RGBA8;
    }
    if (glType == _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
    if (glType == _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
  }

  if (internalFormat == gl.R16F ||
      internalFormat == gl.R32F ||
      internalFormat == _gl.RG16F ||
      internalFormat == _gl.RG32F ||
      internalFormat == gl.RGBA16F ||
      internalFormat == gl.RGBA32F) {
    extensions.get('EXT_color_buffer_float');
  }

  return internalFormat;
}