aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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