bindTexture method

dynamic bindTexture(
  1. dynamic webglType,
  2. dynamic webglTexture
)

Implementation

bindTexture(webglType, webglTexture) {
  if (currentTextureSlot == null) {
    activeTexture(null);
  }

  var boundTexture = currentBoundTextures[currentTextureSlot];

  // print("WebGLState.boundTexture boundTexture: ${boundTexture} currentTextureSlot: ${currentTextureSlot} ");

  if (boundTexture == null) {
    boundTexture = BoundTexture(null, null);
    currentBoundTextures[currentTextureSlot!] = boundTexture;
  }

  // print(" boundTexture.type != webglType: ${boundTexture.type != webglType} ");
  // print("boundTexture.texture != webglTexture: ${boundTexture.texture != webglTexture} ");

  // todo debug
  // 当注释掉下面的if条件前 在web下工作正常 手机app端 不正常 例如:阴影渲染 第一次正确 第二次失败
  // 当然绑定纹理失效?
  // 灵异bug
  // 暂时先注释掉if条件  原因不明
  // if (boundTexture.type != webglType || boundTexture.texture != webglTexture) {

  gl.bindTexture(webglType, webglTexture ?? emptyTextures[webglType]);

  boundTexture.type = webglType;
  boundTexture.texture = webglTexture;
  // }
}