aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library_gl.js27
-rw-r--r--src/library_glut.js8
2 files changed, 34 insertions, 1 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 85c0290e..6f99969e 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -436,6 +436,33 @@ var LibraryGL = {
Module.ctx.uniform4i(location, v0, v1, v2, v3);
},
+ glUniform1iv: function(location, count, value) {
+ location = GL.uniforms[location];
+ value = new Int32Array(TypedArray_copy(value, count*4)); // TODO: optimize
+ Module.ctx.uniform1iv(location, value);
+ },
+
+ glUniform2iv: function(location, count, value) {
+ location = GL.uniforms[location];
+ count *= 2;
+ value = new Int32Array(TypedArray_copy(value, count*4)); // TODO: optimize
+ Module.ctx.uniform2iv(location, value);
+ },
+
+ glUniform3iv: function(location, count, value) {
+ location = GL.uniforms[location];
+ count *= 3;
+ value = new Int32Array(TypedArray_copy(value, count*4)); // TODO: optimize
+ Module.ctx.uniform3iv(location, value);
+ },
+
+ glUniform4iv: function(location, count, value) {
+ location = GL.uniforms[location];
+ count *= 4;
+ value = new Int32Array(TypedArray_copy(value, count*4)); // TODO: optimize
+ Module.ctx.uniform4iv(location, value);
+ },
+
glUniform1fv: function(location, count, value) {
location = GL.uniforms[location];
value = new Float32Array(TypedArray_copy(value, count*4)); // TODO: optimize
diff --git a/src/library_glut.js b/src/library_glut.js
index 9c748177..234666ca 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -323,6 +323,7 @@ var LibraryGLUT = {
var ctx = Module["canvas"].getContext('experimental-webgl');
if (!ctx) throw 'Could not create canvas :(';
#if GL_DEBUG
+ // Useful to debug native webgl apps: var Module = { printErr: function(x) { console.log(x) } };
var wrapper = {};
wrapper.objectMap = new WeakMap();
wrapper.objectCounter = 1;
@@ -333,7 +334,12 @@ var LibraryGLUT = {
wrapper[prop] = function() {
var printArgs = Array.prototype.slice.call(arguments).map(function(arg) {
if (wrapper.objectMap[arg]) return '<' + arg + '|' + wrapper.objectMap[arg] + '>';
- if (arg.subarray) return '{' + arg + '|' + arg.length /*+ '|' + Array.prototype.slice.call(arg).toString().replace(/,/g, ', ')*/ + '}';
+ if (arg.byteLength) {
+ var ret = '{' + arg.byteLength + ':';
+ var arr = Array.prototype.slice.call(new Uint8Array(arg.buffer), 0, 40);
+ ret += arr.toString().replace(/,/g, ', ') + '}';
+ return ret;
+ }
return arg;
});
Module.printErr('[gl_f:' + prop + ':' + printArgs + ']');