diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-05-13 21:17:23 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-05-13 21:17:23 -0700 |
commit | f09211d8eefb89f2cc403dec598307a43e342f3b (patch) | |
tree | dc6d2002e25229c6341f9efced6b3f859d8f5a73 | |
parent | 8e0cbe472f9d18c7da3eb0b783e4999db4e74ed7 (diff) |
fix active client attribute counting and add test
-rw-r--r-- | src/library_gl.js | 17 | ||||
-rw-r--r-- | tests/cube_explosion.c | 4 |
2 files changed, 14 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) { diff --git a/tests/cube_explosion.c b/tests/cube_explosion.c index 9a970c27..ee990a57 100644 --- a/tests/cube_explosion.c +++ b/tests/cube_explosion.c @@ -177,6 +177,10 @@ int main(int argc, char *argv[]) glBindBuffer(GL_ARRAY_BUFFER, arrayBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer); + // try to confuse the client state tracker + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, 20, 0); |