Skip to content

Commit

Permalink
Merge pull request #3113 from lilleyse/vertexDivisorFix
Browse files Browse the repository at this point in the history
Fix globe texture stretching when instancing is enabled.
  • Loading branch information
bagnell committed Oct 21, 2015
2 parents 3021bfa + 4ecbbbe commit 3b250dc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Source/Renderer/VertexArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,10 @@ define([
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer._getBuffer());
gl.vertexAttribPointer(index, this.componentsPerAttribute, this.componentDatatype, this.normalize, this.strideInBytes, this.offsetInBytes);
gl.enableVertexAttribArray(index);
if (this.instanceDivisor > 0) {
context.glVertexAttribDivisor(index, this.instanceDivisor);
}
};

attr.disableVertexAttribArray = function(gl) {
gl.disableVertexAttribArray(this.index);
if (this.instanceDivisor > 0) {
context.glVertexAttribDivisor(index, 0);
}
};
} else {
// Less common case: value array for the same data for each vertex
Expand Down Expand Up @@ -672,7 +666,8 @@ define([

// Workaround for ANGLE, where the attribute divisor seems to be part of the global state instead
// of the VAO state. This function is called when the vao is bound, and should be removed
// once the ANGLE issue is resolved.
// once the ANGLE issue is resolved. Setting the divisor should normally happen in vertexAttrib and
// disableVertexAttribArray.
function setVertexAttribDivisor(vertexArray) {
var context = vertexArray._context;
var hasInstancedAttributes = vertexArray._hasInstancedAttributes;
Expand Down Expand Up @@ -712,12 +707,13 @@ define([
VertexArray.prototype._bind = function() {
if (defined(this._vao)) {
this._context.glBindVertexArray(this._vao);
if (this._context.instancedArrays) {
setVertexAttribDivisor(this);
}
} else {
bind(this._gl, this._attributes, this._indexBuffer);
}

if (this._context.instancedArrays) {
setVertexAttribDivisor(this);
}
};

VertexArray.prototype._unBind = function() {
Expand Down

0 comments on commit 3b250dc

Please sign in to comment.