aboutsummaryrefslogtreecommitdiff
path: root/src/library_gl.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-05-13 21:17:23 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-05-13 21:17:23 -0700
commitf09211d8eefb89f2cc403dec598307a43e342f3b (patch)
treedc6d2002e25229c6341f9efced6b3f859d8f5a73 /src/library_gl.js
parent8e0cbe472f9d18c7da3eb0b783e4999db4e74ed7 (diff)
fix active client attribute counting and add test
Diffstat (limited to 'src/library_gl.js')
-rw-r--r--src/library_gl.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 5452fe3c..07b0d2d3 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1824,22 +1824,25 @@ var LibraryGL = {
// ClientState/gl*Pointer
glEnableClientState: function(cap, disable) {
+ var attrib;
switch(cap) {
case 0x8078: // GL_TEXTURE_COORD_ARRAY
- GL.immediate.enabledClientAttributes[GL.immediate.TEXTURE0 + GL.immediate.clientActiveTexture] = !disable; break;
+ attrib = GL.immediate.TEXTURE0 + GL.immediate.clientActiveTexture; break;
case 0x8074: // GL_VERTEX_ARRAY
- GL.immediate.enabledClientAttributes[GL.immediate.VERTEX] = !disable; break;
+ attrib = GL.immediate.VERTEX; break;
case 0x8075: // GL_NORMAL_ARRAY
- GL.immediate.enabledClientAttributes[GL.immediate.NORMAL] = !disable; break;
+ attrib = GL.immediate.NORMAL; break;
case 0x8076: // GL_COLOR_ARRAY
- GL.immediate.enabledClientAttributes[GL.immediate.COLOR] = !disable; break;
+ attrib = GL.immediate.COLOR; break;
default:
throw 'unhandled clientstate: ' + cap;
}
- if (!disable) {
- GL.immediate.totalEnabledClientAttributes++;
- } else {
+ if (disable && GL.immediate.enabledClientAttributes[attrib]) {
+ GL.immediate.enabledClientAttributes[attrib] = false;
GL.immediate.totalEnabledClientAttributes--;
+ } else if (!disable && !GL.immediate.enabledClientAttributes[attrib]) {
+ GL.immediate.enabledClientAttributes[attrib] = true;
+ GL.immediate.totalEnabledClientAttributes++;
}
},
glDisableClientState: function(cap) {