From 4fe5e75d847ad794cbcf3ccf93c6e9329a74ef91 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 15 Aug 2014 16:07:58 -0700 Subject: [PATCH] proxy some more gl calls --- src/webGLClient.js | 9 +++++++++ src/webGLWorker.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/webGLClient.js b/src/webGLClient.js index 491eb4c05..2f2b31c7f 100644 --- a/src/webGLClient.js +++ b/src/webGLClient.js @@ -150,6 +150,10 @@ function WebGLClient() { ctx.uniform1f(objects[buffer[i]], buffer[i+1]); i += 2; } + function uniform3f() { + ctx.uniform3f(objects[buffer[i]], buffer[i+1], buffer[i+2], buffer[i+3]); + i += 4; + } function uniform3fv() { ctx.uniform3fv(objects[buffer[i]], buffer[i+1]); i += 2; @@ -233,6 +237,11 @@ function WebGLClient() { 66: { name: 'blendEquation', func: func1 }, 67: { name: 'generateMipmap', func: func1 }, 68: { name: 'uniformMatrix3fv', func: func3L0 }, + 69: { name: 'stencilMask', func: func1 }, + 70: { name: 'clearStencil', func: func1 }, + 71: { name: 'texSubImage2D', func: func9 }, + 72: { name: 'uniform3f', func: uniform3f }, + 73: { name: 'blendFuncSeparate', func: func4 }, }; function renderCommands(buf) { diff --git a/src/webGLWorker.js b/src/webGLWorker.js index 98fb00894..8c7278c73 100644 --- a/src/webGLWorker.js +++ b/src/webGLWorker.js @@ -936,6 +936,36 @@ function WebGLWorker() { if (!location) return; commandBuffer.push(68, location.id, transpose, new Float32Array(data)); }; + this.stencilMask = function(mask) { + commandBuffer.push(69, mask); + }; + this.clearStencil = function(s) { + commandBuffer.push(70, s); + }; + this.texSubImage2D = function(target, level, xoffset, yoffset, width, height, format, type, pixels) { + if (pixels === undefined) { + // shorter overload: target, level, xoffset, yoffset, format, type, pixels + var formatTemp = format; + format = width; + type = height; + pixels = formatTemp; + assert(pixels instanceof Image); + assert(format === this.RGBA); // HTML Images are RGBA, 8-bit + assert(type === this.UNSIGNED_BYTE); + var data = pixels.data; + width = data.width; + height = data.height; + pixels = new Uint8Array(data.data); // XXX transform from clamped to normal, could have been done in duplicate + } + commandBuffer.push(71, target, level, xoffset, yoffset, width, height, format, type, duplicate(pixels)); + }; + this.uniform3f = function(location, x, y, z) { + if (!location) return; + commandBuffer.push(72, location.id, x, y, z); + }; + this.blendFuncSeparate = function(srcRGB, dstRGB, srcAlpha, dstAlpha) { + commandBuffer.push(73, srcRGB, dstRGB, srcAlpha, dstAlpha); + } // Setup