setupDepthRenderbuffer method

void setupDepthRenderbuffer(
  1. RenderTarget renderTarget
)

Implementation

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

  var 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 (var i = 0; i < 6; i++) {
        state.bindFramebuffer(gl.FRAMEBUFFER, renderTargetProperties["__webglFramebuffer"][i]);

        // renderTargetProperties["__webglDepthbuffer"][ i ] = gl.createRenderbuffer();
        renderTargetProperties["__webglDepthbuffer"].add(gl.createRenderbuffer());

        setupRenderBufferStorage(renderTargetProperties["__webglDepthbuffer"][i], renderTarget, false);
      }
    } else {
      state.bindFramebuffer(gl.FRAMEBUFFER, renderTargetProperties["__webglFramebuffer"]);

      renderTargetProperties["__webglDepthbuffer"] = gl.createRenderbuffer();
      setupRenderBufferStorage(renderTargetProperties["__webglDepthbuffer"], renderTarget, false);
    }
  }

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