aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-13 12:31:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-13 12:31:02 -0700
commitb04bfab6e27d08722ab09aed0426baec3fdcc8ce (patch)
tree134c75d17fceb1d595870190675d377ed39c5e10
parent80def15592ce9d96209cd2c68ec3b57151fb6cfa (diff)
bindBuffer of null; getError
-rw-r--r--src/webGLClient.js8
-rw-r--r--src/webGLWorker.js7
2 files changed, 12 insertions, 3 deletions
diff --git a/src/webGLClient.js b/src/webGLClient.js
index 10433729..f1657003 100644
--- a/src/webGLClient.js
+++ b/src/webGLClient.js
@@ -18,7 +18,7 @@ function WebGLClient() {
case 'compileShader':
case 'shaderSource': args[0] = objects[args[0]]; break;
case 'attachShader': args[0] = objects[args[0]]; args[1] = objects[args[1]]; break;
- case 'bindBuffer': args[1] = objects[args[1]]; break;
+ case 'bindBuffer': args[1] = args[1] ? objects[args[1]] : null; break;
}
return args;
}
@@ -35,7 +35,11 @@ function WebGLClient() {
//dump('issue ' + [command, numArgs, 'peek:' + buffer.slice(i, i+5)] + '\n');
if (numArgs === 0) {
//dump('issue: ' + command + '\n');
- ctx[command]();
+ if (command === 'getError') {
+ assert(ctx.getError() === ctx.NO_ERROR, 'we cannot handle errors, we are async proxied WebGL');
+ } else {
+ ctx[command]();
+ }
} else if (numArgs > 0) {
var args = fixArgs(command, buffer.slice(i, i+numArgs));
i += numArgs;
diff --git a/src/webGLWorker.js b/src/webGLWorker.js
index f7058a51..46674b01 100644
--- a/src/webGLWorker.js
+++ b/src/webGLWorker.js
@@ -582,7 +582,7 @@ function WebGLWorker() {
return { what: 'buffer', id: id };
};
this.bindBuffer = function(target, buffer) {
- commandBuffer.push('bindBuffer', 2, target, buffer.id);
+ commandBuffer.push('bindBuffer', 2, target, buffer ? buffer.id : 0);
};
this.bufferData = function(target, something, usage) {
if (typeof something !== 'number') something = new Uint8Array(something);
@@ -603,6 +603,11 @@ function WebGLWorker() {
this.drawArrays = function(mode, first, count) {
commandBuffer.push('drawArrays', 3, mode, first, count);
};
+ this.getError = function() {
+ // optimisticaly return success; client will abort on an actual error. we assume an error-free async workflow
+ commandBuffer.push('getError', 0);
+ return this.NO_ERROR;
+ };
// Setup
var dropped = 0;