Skip to content

Commit

Permalink
Only attach depth RBO on first fill-extrusion layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick committed Aug 28, 2017
1 parent bb51e2f commit 1143dc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,24 @@ class Painter {
this._setup3DRenderbuffer();

const renderTarget = this.viewportFrames.pop() || new RenderTexture(this);
renderTarget.attachRenderbuffer(this.depthRbo);
renderTarget.bind();

if (first) {
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.depthRbo);
this.clearDepth();
first = false;
}

this.renderLayer(this, (sourceCache: any), layer, coords);

renderTarget.detachRenderbuffer();
renderTarget.unbind();
this.prerenderedFrames[layer.id] = renderTarget;
}

if (this.depthRboAttached) gl.bindRenderbuffer(gl.RENDERBUFFER, null);
if (this.depthRboAttached) {
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
}

}

// Clear buffers in preparation for drawing to the main framebuffer
Expand Down
6 changes: 2 additions & 4 deletions src/render/render_texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ class RenderTexture {
this.vao = new VertexArrayObject();
}

attachRenderbuffer(depthRbo: WebGLRenderbuffer) {
bind() {
const gl = this.gl;
gl.bindFramebuffer(gl.FRAMEBUFFER, this.fbo);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthRbo);
}

detachRenderbuffer() {
unbind() {
const gl = this.gl;
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, null);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
}
Expand Down

0 comments on commit 1143dc4

Please sign in to comment.