Skip to content

Commit

Permalink
Slightly rework depth clearing to fix all extrusion tests not renderi…
Browse files Browse the repository at this point in the history
…ng + fix texture deletion on resize
  • Loading branch information
Lauren Budorick committed Aug 4, 2017
1 parent c99b299 commit b155913
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Painter {

if (this.viewportTextures.length) {
for (let i = 0; i < this.viewportTextures.length; i++) {
this.gl.deleteTexture(this.viewportTextures[i]);
this.gl.deleteTexture(this.viewportTextures[i].texture);
}
this.viewportTextures = [];
}
Expand Down Expand Up @@ -337,7 +337,8 @@ class Painter {

if (!fboAttached) {
this._setup3DFramebuffer();
fboAttached = true;
// Wait to flip the boolean until after we attach the first
// texture and clear the depth buffer a few lines down.
}

let renderTarget = this.viewportTextures.pop();
Expand All @@ -346,16 +347,17 @@ class Painter {
}
renderTarget.attachToFramebuffer();

this.renderLayer(this, (sourceCache : any), layer, coords);
if (!fboAttached) {
this.clearDepth();
fboAttached = true;
}

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

renderTarget.detachFromFramebuffer();

this._prerenderedTextures[layerId] = renderTarget;
}

if (i === this.style._order3D.length - 1 && fboAttached) {
this.clearDepth();
}
}

if (fboAttached) gl.bindFramebuffer(gl.FRAMEBUFFER, null);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"version": 8,
"metadata": {
"test": {
"height": 256
}
},
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"which": "a",
"property": 10
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.0003,
-0.0003
],
[
-0.0003,
0.0003
],
[
0.0003,
0.0003
],
[
0.0003,
-0.0003
],
[
-0.0003,
-0.0003
]
]
]
}
},
{
"type": "Feature",
"properties": {
"which": "b",
"property": 20
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.0002,
0
],
[
0,
0.0002
],
[
0.0002,
0
],
[
0,
-0.0002
],
[
-0.0002,
0
]
]
]
}
},
{
"type": "Feature",
"properties": {
"which": "c",
"property": 30
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.0001,
-0.0001
],
[
-0.0001,
0.0001
],
[
0.0001,
0.0001
],
[
0.0001,
-0.0001
],
[
-0.0001,
-0.0001
]
]
]
}
}
]
}
}
},
"pitch": 60,
"zoom": 18,
"layers": [
{
"id": "a",
"type": "fill-extrusion",
"source": "geojson",
"filter": ["==", "which", "a"],
"paint": {
"fill-extrusion-color": "red",
"fill-extrusion-height": 10
}
},
{
"id": "b",
"type": "fill-extrusion",
"source": "geojson",
"filter": ["==", "which", "b"],
"paint": {
"fill-extrusion-color": "blue",
"fill-extrusion-height": 20
}
},
{
"id": "c",
"type": "fill-extrusion",
"source": "geojson",
"filter": ["==", "which", "c"],
"paint": {
"fill-extrusion-color": "yellow",
"fill-extrusion-height": 30
}
}
]
}

0 comments on commit b155913

Please sign in to comment.