Skip to content

Commit

Permalink
Only disable vertex attrib arrays when not using VAOs
Browse files Browse the repository at this point in the history
This saves on disableVertexAttribArray calls. They are always disabled
at the end of doDrawList since picking still enables arrays on the
default VAO.
  • Loading branch information
Olli Etuaho committed Jun 30, 2014
1 parent b52cd7c commit 963d61d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/core/display/chunks/geometryChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ SceneJS_ChunkFactory.createChunkType({
return;
}
} else if (ctx.VAO) {
// Start creating a new VAO by switching to the default VAO, which doesn't have attribs enabled.
ctx.VAO.bindVertexArrayOES(null);
this.VAO = ctx.VAO.createVertexArrayOES();
ctx.VAO.bindVertexArrayOES(this.VAO);
var gl = this.program.gl;
}

if (doMorph) {
Expand Down
10 changes: 4 additions & 6 deletions src/core/display/chunks/programChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ SceneJS_ChunkFactory.createChunkType({

var gl = this.program.gl;

if (frameCtx.VAO) {
frameCtx.VAO.bindVertexArrayOES(null);
}

for (var i = 0; i < 10; i++) {
gl.disableVertexAttribArray(i);
if (!frameCtx.VAO) {
for (var i = 0; i < 10; i++) {
gl.disableVertexAttribArray(i);
}
}
},

Expand Down
3 changes: 3 additions & 0 deletions src/core/display/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,9 @@ SceneJS_Display.prototype._doDrawList = function (pick, rayPick) {

if (frameCtx.VAO) {
frameCtx.VAO.bindVertexArrayOES(null);
for (var i = 0; i < 10; i++) {
gl.disableVertexAttribArray(i);
}
}
};

Expand Down

0 comments on commit 963d61d

Please sign in to comment.