Add depth test to PolygonReplay
This commit is contained in:
@@ -870,6 +870,16 @@ ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||||
|
//Save GL parameters.
|
||||||
|
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
||||||
|
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
||||||
|
|
||||||
|
if (!hitDetection) {
|
||||||
|
gl.enable(gl.DEPTH_TEST);
|
||||||
|
gl.depthMask(true);
|
||||||
|
gl.depthFunc(gl.NOTEQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||||
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
||||||
} else {
|
} else {
|
||||||
@@ -887,6 +897,13 @@ ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skipp
|
|||||||
end = start;
|
end = start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hitDetection) {
|
||||||
|
gl.disable(gl.DEPTH_TEST);
|
||||||
|
gl.clear(gl.DEPTH_BUFFER_BIT);
|
||||||
|
//Restore GL parameters.
|
||||||
|
gl.depthMask(tmpDepthMask);
|
||||||
|
gl.depthFunc(tmpDepthFunc);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -964,6 +981,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, conte
|
|||||||
if (skippedFeaturesHash[featureUid]) {
|
if (skippedFeaturesHash[featureUid]) {
|
||||||
if (start !== end) {
|
if (start !== end) {
|
||||||
this.drawElements(gl, context, start, end);
|
this.drawElements(gl, context, start, end);
|
||||||
|
gl.clear(gl.DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
end = featureStart;
|
end = featureStart;
|
||||||
}
|
}
|
||||||
@@ -972,6 +990,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, conte
|
|||||||
}
|
}
|
||||||
if (start !== end) {
|
if (start !== end) {
|
||||||
this.drawElements(gl, context, start, end);
|
this.drawElements(gl, context, start, end);
|
||||||
|
gl.clear(gl.DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
start = end = groupStart;
|
start = end = groupStart;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -406,7 +406,14 @@ describe('ol.render.webgl.PolygonReplay', function() {
|
|||||||
geometry: new ol.geom.Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
|
geometry: new ol.geom.Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
|
||||||
});
|
});
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
gl = {};
|
gl = {
|
||||||
|
getParameter: function() {},
|
||||||
|
enable: function() {},
|
||||||
|
disable: function() {},
|
||||||
|
depthMask: function() {},
|
||||||
|
depthFunc: function() {},
|
||||||
|
clear: function() {}
|
||||||
|
};
|
||||||
context = {};
|
context = {};
|
||||||
replay.setFillStyle_ = function() {};
|
replay.setFillStyle_ = function() {};
|
||||||
replay.drawElements = function() {};
|
replay.drawElements = function() {};
|
||||||
|
|||||||
Reference in New Issue
Block a user