aboutsummaryrefslogtreecommitdiff
path: root/src/library_gl.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-05-09 11:17:21 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-05-09 11:17:21 -0700
commit0518ee039d081168cf2da06f0d2f00862dac4359 (patch)
treec3f731eebfe3b1db07c3c1132b8c97433867fdde /src/library_gl.js
parenta7590b8609cc0597305171ff2489eda8c893ffbd (diff)
fix bug with using color and normal even when not enabled, if they were enabled in the past
Diffstat (limited to 'src/library_gl.js')
-rw-r--r--src/library_gl.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 1c52e422..0f7d251c 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1341,12 +1341,18 @@ var LibraryGL = {
var positionSize = GL.immediate.clientAttributes[GL.immediate.VERTEX].size;
var positionType = GL.immediate.clientAttributes[GL.immediate.VERTEX].type;
var positionOffset = GL.immediate.clientAttributes[GL.immediate.VERTEX].offset;
- var colorSize = GL.immediate.clientAttributes[GL.immediate.COLOR].size;
- var colorType = GL.immediate.clientAttributes[GL.immediate.COLOR].type;
- var colorOffset = GL.immediate.clientAttributes[GL.immediate.COLOR].offset;
- var normalSize = GL.immediate.clientAttributes[GL.immediate.NORMAL].size;
- var normalType = GL.immediate.clientAttributes[GL.immediate.NORMAL].type;
- var normalOffset = GL.immediate.clientAttributes[GL.immediate.NORMAL].offset;
+ var colorSize = 0, colorType, colorOffset;
+ if (GL.immediate.enabledClientAttributes[GL.immediate.COLOR]) {
+ colorSize = GL.immediate.clientAttributes[GL.immediate.COLOR].size;
+ colorType = GL.immediate.clientAttributes[GL.immediate.COLOR].type;
+ colorOffset = GL.immediate.clientAttributes[GL.immediate.COLOR].offset;
+ }
+ var normalSize = 0, normalType, normalOffset;
+ if (GL.immediate.enabledClientAttributes[GL.immediate.NORMAL]) {
+ normalSize = GL.immediate.clientAttributes[GL.immediate.NORMAL].size;
+ normalType = GL.immediate.clientAttributes[GL.immediate.NORMAL].type;
+ normalOffset = GL.immediate.clientAttributes[GL.immediate.NORMAL].offset;
+ }
var ret = {
init: function() {
if (useCurrProgram) {
@@ -1413,7 +1419,7 @@ var LibraryGL = {
this.hasTextures = hasTextures;
this.hasColorAttrib = colorSize > 0 && this.colorLocation >= 0;
this.hasColorUniform = !!this.colorUniformLocation;
- this.hasNormal = this.normalLocation >= 0;
+ this.hasNormal = normalSize > 0 && this.normalLocation >= 0;
this.floatType = Module.ctx.FLOAT; // minor optimization
},