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) {
  final glFormat = utils.convert(texture.format);
  final glType = utils.convert(texture.type);
  final glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);

  if (textureTarget == WebGL.TEXTURE_3D || textureTarget == WebGL.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(WebGL.FRAMEBUFFER, framebuffer);

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

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