Merge pull request #34 from camptocamp/webgl-point-texture-per-image
Make sure only one texture is created per image
This commit is contained in:
@@ -439,23 +439,32 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
|
|
||||||
goog.asserts.assert(this.textures_.length === 0);
|
goog.asserts.assert(this.textures_.length === 0);
|
||||||
|
|
||||||
|
var texture, image, uid;
|
||||||
|
/** @type {Object.<string, WebGLTexture>} */
|
||||||
|
var texturePerImage = {};
|
||||||
var i;
|
var i;
|
||||||
var ii = this.images_.length;
|
var ii = this.images_.length;
|
||||||
var texture;
|
|
||||||
for (i = 0; i < ii; ++i) {
|
for (i = 0; i < ii; ++i) {
|
||||||
var image = this.images_[i];
|
image = this.images_[i];
|
||||||
texture = gl.createTexture();
|
|
||||||
gl.bindTexture(goog.webgl.TEXTURE_2D, texture);
|
uid = goog.getUid(image).toString();
|
||||||
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
if (goog.object.containsKey(texturePerImage, uid)) {
|
||||||
goog.webgl.TEXTURE_WRAP_S, goog.webgl.CLAMP_TO_EDGE);
|
texture = goog.object.get(texturePerImage, uid);
|
||||||
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
} else {
|
||||||
goog.webgl.TEXTURE_WRAP_T, goog.webgl.CLAMP_TO_EDGE);
|
texture = gl.createTexture();
|
||||||
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
gl.bindTexture(goog.webgl.TEXTURE_2D, texture);
|
||||||
goog.webgl.TEXTURE_MIN_FILTER, goog.webgl.LINEAR);
|
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
||||||
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
goog.webgl.TEXTURE_WRAP_S, goog.webgl.CLAMP_TO_EDGE);
|
||||||
goog.webgl.TEXTURE_MAG_FILTER, goog.webgl.LINEAR);
|
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
||||||
gl.texImage2D(goog.webgl.TEXTURE_2D, 0, goog.webgl.RGBA, goog.webgl.RGBA,
|
goog.webgl.TEXTURE_WRAP_T, goog.webgl.CLAMP_TO_EDGE);
|
||||||
goog.webgl.UNSIGNED_BYTE, image);
|
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
||||||
|
goog.webgl.TEXTURE_MIN_FILTER, goog.webgl.LINEAR);
|
||||||
|
gl.texParameteri(goog.webgl.TEXTURE_2D,
|
||||||
|
goog.webgl.TEXTURE_MAG_FILTER, goog.webgl.LINEAR);
|
||||||
|
gl.texImage2D(goog.webgl.TEXTURE_2D, 0, goog.webgl.RGBA, goog.webgl.RGBA,
|
||||||
|
goog.webgl.UNSIGNED_BYTE, image);
|
||||||
|
goog.object.set(texturePerImage, uid, texture);
|
||||||
|
}
|
||||||
this.textures_[i] = texture;
|
this.textures_[i] = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user