aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js49
1 files changed, 2 insertions, 47 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 3a59d751..a6a420fa 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -60,63 +60,18 @@ mergeInto(LibraryManager.library, {
// Useful to debug native webgl apps: var Module = { printErr: function(x) { console.log(x) } };
var tempCtx = ctx;
var wrapper = {};
- wrapper.objectMap = new WeakMap();
- wrapper.objectCounter = 1;
- function prettify(arg) {
- if (typeof arg == 'undefined') return '!UNDEFINED!';
- if (!arg) return arg;
- if (wrapper.objectMap[arg]) return '<' + arg + '|' + wrapper.objectMap[arg] + '>';
- if (arg.toString() == '[object HTMLImageElement]') {
- return arg + '\n\n';
- }
- if (arg.byteLength) {
- return '{' + Array.prototype.slice.call(arg, 0, Math.min(arg.length, 40)) + '}'; // Useful for correct arrays, less so for compiled arrays, see the code below for that
- var buf = new ArrayBuffer(32);
- var i8buf = new Int8Array(buf);
- var i16buf = new Int16Array(buf);
- var f32buf = new Float32Array(buf);
- switch(arg.toString()) {
- case '[object Uint8Array]':
- i8buf.set(arg.subarray(0, 32));
- break;
- case '[object Float32Array]':
- f32buf.set(arg.subarray(0, 5));
- break;
- case '[object Uint16Array]':
- i16buf.set(arg.subarray(0, 16));
- break;
- default:
- alert('unknown array for debugging: ' + arg);
- throw 'see alert';
- }
- var ret = '{' + arg.byteLength + ':\n';
- var arr = Array.prototype.slice.call(i8buf);
- ret += 'i8:' + arr.toString().replace(/,/g, ',') + '\n';
- arr = Array.prototype.slice.call(f32buf, 0, 8);
- ret += 'f32:' + arr.toString().replace(/,/g, ',') + '}';
- return ret;
- }
- if (typeof arg == 'object') {
- wrapper.objectMap[arg] = wrapper.objectCounter++;
- return '<' + arg + '|' + wrapper.objectMap[arg] + '>';
- }
- if (typeof arg == 'number') {
- return '0x' + arg.toString(16);
- }
- return arg;
- }
for (var prop in tempCtx) {
(function(prop) {
switch (typeof tempCtx[prop]) {
case 'function': {
wrapper[prop] = function() {
if (GL.debug) {
- var printArgs = Array.prototype.slice.call(arguments).map(prettify)
+ var printArgs = Array.prototype.slice.call(arguments).map(Runtime.prettyPrint);
console.log('[gl_f:' + prop + ':' + printArgs + ']');
}
var ret = tempCtx[prop].apply(tempCtx, arguments);
if (GL.debug && typeof ret != 'undefined') {
- console.log('[ gl:' + prop + ':return:' + prettify(ret) + ']');
+ console.log('[ gl:' + prop + ':return:' + Runtime.prettyPrint(ret) + ']');
}
return ret;
}