aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-01 17:06:44 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-01 17:20:58 -0700
commit63cfce0325e60f9197b2692a8de7426e9cd4a206 (patch)
tree53f5d3a15629260b2264d5287ab011c014f5dd4e
parent13ead4463cac1f7860524210ed02991618aa9771 (diff)
optimize client attribute storage
-rw-r--r--src/library_gl.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index bf8cb706..813da761 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1984,7 +1984,7 @@ var LibraryGL = {
totalEnabledClientAttributes: 0,
enabledClientAttributes: [0, 0],
- clientAttributes: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}], // raw data, including possible unneeded ones
+ clientAttributes: [], // raw data, including possible unneeded ones
liveClientAttributes: [], // the ones actually alive in the current computation, sorted
modifiedClientAttributes: false,
clientActiveTexture: 0,
@@ -1992,11 +1992,27 @@ var LibraryGL = {
setClientAttribute: function(name, size, type, stride, pointer) {
var attrib = this.clientAttributes[name];
- attrib.name = name;
- attrib.size = size;
- attrib.type = type;
- attrib.stride = stride;
- attrib.pointer = pointer;
+ if (!attrib) {
+ for (var i = 0; i <= name; i++) { // keep flat
+ if (!this.clientAttributes[i]) {
+ this.clientAttributes[i] = {
+ name: name,
+ size: size,
+ type: type,
+ stride: stride,
+ pointer: pointer,
+ offset: 0
+ };
+ }
+ }
+ } else {
+ attrib.name = name;
+ attrib.size = size;
+ attrib.type = type;
+ attrib.stride = stride;
+ attrib.pointer = pointer;
+ attrib.offset = 0;
+ }
this.modifiedClientAttributes = true;
},