Fix tile edge artefacts

This commit is contained in:
Tom Payne
2012-07-17 22:54:58 +02:00
parent 6abcc56789
commit 7dc2884498
2 changed files with 12 additions and 6 deletions

View File

@@ -269,9 +269,13 @@ ol.webgl.Map.prototype.getTexture = function(image) {
gl.texImage2D(goog.webgl.TEXTURE_2D, 0, goog.webgl.RGBA, goog.webgl.RGBA,
goog.webgl.UNSIGNED_BYTE, image);
gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_MAG_FILTER,
goog.webgl.LINEAR);
goog.webgl.NEAREST);
gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_MIN_FILTER,
goog.webgl.LINEAR);
goog.webgl.NEAREST);
gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_WRAP_S,
goog.webgl.CLAMP_TO_EDGE);
gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_WRAP_T,
goog.webgl.CLAMP_TO_EDGE);
this.textureCache_[image.src] = texture;
return texture;
}

View File

@@ -270,11 +270,13 @@ ol.webgl.TileLayerRenderer.prototype.redraw = function() {
if (goog.isNull(this.arrayBuffer_)) {
var arrayBuffer = gl.createBuffer();
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, arrayBuffer);
var textureOffsetX = 0.5 / tileSize.width;
var textureOffsetY = 0.5 / tileSize.height;
gl.bufferData(goog.webgl.ARRAY_BUFFER, new Float32Array([
0, 0, 0, 1,
1, 0, 1, 1,
0, 1, 0, 0,
1, 1, 1, 0
0, 0, 0 + textureOffsetX, 1 + textureOffsetY,
1, 0, 1 + textureOffsetX, 1 + textureOffsetY,
0, 1, 0 + textureOffsetX, 0 + textureOffsetY,
1, 1, 1 + textureOffsetX, 0 + textureOffsetY
]), goog.webgl.STATIC_DRAW);
this.arrayBuffer_ = arrayBuffer;
} else {