diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-06 16:00:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-06 16:00:14 -0700 |
commit | cec906c9c27fba775270e62aa3359489fe452c56 (patch) | |
tree | 171d122fc7148583d89738fb548451964ed657a9 /src | |
parent | e1055ada578f6218b5c16104ea554cc74c831959 (diff) |
prepare to proxy gl commands
Diffstat (limited to 'src')
-rw-r--r-- | src/proxyClient.js | 4 | ||||
-rw-r--r-- | src/webGLClient.js | 13 | ||||
-rw-r--r-- | src/webGLWorker.js | 12 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/proxyClient.js b/src/proxyClient.js index 62ae2492..53412671 100644 --- a/src/proxyClient.js +++ b/src/proxyClient.js @@ -80,6 +80,10 @@ worker.onmessage = function worker_onmessage(event) { } break; } + case 'gl': { + Module.glClient.onmessage(data); + break; + } default: throw 'what?'; } }; diff --git a/src/webGLClient.js b/src/webGLClient.js index 5a69c4a4..02756ddb 100644 --- a/src/webGLClient.js +++ b/src/webGLClient.js @@ -1,6 +1,19 @@ // WebGLWorker client code function WebGLClient() { + function renderCommands(buffer) { + } + + this.onmessage = function(msg) { + dump('client GL got ' + JSON.stringify(msg) + '\n'); + switch(msg.op) { + case 'render': { + renderCommands(msg.commandBuffer); + break; + } + default: throw 'weird gl onmessage ' + JSON.stringify(msg); + } + }; } WebGLClient.prefetch = function() { diff --git a/src/webGLWorker.js b/src/webGLWorker.js index 4a2f7bbb..eb230e51 100644 --- a/src/webGLWorker.js +++ b/src/webGLWorker.js @@ -8,6 +8,8 @@ function WebGLWorker() { this.prefetchedParameters = {}; this.prefetchedExtensions = {}; + var commandBuffer = []; + //=========== // Constants //=========== @@ -469,11 +471,21 @@ function WebGLWorker() { dump('worker getExtension ' + JSON.stringify(this.prefetchedExtensions) + '\n'); var i = this.prefetchedExtensions.indexOf(name); if (i < 0) return null; + // XXX send a msg, to enable it in the client return true; // TODO: return an object here }; this.getSupportedExtensions = function() { return this.prefetchedExtensions; }; + + // Setup + var postMainLoop = Module['postMainLoop']; + Module['postMainLoop'] = function() { + if (postMainLoop) postMainLoop(); + // frame complete, send the command buffer + postMessage({ target: 'gl', method: 'render', commandBuffer: commandBuffer }); + commandBuffer = []; + }; } |