From e35cbd670c9c277c0d2aa3575853d0b29ec54342 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Tue, 10 Nov 2015 15:43:14 +0100 Subject: [PATCH] Fix bug with first draw call Attribute locations aren't correct on the first draw call, because the shader is bound in `GLGeometry.prototype.bind` before they are updated and `gl-shader` updates locations when it is bound. Binding the shader after the attributes are updated fixes the problem. This fixes issue stackgl/gl-shader#5. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 983be9a..8093961 100644 --- a/index.js +++ b/index.js @@ -98,14 +98,14 @@ GLGeometry.prototype.bind = function bind(shader) { this.update() this._vao.bind() - if (!shader) return - shader.bind() - if (!this._keys) return for (var i = 0; i < this._keys.length; i++) { var attr = shader.attributes[this._keys[i]] if (attr) attr.location = i } + + if (!shader) return + shader.bind() } GLGeometry.prototype.draw = function draw(mode, start, stop) {