Skip to content

Commit

Permalink
Merge e9ef1ed into fdbeaa6
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Sep 16, 2019
2 parents fdbeaa6 + e9ef1ed commit c2da8b0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/webgl/src/classes/vertex-array-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class VertexArrayObject extends Resource {
this.hasVertexArrays = VertexArrayObject.isSupported(gl);
this.buffer = null;
this.bufferValue = null;
this.isDefaultArray = opts.isDefaultArray !== undefined ? opts.isDefaultArray : false;
this.isDefaultArray = opts.isDefaultArray || false;

this.initialize(opts);

Expand Down
2 changes: 1 addition & 1 deletion modules/webgl/src/classes/vertex-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export default class VertexArray {
VertexArrayObject.setConstant(this.gl, location, constant);

// If we are using the global VertexArrayObject, we need to disable the attribute now
if (this.vertexArrayObject.isDefault) {
if (this.vertexArrayObject.isDefaultArray) {
this.vertexArrayObject.enable(location, false);
}
}
Expand Down
33 changes: 33 additions & 0 deletions modules/webgl/test/classes/vertex-array.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,36 @@ test('WebGL#VertexArray#constant multi-column attribute', t => {

t.end();
});

test('WebGL#VertexArray#default VAO unbinding', t => {
const {gl} = fixture;

const oldIsSupported = VertexArrayObject.isSupported;
VertexArrayObject.isSupported = () => false;

const vertexArray = new VertexArray(gl, {
attributes: {
positions: new Buffer(gl, {
target: GL.ARRAY_BUFFER,
data: new Float32Array([0, 1, 2]),
accessor: {size: 3}
}),
elements: new Buffer(gl, {
target: GL.ELEMENT_ARRAY_BUFFER,
data: new Float32Array([0, 1, 2]),
accessor: {size: 3}
})
}
});
t.ok(vertexArray.vertexArrayObject.isDefaultArray, 'Using default VertexArrayObject');
t.ok(vertexArray.elements, 'VertexArray has elements');

vertexArray.bindBuffers();
vertexArray.unbindBuffers();

t.ok(vertexArray.elements, 'VertexArray has elements after binding and unbinding');

VertexArrayObject.isSupported = oldIsSupported;

t.end();
});

0 comments on commit c2da8b0

Please sign in to comment.