diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-13 13:29:51 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-13 13:29:51 -0700 |
commit | cd987405b9e1f825172dbaa12e61748c8b2e7941 (patch) | |
tree | 6eeed79fd940f520f6e02b5608b603ceecdfd6b7 | |
parent | b04bfab6e27d08722ab09aed0426baec3fdcc8ce (diff) |
createTexture, bindTexture
-rw-r--r-- | src/webGLClient.js | 1 | ||||
-rw-r--r-- | src/webGLWorker.js | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/webGLClient.js b/src/webGLClient.js index f1657003..173078c3 100644 --- a/src/webGLClient.js +++ b/src/webGLClient.js @@ -18,6 +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 'bindTexture': case 'bindBuffer': args[1] = args[1] ? objects[args[1]] : null; break; } return args; diff --git a/src/webGLWorker.js b/src/webGLWorker.js index 46674b01..6319f70f 100644 --- a/src/webGLWorker.js +++ b/src/webGLWorker.js @@ -12,6 +12,10 @@ function WebGLWorker() { var nextId = 1; + var bindings = { + texture2D: null + }; + //=========== // Constants //=========== @@ -465,7 +469,12 @@ function WebGLWorker() { this.getParameter = function(name) { assert(name); if (name in this.prefetchedParameters) return this.prefetchedParameters[name]; - throw 'TODO: get parameter ' + name + ' : ' + revname(name); + switch (name) { + case this.TEXTURE_BINDING_2D: { + return bindings.texture2D; + } + default: throw 'TODO: get parameter ' + name + ' : ' + revname(name); + } }; this.getExtension = function(name) { var i = this.prefetchedExtensions.indexOf(name); @@ -608,6 +617,20 @@ function WebGLWorker() { commandBuffer.push('getError', 0); return this.NO_ERROR; }; + this.createTexture = function() { + var id = nextId++; + commandBuffer.push('createTexture', -1, id); + return { id: id, what: 'texture' }; + }; + this.bindTexture = function(target, texture) { + switch (target) { + case that.TEXTURE_2D: { + bindings.texture2D = texture; + break; + } + } + commandBuffer.push('bindTexture', 2, target, texture ? texture.id : 0); + }; // Setup var dropped = 0; |