summaryrefslogtreecommitdiff
path: root/src/webGLClient.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-06 16:46:12 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-06 16:46:12 -0700
commit5e981894dd503ec8767aefa9225b349a03dd2ab3 (patch)
tree4707e01a78a532f730d88d6cd649b0dd975cc250 /src/webGLClient.js
parent9d2476894382e8e71aff70f32d0c32cc9bad1b55 (diff)
remote creators, shaderSource
Diffstat (limited to 'src/webGLClient.js')
-rw-r--r--src/webGLClient.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/webGLClient.js b/src/webGLClient.js
index a0cc7b7d..ad55acc4 100644
--- a/src/webGLClient.js
+++ b/src/webGLClient.js
@@ -1,6 +1,14 @@
// WebGLWorker client code
function WebGLClient() {
+ var objects = {};
+
+ function fixArgs(command, args) {
+ switch (command) {
+ case 'shaderSource': args[0] = objects[args[0]]; break;
+ }
+ }
+
function renderCommands(buffer) {
var ctx = Module.ctx;
var i = 0;
@@ -8,9 +16,20 @@ function WebGLClient() {
while (i < len) {
var command = buffer[i++];
var numArgs = buffer[i++];
- var args = buffer.slice(i, i+numArgs);
- i += numArgs;
- ctx[command].apply(ctx, args);
+ if (numArgs === 0) {
+ ctx[command]();
+ } else if (numArgs > 0) {
+ var args = fixArgs(command, buffer.slice(i, i+numArgs));
+ i += numArgs;
+ ctx[command].apply(ctx, args);
+ } else {
+ // negative means a constructor, last argument is the id to save as
+ numArgs = -numArgs - 1;
+ var args = fixArgs(command, buffer.slice(i, i+numArgs));
+ i += numArgs;
+ var id = buffer[i++];
+ objects[id] = ctx[command].apply(ctx, args);
+ }
}
}