aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rwxr-xr-xemcc2
-rw-r--r--src/jsifier.js29
-rw-r--r--src/library.js20
-rw-r--r--src/library_egl.js20
-rw-r--r--src/library_gl.js590
-rw-r--r--src/library_glut.js310
-rw-r--r--src/library_sdl.js17
-rw-r--r--src/library_xlib.js24
-rw-r--r--src/long.js1633
-rw-r--r--src/modules.js2
-rw-r--r--src/parseTools.js58
-rw-r--r--src/settings.js3
-rw-r--r--src/shell.html1
-rw-r--r--system/include/X11/X.h717
-rw-r--r--system/include/X11/Xatom.h79
-rw-r--r--system/include/X11/Xfuncproto.h127
-rw-r--r--system/include/X11/Xlib.h4023
-rw-r--r--system/include/X11/Xosdefs.h116
-rw-r--r--system/include/X11/Xutil.h826
-rw-r--r--system/include/X11/keysym.h73
-rw-r--r--system/include/X11/keysymdef.h2389
-rw-r--r--system/include/libc/sys/types.h5
-rw-r--r--tests/cube2hash/Makefile14
-rw-r--r--tests/cube2hash/cube2crypto.c23
-rw-r--r--tests/cube2hash/cube2crypto.h9
-rw-r--r--tests/cube2hash/hashstring.cpp28
-rw-r--r--tests/cube2hash/tiger.c175
-rw-r--r--tests/cube2hash/tiger.h12
-rw-r--r--tests/cube2hash/util.h22
-rw-r--r--tests/freetype/main_3.c184
-rw-r--r--tests/freetype/ref_3.txt33
-rw-r--r--tests/freetype/ref_4.txt32
-rw-r--r--tests/gears.pngbin0 -> 7832 bytes
-rw-r--r--tests/gl/LICENSE.TXT11
-rw-r--r--tests/gl/sdl_ogl.c202
-rw-r--r--tests/gl/tutorial2.frag11
-rw-r--r--tests/gl/tutorial2.vert19
-rw-r--r--tests/glbook/CH02_HelloTriangle.pngbin0 -> 1009 bytes
-rw-r--r--tests/glbook/CH08_SimpleVertexShader.pngbin0 -> 1600 bytes
-rw-r--r--tests/glbook/CH09_SimpleTexture2D.pngbin0 -> 1943 bytes
-rw-r--r--tests/glbook/CH09_TextureCubemap.pngbin0 -> 3209 bytes
-rw-r--r--tests/glbook/Chapter_10/MultiTexture/MultiTexture.c213
-rw-r--r--tests/glbook/Chapter_10/MultiTexture/basemap.tgabin0 -> 786476 bytes
-rw-r--r--tests/glbook/Chapter_10/MultiTexture/lightmap.tgabin0 -> 196626 bytes
-rw-r--r--tests/glbook/Chapter_11/Multisample/Multisample.c302
-rw-r--r--tests/glbook/Chapter_11/Stencil_Test/Stencil_Test.c273
-rw-r--r--tests/glbook/Chapter_13/ParticleSystem/ParticleSystem.c294
-rw-r--r--tests/glbook/Chapter_13/ParticleSystem/smoke.tgabin0 -> 49170 bytes
-rw-r--r--tests/glbook/Chapter_15/Hello_Triangle_KD/Hello_Triangle_KD.c306
-rw-r--r--tests/glbook/Chapter_2/Hello_Triangle/Hello_Triangle.c200
-rw-r--r--tests/glbook/Chapter_8/Simple_VertexShader/Simple_VertexShader.c209
-rw-r--r--tests/glbook/Chapter_9/MipMap2D/MipMap2D.c348
-rw-r--r--tests/glbook/Chapter_9/Simple_Texture2D/Simple_Texture2D.c213
-rw-r--r--tests/glbook/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c244
-rw-r--r--tests/glbook/Chapter_9/TextureWrap/TextureWrap.c257
-rw-r--r--tests/glbook/Common/esShader.c155
-rw-r--r--tests/glbook/Common/esShapes.c280
-rw-r--r--tests/glbook/Common/esTransform.c213
-rw-r--r--tests/glbook/Common/esUtil.c420
-rw-r--r--tests/glbook/Common/esUtil.h281
-rw-r--r--tests/glbook/Makefile60
-rw-r--r--tests/glbook/README.linux32
-rw-r--r--tests/i64_precise.txt128
-rwxr-xr-xtests/runner.py608
-rw-r--r--tools/autodebugger.py7
-rw-r--r--tools/clean_webconsole.py15
-rw-r--r--tools/js-optimizer.js2
-rw-r--r--tools/scan_js.py20
-rw-r--r--tools/shared.py1
-rw-r--r--tools/test-js-optimizer-output.js4
71 files changed, 15992 insertions, 934 deletions
diff --git a/AUTHORS b/AUTHORS
index 93d4e0a0..4ebdede9 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -17,4 +17,6 @@ under the licensing terms detailed in LICENSE.
* Richard Assar <richard.assar@gmail.com>
* Nathan Hammond <emscripten@nathanhammond.com>
* Behdad Esfahbod <behdad@behdad.org>
+* David Benjamin <davidben@mit.edu>
* Pierre Renaux <pierre@talansoft.com>
+
diff --git a/emcc b/emcc
index a6cacb39..8f4ed684 100755
--- a/emcc
+++ b/emcc
@@ -361,7 +361,7 @@ for i in range(1, len(sys.argv)):
if '-M' in sys.argv or '-MM' in sys.argv:
# Just output dependencies, do not compile. Warning: clang and gcc behave differently with -MF! (clang seems to not recognize it)
- cmd = [CC] + sys.argv[1:]
+ cmd = [CC] + shared.COMPILER_OPTS + sys.argv[1:]
if DEBUG: print >> sys.stderr, 'emcc, just dependencies: ', ' '.join(cmd)
exit(subprocess.call(cmd))
diff --git a/src/jsifier.js b/src/jsifier.js
index 99176fd2..8e688d8d 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -166,23 +166,27 @@ function JSify(data, functionsOnly, givenFunctions) {
ret[index++] = 0;
}
// Add current value(s)
- var currValue = flatten(values[i]);
+ var currValue = values[i];
if (USE_TYPED_ARRAYS == 2 && typeData.fields[i] == 'i64') {
// 'flatten' out the 64-bit value into two 32-bit halves
- ret[index++] = currValue>>>0;
+ var parts = parseI64Constant(currValue, true);
+ ret[index++] = parts[0];
ret[index++] = 0;
ret[index++] = 0;
ret[index++] = 0;
- ret[index++] = Math.floor(currValue/4294967296);
+ ret[index++] = parts[1];
ret[index++] = 0;
ret[index++] = 0;
ret[index++] = 0;
- } else if (typeof currValue == 'object') {
- for (var j = 0; j < currValue.length; j++) {
- ret[index++] = currValue[j];
- }
} else {
- ret[index++] = currValue;
+ currValue = flatten(currValue);
+ if (typeof currValue == 'object') {
+ for (var j = 0; j < currValue.length; j++) {
+ ret[index++] = currValue[j];
+ }
+ } else {
+ ret[index++] = currValue;
+ }
}
i += 1;
}
@@ -400,7 +404,8 @@ function JSify(data, functionsOnly, givenFunctions) {
// name the function; overwrite if it's already named
snippet = snippet.replace(/function(?:\s+([^(]+))?\s*\(/, 'function _' + ident + '(');
if (LIBRARY_DEBUG) {
- snippet = snippet.replace('{', '{ Module.printErr("[library call:' + ident + ': " + Array.prototype.slice.call(arguments) + "]"); ');
+ snippet = snippet.replace('{', '{ var ret = (function() {Module.printErr("[library call:' + ident + ': " + Array.prototype.slice.call(arguments) + "]"); ');
+ snippet = snippet.substr(0, snippet.length-1) + '}).apply(this, arguments); Module.printErr(" [ return:" + ret); return ret; }';
}
}
@@ -1195,6 +1200,12 @@ function JSify(data, functionsOnly, givenFunctions) {
// This is the main pass. Print out the generated code that we have here, together with the
// rest of the output that we started to print out earlier (see comment on the
// "Final shape that will be created").
+ if (PRECISE_I64_MATH && preciseI64MathUsed) {
+ print(read('long.js'));
+ } else {
+ print('// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included');
+ print('var i64Math = null;');
+ }
var generated = itemsDict.functionStub.concat(itemsDict.GlobalVariablePostSet);
generated.forEach(function(item) { print(indentify(item.JS || '', 2)); });
if (RUNTIME_TYPE_INFO) {
diff --git a/src/library.js b/src/library.js
index 78dd629b..6c96bcca 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2487,6 +2487,10 @@ LibraryManager.library = {
var signed = next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0);
argSize = argSize || 4;
var currArg = getNextArg('i' + (argSize * 8));
+#if PRECISE_I64_MATH == 1
+ var origArg = currArg;
+#endif
+ var argText;
#if USE_TYPED_ARRAYS == 2
// Flatten i64-1 [low, high] into a (slightly rounded) double
if (argSize == 8) {
@@ -2500,11 +2504,16 @@ LibraryManager.library = {
}
// Format the number.
var currAbsArg = Math.abs(currArg);
- var argText;
var prefix = '';
if (next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0)) {
+#if PRECISE_I64_MATH == 1
+ if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1]); else
+#endif
argText = reSign(currArg, 8 * argSize, 1).toString(10);
} else if (next == 'u'.charCodeAt(0)) {
+#if PRECISE_I64_MATH == 1
+ if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], true); else
+#endif
argText = unSign(currArg, 8 * argSize, 1).toString(10);
currArg = Math.abs(currArg);
} else if (next == 'o'.charCodeAt(0)) {
@@ -6078,3 +6087,12 @@ LibraryManager.library = {
}
};
+function autoAddDeps(object, name) {
+ name = [name];
+ for (var item in object) {
+ if (item.substr(-6) != '__deps' && !object[item + '__deps']) {
+ object[item + '__deps'] = name;
+ }
+ }
+}
+
diff --git a/src/library_egl.js b/src/library_egl.js
new file mode 100644
index 00000000..6ad226f0
--- /dev/null
+++ b/src/library_egl.js
@@ -0,0 +1,20 @@
+
+var LibraryEGL = {
+ eglGetDisplay: function(x_display) { return 3 },
+ eglInitialize: function(display, majorVersion, minorVersion) { return 1 },
+ eglGetConfigs: function(display, hmm1, hmm2, numConfigs) { return 1 },
+ eglChooseConfig: function(display, attribList, config, hmm, numConfigs) { return 1 },
+ eglCreateWindowSurface: function(display, config, hWnd, hmm) { return 4 },
+
+ eglCreateContext__deps: ['glutCreateWindow', '$GL'],
+ eglCreateContext: function(display, config, hmm, contextAttribs) {
+ _glutCreateWindow();
+ return 1;
+ },
+
+ eglMakeCurrent: function(display, surface, surface, context) { return 1 },
+ eglSwapBuffers: function() {},
+};
+
+mergeInto(LibraryManager.library, LibraryEGL);
+
diff --git a/src/library_gl.js b/src/library_gl.js
index 4651e0d0..8a24a345 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1,54 +1,21 @@
//"use strict";
-// FIXME:
-// * glGetUniformLocation should return -1 when the value is not valid, not null
-// * glUniform1fi should be glUniform1iv
-// * glGetAttribLocation lacks return value (and should be -1 when not valid)
-// * single-underscore deps need double underscore (and, just auto-add them all)
-// * glGetProgramInfoLog and *shader* should be essentially identical
-// * glGetIntegerv set to bool etc needs fixing
-
var LibraryGL = {
$GL: {
- hashtable: function(name) {
- if (!this._hashtables) {
- this._hashtables = {};
- }
- if (!(name in this._hashtables)) {
- this._hashtables[name] = {
- table: {},
- counter: 1,
- add: function(obj) {
- var id = this.counter++;
- this.table[id] = obj;
- return id;
- },
- get: function(id) {
- if( id == 0 ) return null;
-#if ASSERTIONS
- assert(id < this.counter, "Invalid id " + id + " for the hashtable " + name);
-#endif
- return this.table[id];
- },
- id: function(obj) {
- for (var i = 1; i < this.counter; ++i) {
- if (obj == this.table[i]) {
- return i;
- }
- }
- return null;
- },
- remove: function(id) {
- if( id == 0 ) return;
-#if ASSERTIONS
- assert(id < this.counter, "Invalid id " + id + " for the hashtable " + name);
-#endif
- delete this.table[id];
- }
- };
- }
- return this._hashtables[name];
- },
+ buffers: {},
+ bufferCounter: 1,
+ programs: {},
+ programCounter: 1,
+ framebuffers: {},
+ framebufferCounter: 1,
+ renderbuffer: {},
+ renderbufferCounter: 1,
+ textures: {},
+ textureCounter: 1,
+ uniforms: {},
+ uniformCounter: 1,
+ shaders: {},
+ shaderCounter: 1
},
glGetString: function(name_) {
@@ -71,7 +38,7 @@ var LibraryGL = {
{{{ makeSetValue('p', '0', 'result', 'i32') }}};
break;
case "boolean":
- {{{ makeSetValue('p', '0', 'result ? 1 : 0', 'i32') }}};
+ {{{ makeSetValue('p', '0', 'result ? 1 : 0', 'i8') }}};
break;
case "string":
throw 'Native code calling glGetIntegerv(' + name_ + ') on a name which returns a string!';
@@ -83,18 +50,18 @@ var LibraryGL = {
result instanceof Int32Array ||
result instanceof Array) {
for (var i = 0; i < result.length; ++i) {
- {{{ makeSetValue('p', 'i', 'result[i]', 'i32') }}};
+ {{{ makeSetValue('p', 'i*4', 'result[i]', 'i32') }}};
}
} else if (result instanceof WebGLBuffer) {
- {{{ makeSetValue('p', '0', 'GL.hashtable("buffer").id(result)', 'i32') }}};
+ {{{ makeSetValue('p', '0', 'GL.buffers[result]', 'i32') }}};
} else if (result instanceof WebGLProgram) {
- {{{ makeSetValue('p', '0', 'GL.hashtable("program").id(result)', 'i32') }}};
+ {{{ makeSetValue('p', '0', 'GL.programs[result]', 'i32') }}};
} else if (result instanceof WebGLFramebuffer) {
- {{{ makeSetValue('p', '0', 'GL.hashtable("framebuffer").id(result)', 'i32') }}};
+ {{{ makeSetValue('p', '0', 'GL.framebuffers[result]', 'i32') }}};
} else if (result instanceof WebGLRenderbuffer) {
- {{{ makeSetValue('p', '0', 'gl.hashtable("renderbuffer").id(result)', 'i32') }}};
+ {{{ makeSetValue('p', '0', 'GL.renderbuffers[result]', 'i32') }}};
} else if (result instanceof WebGLTexture) {
- {{{ makeSetValue('p', '0', 'gl.hashtable("texture").id(result)', 'i32') }}};
+ {{{ makeSetValue('p', '0', 'GL.textures[result]', 'i32') }}};
} else {
throw 'Unknown object returned from WebGL getParameter';
}
@@ -125,18 +92,18 @@ var LibraryGL = {
result instanceof Int32Array ||
result instanceof Array) {
for (var i = 0; i < result.length; ++i) {
- {{{ makeSetValue('p', 'i', 'result[i]', 'float') }}};
+ {{{ makeSetValue('p', 'i*4', 'result[i]', 'float') }}};
}
} else if (result instanceof WebGLBuffer) {
- {{{ makeSetValue('p', '0', 'GL.hashtable("buffer").id(result)', 'float') }}};
+ {{{ makeSetValue('p', '0', 'GL.buffers[result]', 'float') }}};
} else if (result instanceof WebGLProgram) {
- {{{ makeSetValue('p', '0', 'GL.hashtable("program").id(result)', 'float') }}};
+ {{{ makeSetValue('p', '0', 'GL.programs[result]', 'float') }}};
} else if (result instanceof WebGLFramebuffer) {
- {{{ makeSetValue('p', '0', 'GL.hashtable("framebuffer").id(result)', 'float') }}};
+ {{{ makeSetValue('p', '0', 'GL.framebuffers[result]', 'float') }}};
} else if (result instanceof WebGLRenderbuffer) {
- {{{ makeSetValue('p', '0', 'gl.hashtable("renderbuffer").id(result)', 'float') }}};
+ {{{ makeSetValue('p', '0', 'gl.renderbuffers[result]', 'float') }}};
} else if (result instanceof WebGLTexture) {
- {{{ makeSetValue('p', '0', 'gl.hashtable("texture").id(result)', 'float') }}};
+ {{{ makeSetValue('p', '0', 'gl.textures[result]', 'float') }}};
} else {
throw 'Unknown object returned from WebGL getParameter';
}
@@ -186,19 +153,19 @@ var LibraryGL = {
}
},
- glGenTextures__deps: ['$GL'],
glGenTextures: function(n, textures) {
for (var i = 0; i < n; i++) {
- var id = GL.hashtable("texture").add(Module.ctx.createTexture());
- {{{ makeSetValue('textures', 'i', 'id', 'i32') }}};
+ var id = GL.textureCounter++;
+ GL.textures[id] = Module.ctx.createTexture();
+ {{{ makeSetValue('textures', 'i*4', 'id', 'i32') }}};
}
},
glDeleteTextures: function(n, textures) {
for (var i = 0; i < n; i++) {
- var id = {{{ makeGetValue('textures', 'i', 'i32') }}};
- Module.ctx.deleteTexture(GL.hashtable("texture").get(id));
- GL.hashtable("texture").remove(id);
+ var id = {{{ makeGetValue('textures', 'i*4', 'i32') }}};
+ Module.ctx.deleteTexture(GL.textures[id]);
+ GL.textures[id] = null;
}
},
@@ -299,7 +266,7 @@ var LibraryGL = {
},
glBindTexture: function(target, texture) {
- Module.ctx.bindTexture(target, GL.hashtable("texture").get(texture));
+ Module.ctx.bindTexture(target, GL.textures[texture]);
},
glGetTexParameterfv: function(target, pname, params) {
@@ -310,34 +277,32 @@ var LibraryGL = {
{{{ makeSetValue('params', '0', 'Module.getTexParameter(target, pname)', 'i32') }}};
},
- glIsTexture_deps: ['$GL'],
glIsTexture: function(texture) {
- var fb = GL.hashtable("texture").get(texture);
+ var fb = GL.textures[texture];
if (typeof(fb) == 'undefined') {
return false;
}
return Module.ctx.isTexture(fb);
},
- glGenBuffers__deps: ['$GL'],
glGenBuffers: function(n, buffers) {
for (var i = 0; i < n; i++) {
- var id = GL.hashtable("buffer").add(Module.ctx.createBuffer());
- {{{ makeSetValue('buffers', 'i', 'id', 'i32') }}};
+ var id = GL.bufferCounter++;
+ GL.buffers[id] = Module.ctx.createBuffer();
+ {{{ makeSetValue('buffers', 'i*4', 'id', 'i32') }}};
}
},
glDeleteBuffers: function(n, buffers) {
for (var i = 0; i < n; i++) {
- var id = {{{ makeGetValue('buffers', 'i', 'i32') }}};
- Module.ctx.deleteBuffer(GL.hashtable("buffer").get(id));
- GL.hashtable("buffer").remove(id);
+ var id = {{{ makeGetValue('buffers', 'i*4', 'i32') }}};
+ Module.ctx.deleteBuffer(GL.buffers[id]);
+ GL.buffers[id] = null;
}
},
glBufferData: function(target, size, data, usage) {
- var floatArray = new Float32Array(TypedArray_copy(data, size));
- Module.ctx.bufferData(target, floatArray, usage);
+ Module.ctx.bufferData(target, HEAPU8.subarray(data, data+size), usage);
},
glBufferSubData: function(target, offset, size, data) {
@@ -345,172 +310,145 @@ var LibraryGL = {
Module.ctx.bufferSubData(target, offset, floatArray);
},
- glIsBuffer_deps: ['$GL'],
glIsBuffer: function(buffer) {
- var fb = GL.hashtable("buffer").get(buffer);
+ var fb = GL.buffers[buffer];
if (typeof(fb) == 'undefined') {
return false;
}
return Module.ctx.isBuffer(fb);
},
- glGenRenderbuffers__deps: ['$GL'],
glGenRenderbuffers: function(n, renderbuffers) {
for (var i = 0; i < n; i++) {
- var id = GL.hashtable("renderbuffer").add(Module.ctx.createRenderbuffer());
- {{{ makeSetValue('renderbuffers', 'i', 'id', 'i32') }}};
+ var id = GL.renderbufferCounter++;
+ GL.renderbuffers[id] = Module.ctx.createRenderbuffer();
+ {{{ makeSetValue('renderbuffers', 'i*4', 'id', 'i32') }}};
}
},
glDeleteRenderbuffers: function(n, renderbuffers) {
for (var i = 0; i < n; i++) {
- var id = {{{ makeGetValue('renderbuffers', 'i', 'i32') }}};
- Module.ctx.deleteRenderbuffer(GL.hashtable("renderbuffer").get(id));
- GL.hashtable("renderbuffer").remove(id);
+ var id = {{{ makeGetValue('renderbuffers', 'i*4', 'i32') }}};
+ Module.ctx.deleteRenderbuffer(GL.renderbuffers[id]);
+ GL.renderbuffers[id];
}
},
glBindRenderbuffer: function(target, renderbuffer) {
- Module.ctx.bindRenderbuffer(target, GL.hashtable("renderbuffer").get(renderbuffer));
+ Module.ctx.bindRenderbuffer(target, GL.renderbuffers[renderbuffer]);
},
glGetRenderbufferParameteriv: function(target, pname, params) {
{{{ makeSetValue('params', '0', 'Module.ctx.getRenderbufferParameter(target, pname)', 'i32') }}};
},
- glIsRenderbuffer_deps: ['$GL'],
glIsRenderbuffer: function(renderbuffer) {
- var fb = GL.hashtable("renderbuffer").get(renderbuffer);
+ var fb = GL.renderbuffers[renderbuffer];
if (typeof(fb) == 'undefined') {
return false;
}
return Module.ctx.isRenderbuffer(fb);
},
- glBindAttribLocation_deps: ['$GL'],
glGetUniformLocation: function(program, name) {
name = Pointer_stringify(name);
- return GL.hashtable("uniform").add(
- Module.ctx.getUn