setupDepthRenderbuffer method

void setupDepthRenderbuffer(
  1. RenderTarget renderTarget
)

Implementation

void setupDepthRenderbuffer(RenderTarget renderTarget) {
  final renderTargetProperties = properties.get(renderTarget);

  final isCube = (renderTarget.isWebGLCubeRenderTarget == true);

  if (renderTarget.depthTexture != null) {
    if (isCube) {
      throw ('target.depthTexture not supported in Cube render targets');
    }

    setupDepthTexture(renderTargetProperties["__webglFramebuffer"], renderTarget);
  } else {
    if (isCube) {
      renderTargetProperties["__webglDepthbuffer"] = [];

      for (int i = 0; i < 6; i++) {
        state.bindFramebuffer(WebGL.FRAMEBUFFER, renderTargetProperties["__webglFramebuffer"][i]);
        renderTargetProperties["__webglDepthbuffer"].add(gl.createRenderbuffer());
        setupRenderBufferStorage(renderTargetProperties["__webglDepthbuffer"][i], renderTarget, false);
      }
    }
    else {
      state.bindFramebuffer(WebGL.FRAMEBUFFER, renderTargetProperties["__webglFramebuffer"]);
      renderTargetProperties["__webglDepthbuffer"] = gl.createRenderbuffer();
      setupRenderBufferStorage(renderTargetProperties["__webglDepthbuffer"], renderTarget, false);
    }
  }

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