aboutsummaryrefslogtreecommitdiff
path: root/src/webGLWorker.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-13 16:49:35 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-13 16:49:35 -0700
commita9539d4e707d9b34388a65b22b85a1d6d723c130 (patch)
treeb7d2564938af41a8a931cce89b5a56581bbc1bc9 /src/webGLWorker.js
parent091a3251e732d4d0fe8d6131e4a69ff0c3afb24a (diff)
getAttribLocation, and track and allocate attributes in worker
Diffstat (limited to 'src/webGLWorker.js')
-rw-r--r--src/webGLWorker.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/webGLWorker.js b/src/webGLWorker.js
index 0a03787e..686be598 100644
--- a/src/webGLWorker.js
+++ b/src/webGLWorker.js
@@ -8,6 +8,8 @@ function WebGLProgram(id) {
this.what = 'program';
this.id = id;
this.shaders = [];
+ this.attributes = {};
+ this.attributeVec = [];
}
function WebGLFramebuffer(id) {
this.what = 'frameBuffer';
@@ -544,8 +546,18 @@ function WebGLWorker() {
commandBuffer.push('attachShader', 2, program.id, shader.id);
};
this.bindAttribLocation = function(program, index, name) {
+ program.attributes[name] = index;
+ program.attributeVec[index] = name;
commandBuffer.push('bindAttribLocation', 3, program.id, index, name);
};
+ this.getAttribLocation = function(program, name) {
+ // manually bound attribs are cached locally
+ if (name in program.attributes) return program.attributes[name];
+ // if not manually bound, bind it to the next index so we update the client
+ var index = program.attributeVec.length;
+ this.bindAttribLocation(program, index, name);
+ return index;
+ };
this.linkProgram = function(program) {
commandBuffer.push('linkProgram', 1, program.id);
// parse shader sources