setupFrameBufferTexture method

void setupFrameBufferTexture(
  1. dynamic framebuffer,
  2. RenderTarget renderTarget,
  3. Texture texture,
  4. dynamic attachment,
  5. dynamic textureTarget,
)

Implementation

void setupFrameBufferTexture(framebuffer, RenderTarget renderTarget, Texture texture, attachment, textureTarget) {
  var glFormat = utils.convert(texture.format);
  var glType = utils.convert(texture.type);
  var glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);

  if (textureTarget == gl.TEXTURE_3D || textureTarget == gl.TEXTURE_2D_ARRAY) {
    state.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width.toInt(), renderTarget.height.toInt(),
        renderTarget.depth.toInt(), 0, glFormat, glType, null);
  } else {
    state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width.toInt(), renderTarget.height.toInt(), 0,
        glFormat, glType, null);
  }

  state.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
  // gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, textureTarget,
  //     properties.get(texture)["__webglTexture"], 0);

  if (useMultisampledRenderToTexture(renderTarget)) {
    multisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT(_gl.FRAMEBUFFER, attachment,
        textureTarget, properties.get(texture)["__webglTexture"], 0, getRenderTargetSamples(renderTarget));
  } else {
    _gl.framebufferTexture2D(
        _gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture)["__webglTexture"], 0);
  }

  state.bindFramebuffer(gl.FRAMEBUFFER, null);
}