diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-01-02 19:12:56 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-01-09 20:05:27 +0200 |
commit | 8e69ae1e19523a15c1f9328f3c0e757c0661dc4b (patch) | |
tree | 816569b360c737396cb0ff99199670b7e2bb151a | |
parent | c6582b7766e7754032f6fb7aae278f7f77090615 (diff) |
Optimize glEnableClientState by avoiding it to be called with different param count.
-rw-r--r-- | src/library_gl.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 3e022539..203721f8 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -4485,7 +4485,7 @@ var LibraryGL = { // ClientState/gl*Pointer - glEnableClientState: function(cap, disable) { + glEnableClientState: function(cap) { var attrib = GLEmulation.getAttributeFromCapability(cap); if (attrib === null) { #if ASSERTIONS @@ -4493,21 +4493,29 @@ var LibraryGL = { #endif return; } - if (disable && GL.immediate.enabledClientAttributes[attrib]) { - GL.immediate.enabledClientAttributes[attrib] = false; - GL.immediate.totalEnabledClientAttributes--; - this.currentRenderer = null; // Will need to change current renderer, since the set of active vertex pointers changed. - if (GLEmulation.currentVao) delete GLEmulation.currentVao.enabledClientStates[cap]; - } else if (!disable && !GL.immediate.enabledClientAttributes[attrib]) { + if (!GL.immediate.enabledClientAttributes[attrib]) { GL.immediate.enabledClientAttributes[attrib] = true; GL.immediate.totalEnabledClientAttributes++; this.currentRenderer = null; // Will need to change current renderer, since the set of active vertex pointers changed. if (GLEmulation.currentVao) GLEmulation.currentVao.enabledClientStates[cap] = 1; + GL.immediate.modifiedClientAttributes = true; } - GL.immediate.modifiedClientAttributes = true; }, glDisableClientState: function(cap) { - _glEnableClientState(cap, 1); + var attrib = GLEmulation.getAttributeFromCapability(cap); + if (attrib === null) { +#if ASSERTIONS + Module.printErr('WARNING: unhandled clientstate: ' + cap); +#endif + return; + } + if (GL.immediate.enabledClientAttributes[attrib]) { + GL.immediate.enabledClientAttributes[attrib] = false; + GL.immediate.totalEnabledClientAttributes--; + this.currentRenderer = null; // Will need to change current renderer, since the set of active vertex pointers changed. + if (GLEmulation.currentVao) delete GLEmulation.currentVao.enabledClientStates[cap]; + GL.immediate.modifiedClientAttributes = true; + } }, glVertexPointer__deps: ['$GLEmulation'], // if any pointers are used, glVertexPointer must be, and if it is, then we need emulation |