diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-05-01 13:56:23 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-05-01 13:56:23 -0700 |
commit | 5767a177c205fd6701b6da0c838ff28c1c13935b (patch) | |
tree | a13431ca9d3b2db1076c0829f409dc40a96b3f9b | |
parent | 50d59708df29324c9c913310b49db93241ca1e48 (diff) |
optimize usage of client attributes to avoid allocations
-rw-r--r-- | src/library_gl.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 93b50222..051e33a1 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1241,7 +1241,7 @@ var LibraryGL = { totalEnabledClientAttributes: 0, enabledClientAttributes: [0, 0], - clientAttributes: [null, null], + clientAttributes: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}], clientActiveTexture: 0, byteSizeByType: { @@ -1255,9 +1255,12 @@ var LibraryGL = { }, setClientAttribute: function(name, size, type, stride, pointer) { - this.clientAttributes[GL.immediate.ATTRIBUTE_BY_NAME[name]] = { - size: size, type: type, stride: stride, pointer: pointer, name: name + size - }; + var attrib = this.clientAttributes[GL.immediate.ATTRIBUTE_BY_NAME[name]]; + attrib.size = size; + attrib.type = type; + attrib.stride = stride; + attrib.pointer = pointer; + attrib.name = name + size; }, // Renderers @@ -1432,9 +1435,12 @@ var LibraryGL = { }; }, + tempClientAttributes: [], prepareClientAttributes: function(count) { // Client attributes are to be used here, emulate that - var stride = 0, attributes = [], start; + var stride = 0, start; + var attributes = GL.immediate.tempClientAttributes; + attributes.length = 0; for (var i = 0; i < GL.immediate.NUM_ATTRIBUTES; i++) { if (GL.immediate.enabledClientAttributes[i]) attributes.push(GL.immediate.clientAttributes[i]); } |