Delete WebGL buffers
This commit is contained in:
@@ -196,22 +196,30 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
|||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.deleteTextures =
|
ol.render.webgl.ImageReplay.prototype.dispose = function(frameState, context) {
|
||||||
function(frameState, context) {
|
goog.asserts.assert(!goog.isNull(this.verticesBuffer_));
|
||||||
|
goog.asserts.assert(!goog.isNull(this.indicesBuffer_));
|
||||||
frameState.postRenderFunctions.push(
|
frameState.postRenderFunctions.push(
|
||||||
goog.partial(
|
goog.partial(
|
||||||
/**
|
/**
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {Array.<WebGLTexture>} textures Textures.
|
* @param {Array.<WebGLTexture>} textures Textures.
|
||||||
|
* @param {WebGLBuffer} verticesBuffer Vertices buffer.
|
||||||
|
* @param {WebGLBuffer} indicesBuffer Indices buffer.
|
||||||
*/
|
*/
|
||||||
function(gl, textures) {
|
function(gl, textures, verticesBuffer, indicesBuffer) {
|
||||||
if (!gl.isContextLost()) {
|
if (!gl.isContextLost()) {
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
for (i = 0, ii = textures.length; i < ii; ++i) {
|
||||||
gl.deleteTexture(textures[i]);
|
gl.deleteTexture(textures[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gl.deleteBuffer(verticesBuffer);
|
||||||
|
gl.deleteBuffer(indicesBuffer);
|
||||||
}
|
}
|
||||||
}, context.getGL(), this.textures_));
|
},
|
||||||
|
context.getGL(), this.textures_, this.verticesBuffer_,
|
||||||
|
this.indicesBuffer_));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -424,6 +432,7 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
|||||||
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
||||||
gl.bufferData(goog.webgl.ARRAY_BUFFER,
|
gl.bufferData(goog.webgl.ARRAY_BUFFER,
|
||||||
new Float32Array(this.vertices_), goog.webgl.STATIC_DRAW);
|
new Float32Array(this.vertices_), goog.webgl.STATIC_DRAW);
|
||||||
|
|
||||||
this.indicesBuffer_ = gl.createBuffer();
|
this.indicesBuffer_ = gl.createBuffer();
|
||||||
gl.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
gl.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
||||||
gl.bufferData(goog.webgl.ELEMENT_ARRAY_BUFFER,
|
gl.bufferData(goog.webgl.ELEMENT_ARRAY_BUFFER,
|
||||||
@@ -525,6 +534,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
|
|
||||||
var locations = this.locations_;
|
var locations = this.locations_;
|
||||||
|
|
||||||
|
goog.asserts.assert(!goog.isNull(this.verticesBuffer_));
|
||||||
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
@@ -552,6 +562,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false,
|
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false,
|
||||||
offsetRotateMatrix);
|
offsetRotateMatrix);
|
||||||
|
|
||||||
|
goog.asserts.assert(!goog.isNull(this.indicesBuffer_));
|
||||||
gl.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
gl.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
|
||||||
|
|
||||||
goog.asserts.assert(this.textures_.length == this.groupIndices_.length);
|
goog.asserts.assert(this.textures_.length == this.groupIndices_.length);
|
||||||
@@ -664,11 +675,11 @@ ol.render.webgl.ReplayGroup = function(tolerance, maxExtent) {
|
|||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.deleteTextures =
|
ol.render.webgl.ReplayGroup.prototype.dispose =
|
||||||
function(frameState, context) {
|
function(frameState, context) {
|
||||||
var replayKey;
|
var replayKey;
|
||||||
for (replayKey in this.replays_) {
|
for (replayKey in this.replays_) {
|
||||||
this.replays_[replayKey].deleteTextures(frameState, context);
|
this.replays_[replayKey].dispose(frameState, context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
|
|||||||
extent[3] = frameStateExtent[3] + yBuffer;
|
extent[3] = frameStateExtent[3] + yBuffer;
|
||||||
|
|
||||||
if (!goog.isNull(this.replayGroup_)) {
|
if (!goog.isNull(this.replayGroup_)) {
|
||||||
this.replayGroup_.deleteTextures(frameState, context);
|
this.replayGroup_.dispose(frameState, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dirty_ = false;
|
this.dirty_ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user