diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-08-04 22:45:19 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-08-05 21:56:54 -0700 |
commit | 04ea62fb7cd99b54fbc1fdfeac2abdf3e55e445f (patch) | |
tree | 7d4db72015e929d293b66ceed581e0fc7a82e61f | |
parent | 259415224a44a8a325ef9bb97e423037feda6573 (diff) |
optimize byteSizeByType
-rw-r--r-- | src/library_gl.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index e52d22c3..f06d3748 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1422,15 +1422,16 @@ var LibraryGL = { clientActiveTexture: 0, clientColor: null, - byteSizeByType: { - 0x1400: 1, // GL_BYTE - 0x1401: 1, // GL_UNSIGNED_BYTE - 0x1402: 2, // GL_SHORT - 0x1403: 2, // GL_UNSIGNED_SHORT - 0x1404: 4, // GL_INT - 0x1405: 4, // GL_UNSIGNED_INT - 0x1406: 4 // GL_FLOAT - }, + byteSizeByTypeRoot: 0x1400, // GL_BYTE + byteSizeByType: [ + 1, // GL_BYTE + 1, // GL_UNSIGNED_BYTE + 2, // GL_SHORT + 2, // GL_UNSIGNED_SHORT + 4, // GL_INT + 4, // GL_UNSIGNED_INT + 4 // GL_FLOAT + ], setClientAttribute: function(name, size, type, stride, pointer) { var attrib = this.clientAttributes[GL.immediate.ATTRIBUTE_BY_NAME[name]]; @@ -1507,7 +1508,7 @@ var LibraryGL = { #endif this.enabledClientAttributes[this.ATTRIBUTE_BY_NAME[name]] = true; this.setClientAttribute(name, size, type, 0, this.rendererComponentPointer); - this.rendererComponentPointer += size * this.byteSizeByType[type]; + this.rendererComponentPointer += size * this.byteSizeByType[type - this.byteSizeByTypeRoot]; } else { this.rendererComponents[name]++; } @@ -1942,7 +1943,7 @@ var LibraryGL = { assert((attribute.offset - bytes)%4 == 0); // XXX assuming 4-alignment bytes += attribute.offset - bytes; } - bytes += attribute.size * GL.immediate.byteSizeByType[attribute.type]; + bytes += attribute.size * GL.immediate.byteSizeByType[attribute.type - GL.immediate.byteSizeByTypeRoot]; if (bytes % 4 != 0) bytes += 4 - (bytes % 4); // XXX assuming 4-alignment } assert(stride == 0 || bytes <= stride); |