Stop leaking VAOs
This commit is contained in:
parent
70201bb29c
commit
03b4ec2cc6
|
@ -385,12 +385,15 @@ class ThreeDRenderer extends Renderer {
|
|||
|
||||
private cubeVertexPositionBuffer: WebGLBuffer;
|
||||
private cubeIndexBuffer: WebGLBuffer;
|
||||
|
||||
private glyphPositionsBuffer: WebGLBuffer;
|
||||
private glyphPositions: number[];
|
||||
private glyphPositionRanges: Range[];
|
||||
private glyphTexCoords: glmatrix.vec4[];
|
||||
private glyphSizes: glmatrix.vec2[];
|
||||
|
||||
private distantGlyphVAO: WebGLVertexArrayObjectOES | null;
|
||||
|
||||
constructor(renderContext: ThreeDView) {
|
||||
super(renderContext);
|
||||
|
||||
|
@ -616,8 +619,9 @@ class ThreeDRenderer extends Renderer {
|
|||
const gl = this.renderContext.gl;
|
||||
|
||||
// Prepare the distant glyph VAO.
|
||||
const vao = this.renderContext.vertexArrayObjectExt.createVertexArrayOES();
|
||||
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(vao);
|
||||
if (this.distantGlyphVAO == null)
|
||||
this.distantGlyphVAO = this.renderContext.vertexArrayObjectExt.createVertexArrayOES();
|
||||
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(this.distantGlyphVAO);
|
||||
const distantGlyphProgram = this.renderContext.shaderPrograms.demo3DDistantGlyph;
|
||||
gl.useProgram(distantGlyphProgram.program);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, this.renderContext.quadPositionsBuffer);
|
||||
|
@ -733,7 +737,6 @@ class ThreeDRenderer extends Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
this.renderContext.vertexArrayObjectExt.deleteVertexArrayOES(vao);
|
||||
this.renderContext.vertexArrayObjectExt.bindVertexArrayOES(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,9 @@ export abstract class Renderer {
|
|||
protected abstract get usedSizeFactor(): glmatrix.vec2;
|
||||
protected abstract get worldTransform(): glmatrix.mat4;
|
||||
|
||||
private implicitCoverInteriorVAO: WebGLVertexArrayObjectOES | null;
|
||||
private implicitCoverCurveVAO: WebGLVertexArrayObjectOES | null;
|
||||
|
||||
private instancedPathIDVBO: WebGLBuffer | null;
|
||||
private timerQueryPollInterval: number | null;
|
||||
|
||||
|
@ -282,13 +285,13 @@ export abstract class Renderer {
|
|||
renderContext.gl.disable(renderContext.gl.BLEND);
|
||||
|
||||
// Set up the implicit cover interior VAO.
|
||||
//
|
||||
// TODO(pcwalton): Cache these.
|
||||
const directInteriorProgram =
|
||||
renderContext.shaderPrograms[this.directInteriorProgramName];
|
||||
const implicitCoverInteriorVAO = renderContext.vertexArrayObjectExt
|
||||
.createVertexArrayOES();
|
||||
renderContext.vertexArrayObjectExt.bindVertexArrayOES(implicitCoverInteriorVAO);
|
||||
if (this.implicitCoverInteriorVAO == null) {
|
||||
this.implicitCoverInteriorVAO = renderContext.vertexArrayObjectExt
|
||||
.createVertexArrayOES();
|
||||
}
|
||||
renderContext.vertexArrayObjectExt.bindVertexArrayOES(this.implicitCoverInteriorVAO);
|
||||
this.initImplicitCoverInteriorVAO(objectIndex, instanceRange);
|
||||
|
||||
// Draw direct interior parts.
|
||||
|
@ -331,8 +334,11 @@ export abstract class Renderer {
|
|||
//
|
||||
// TODO(pcwalton): Cache these.
|
||||
const directCurveProgram = renderContext.shaderPrograms[this.directCurveProgramName];
|
||||
const implicitCoverCurveVAO = renderContext.vertexArrayObjectExt.createVertexArrayOES();
|
||||
renderContext.vertexArrayObjectExt.bindVertexArrayOES(implicitCoverCurveVAO);
|
||||
if (this.implicitCoverCurveVAO == null) {
|
||||
this.implicitCoverCurveVAO = renderContext.vertexArrayObjectExt
|
||||
.createVertexArrayOES();
|
||||
}
|
||||
renderContext.vertexArrayObjectExt.bindVertexArrayOES(this.implicitCoverCurveVAO);
|
||||
this.initImplicitCoverCurveVAO(objectIndex, instanceRange);
|
||||
|
||||
// Draw direct curve parts.
|
||||
|
|
Loading…
Reference in New Issue