bindFramebuffer method

dynamic bindFramebuffer(
  1. dynamic target,
  2. dynamic framebuffer
)

Implementation

bindFramebuffer(target, framebuffer) {
  if (framebuffer == null && xrFramebuffer != null) {
    framebuffer = xrFramebuffer;
  } // use active XR framebuffer if available

  if (currentBoundFramebuffers[target] != framebuffer) {
    gl.bindFramebuffer(target, framebuffer);

    currentBoundFramebuffers[target] = framebuffer;

    if (isWebGL2) {
      // gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER

      if (target == gl.DRAW_FRAMEBUFFER) {
        currentBoundFramebuffers[gl.FRAMEBUFFER] = framebuffer;
      }

      if (target == gl.FRAMEBUFFER) {
        currentBoundFramebuffers[gl.DRAW_FRAMEBUFFER] = framebuffer;
      }
    }

    return true;
  }

  return false;
}