webruby 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webruby/config.rb +4 -9
- data/lib/webruby/rake/files.rake +2 -2
- data/modules/emscripten/AUTHORS +9 -1
- data/modules/emscripten/CONTRIBUTING.markdown +5 -0
- data/modules/emscripten/ChangeLog +435 -0
- data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
- data/modules/emscripten/em++ +0 -2
- data/modules/emscripten/emcc +92 -32
- data/modules/emscripten/emlink.py +16 -13
- data/modules/emscripten/emmake +1 -1
- data/modules/emscripten/emrun +918 -0
- data/modules/emscripten/emrun.bat +2 -0
- data/modules/emscripten/emscripten.py +545 -20
- data/modules/emscripten/src/analyzer.js +6 -1
- data/modules/emscripten/src/compiler.js +25 -16
- data/modules/emscripten/src/emrun_postjs.js +20 -0
- data/modules/emscripten/{tests → src}/hello_world.js +0 -0
- data/modules/emscripten/src/intertyper.js +45 -16
- data/modules/emscripten/src/jsifier.js +78 -48
- data/modules/emscripten/src/library.js +381 -96
- data/modules/emscripten/src/library_browser.js +50 -53
- data/modules/emscripten/src/library_egl.js +66 -24
- data/modules/emscripten/src/library_fs.js +122 -90
- data/modules/emscripten/src/library_gl.js +739 -353
- data/modules/emscripten/src/library_glfw.js +9 -3
- data/modules/emscripten/src/library_glut.js +10 -5
- data/modules/emscripten/src/library_idbfs.js +14 -14
- data/modules/emscripten/src/library_memfs.js +65 -41
- data/modules/emscripten/src/library_nodefs.js +61 -9
- data/modules/emscripten/src/library_openal.js +4 -4
- data/modules/emscripten/src/library_path.js +9 -13
- data/modules/emscripten/src/library_sdl.js +301 -64
- data/modules/emscripten/src/library_sockfs.js +7 -5
- data/modules/emscripten/src/modules.js +62 -22
- data/modules/emscripten/src/parseTools.js +135 -102
- data/modules/emscripten/src/postamble.js +3 -4
- data/modules/emscripten/src/preamble.js +49 -29
- data/modules/emscripten/src/proxyClient.js +1 -1
- data/modules/emscripten/src/proxyWorker.js +10 -10
- data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
- data/modules/emscripten/src/runtime.js +32 -8
- data/modules/emscripten/src/settings.js +25 -8
- data/modules/emscripten/src/shell.html +6 -3
- data/modules/emscripten/src/shell.js +13 -11
- data/modules/emscripten/src/simd.js +602 -432
- data/modules/emscripten/src/struct_info.json +22 -2
- data/modules/emscripten/src/utility.js +32 -17
- data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
- data/modules/emscripten/system/include/compat/ctype.h +17 -0
- data/modules/emscripten/system/include/compat/wchar.h +23 -0
- data/modules/emscripten/system/include/compat/wctype.h +23 -0
- data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
- data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
- data/modules/emscripten/system/include/emscripten/vector.h +29 -1
- data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
- data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
- data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
- data/modules/emscripten/system/include/libcxx/__config +95 -17
- data/modules/emscripten/system/include/libcxx/__debug +25 -4
- data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
- data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
- data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
- data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
- data/modules/emscripten/system/include/libcxx/__locale +21 -19
- data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
- data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
- data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
- data/modules/emscripten/system/include/libcxx/__tree +35 -26
- data/modules/emscripten/system/include/libcxx/__tuple +15 -15
- data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
- data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
- data/modules/emscripten/system/include/libcxx/algorithm +121 -110
- data/modules/emscripten/system/include/libcxx/array +15 -15
- data/modules/emscripten/system/include/libcxx/bitset +4 -4
- data/modules/emscripten/system/include/libcxx/chrono +51 -17
- data/modules/emscripten/system/include/libcxx/cmath +25 -23
- data/modules/emscripten/system/include/libcxx/codecvt +21 -18
- data/modules/emscripten/system/include/libcxx/complex +48 -7
- data/modules/emscripten/system/include/libcxx/cstddef +1 -1
- data/modules/emscripten/system/include/libcxx/cstdio +8 -1
- data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
- data/modules/emscripten/system/include/libcxx/cwchar +1 -1
- data/modules/emscripten/system/include/libcxx/deque +26 -12
- data/modules/emscripten/system/include/libcxx/dynarray +311 -0
- data/modules/emscripten/system/include/libcxx/exception +4 -4
- data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
- data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
- data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
- data/modules/emscripten/system/include/libcxx/forward_list +33 -7
- data/modules/emscripten/system/include/libcxx/fstream +4 -4
- data/modules/emscripten/system/include/libcxx/functional +200 -170
- data/modules/emscripten/system/include/libcxx/future +83 -39
- data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
- data/modules/emscripten/system/include/libcxx/iomanip +147 -0
- data/modules/emscripten/system/include/libcxx/ios +24 -16
- data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
- data/modules/emscripten/system/include/libcxx/istream +13 -8
- data/modules/emscripten/system/include/libcxx/iterator +108 -417
- data/modules/emscripten/system/include/libcxx/limits +8 -4
- data/modules/emscripten/system/include/libcxx/list +28 -8
- data/modules/emscripten/system/include/libcxx/locale +153 -390
- data/modules/emscripten/system/include/libcxx/map +280 -100
- data/modules/emscripten/system/include/libcxx/memory +49 -97
- data/modules/emscripten/system/include/libcxx/mutex +2 -2
- data/modules/emscripten/system/include/libcxx/new +43 -14
- data/modules/emscripten/system/include/libcxx/numeric +2 -2
- data/modules/emscripten/system/include/libcxx/optional +697 -0
- data/modules/emscripten/system/include/libcxx/ostream +17 -8
- data/modules/emscripten/system/include/libcxx/queue +5 -5
- data/modules/emscripten/system/include/libcxx/random +53 -51
- data/modules/emscripten/system/include/libcxx/ratio +11 -11
- data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/include/libcxx/regex +23 -20
- data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
- data/modules/emscripten/system/include/libcxx/set +166 -2
- data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
- data/modules/emscripten/system/include/libcxx/sstream +4 -4
- data/modules/emscripten/system/include/libcxx/stack +3 -3
- data/modules/emscripten/system/include/libcxx/streambuf +5 -5
- data/modules/emscripten/system/include/libcxx/string +372 -324
- data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
- data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
- data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
- data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
- data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
- data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
- data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
- data/modules/emscripten/system/include/libcxx/system_error +14 -8
- data/modules/emscripten/system/include/libcxx/thread +7 -8
- data/modules/emscripten/system/include/libcxx/tuple +29 -88
- data/modules/emscripten/system/include/libcxx/type_traits +253 -209
- data/modules/emscripten/system/include/libcxx/typeindex +3 -3
- data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
- data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
- data/modules/emscripten/system/include/libcxx/utility +20 -20
- data/modules/emscripten/system/include/libcxx/valarray +23 -23
- data/modules/emscripten/system/include/libcxx/vector +114 -91
- data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
- data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
- data/modules/emscripten/system/lib/libcextra.symbols +7 -0
- data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
- data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
- data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
- data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
- data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
- data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
- data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
- data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
- data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
- data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
- data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
- data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
- data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
- data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
- data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
- data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
- data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
- data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
- data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
- data/modules/emscripten/system/lib/libcxx/symbols +187 -168
- data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
- data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
- data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
- data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
- data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
- data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
- data/modules/emscripten/tools/cache.py +5 -7
- data/modules/emscripten/tools/cache.pyc +0 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
- data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
- data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
- data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
- data/modules/emscripten/tools/file_packager.py +93 -50
- data/modules/emscripten/tools/js-optimizer.js +98 -48
- data/modules/emscripten/tools/js_optimizer.py +4 -4
- data/modules/emscripten/tools/js_optimizer.pyc +0 -0
- data/modules/emscripten/tools/jsrun.py +1 -1
- data/modules/emscripten/tools/jsrun.pyc +0 -0
- data/modules/emscripten/tools/response_file.py +6 -0
- data/modules/emscripten/tools/response_file.pyc +0 -0
- data/modules/emscripten/tools/settings_template_readonly.py +2 -0
- data/modules/emscripten/tools/shared.py +88 -34
- data/modules/emscripten/tools/shared.pyc +0 -0
- data/modules/emscripten/tools/split.py +21 -13
- data/modules/mruby/build_config.rb +7 -1
- data/modules/mruby/doc/compile/README.md +5 -9
- data/modules/mruby/include/mrbconf.h +5 -2
- data/modules/mruby/include/mruby/array.h +1 -0
- data/modules/mruby/include/mruby/compile.h +2 -4
- data/modules/mruby/include/mruby/dump.h +7 -16
- data/modules/mruby/include/mruby/hash.h +1 -1
- data/modules/mruby/include/mruby/irep.h +14 -2
- data/modules/mruby/include/mruby/khash.h +8 -7
- data/modules/mruby/include/mruby/string.h +1 -0
- data/modules/mruby/include/mruby/value.h +5 -2
- data/modules/mruby/include/mruby.h +12 -13
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
- data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
- data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
- data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
- data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
- data/modules/mruby/mrblib/numeric.rb +99 -33
- data/modules/mruby/src/array.c +11 -4
- data/modules/mruby/src/backtrace.c +2 -2
- data/modules/mruby/src/class.c +49 -30
- data/modules/mruby/src/codegen.c +131 -79
- data/modules/mruby/src/debug.c +1 -1
- data/modules/mruby/src/dump.c +213 -163
- data/modules/mruby/src/error.c +17 -17
- data/modules/mruby/src/error.h +1 -1
- data/modules/mruby/src/etc.c +10 -0
- data/modules/mruby/src/gc.c +35 -17
- data/modules/mruby/src/hash.c +5 -5
- data/modules/mruby/src/kernel.c +36 -14
- data/modules/mruby/src/load.c +238 -296
- data/modules/mruby/src/numeric.c +18 -98
- data/modules/mruby/src/object.c +3 -5
- data/modules/mruby/src/parse.y +63 -56
- data/modules/mruby/src/proc.c +8 -5
- data/modules/mruby/src/re.h +0 -1
- data/modules/mruby/src/state.c +65 -27
- data/modules/mruby/src/string.c +3 -31
- data/modules/mruby/src/symbol.c +3 -3
- data/modules/mruby/src/variable.c +12 -5
- data/modules/mruby/src/vm.c +90 -72
- data/modules/mruby/tasks/mruby_build.rake +10 -1
- data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
- data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
- data/modules/mruby/test/driver.c +3 -3
- data/modules/mruby/test/t/array.rb +5 -5
- data/modules/mruby/test/t/class.rb +14 -1
- data/modules/mruby/test/t/kernel.rb +4 -0
- data/modules/mruby/test/t/module.rb +4 -4
- data/modules/mruby/test/t/nameerror.rb +1 -1
- data/modules/mruby/tools/mrbc/mrbc.c +23 -17
- data/modules/mruby/travis_config.rb +10 -1
- metadata +28 -5
- data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -4,12 +4,12 @@
|
|
4
4
|
|
5
5
|
mergeInto(LibraryManager.library, {
|
6
6
|
$Browser__deps: ['$PATH'],
|
7
|
-
$Browser__postset: 'Module["requestFullScreen"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports
|
8
|
-
'Module["requestAnimationFrame"] = function(func) { Browser.requestAnimationFrame(func) };\n' +
|
9
|
-
'Module["setCanvasSize"] = function(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };\n' +
|
10
|
-
'Module["pauseMainLoop"] = function() { Browser.mainLoop.pause() };\n' +
|
11
|
-
'Module["resumeMainLoop"] = function() { Browser.mainLoop.resume() };\n' +
|
12
|
-
'Module["getUserMedia"] = function() { Browser.getUserMedia() }',
|
7
|
+
$Browser__postset: 'Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports
|
8
|
+
'Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };\n' +
|
9
|
+
'Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };\n' +
|
10
|
+
'Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };\n' +
|
11
|
+
'Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };\n' +
|
12
|
+
'Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }',
|
13
13
|
$Browser: {
|
14
14
|
mainLoop: {
|
15
15
|
scheduler: null,
|
@@ -77,10 +77,10 @@ mergeInto(LibraryManager.library, {
|
|
77
77
|
// might create some side data structure for use later (like an Image element, etc.).
|
78
78
|
|
79
79
|
var imagePlugin = {};
|
80
|
-
imagePlugin['canHandle'] = function(name) {
|
80
|
+
imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
|
81
81
|
return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
|
82
82
|
};
|
83
|
-
imagePlugin['handle'] = function(byteArray, name, onload, onerror) {
|
83
|
+
imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
|
84
84
|
var b = null;
|
85
85
|
if (Browser.hasBlobConstructor) {
|
86
86
|
try {
|
@@ -103,7 +103,7 @@ mergeInto(LibraryManager.library, {
|
|
103
103
|
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
|
104
104
|
#endif
|
105
105
|
var img = new Image();
|
106
|
-
img.onload = function() {
|
106
|
+
img.onload = function img_onload() {
|
107
107
|
assert(img.complete, 'Image ' + name + ' could not be decoded');
|
108
108
|
var canvas = document.createElement('canvas');
|
109
109
|
canvas.width = img.width;
|
@@ -114,7 +114,7 @@ mergeInto(LibraryManager.library, {
|
|
114
114
|
Browser.URLObject.revokeObjectURL(url);
|
115
115
|
if (onload) onload(byteArray);
|
116
116
|
};
|
117
|
-
img.onerror = function(event) {
|
117
|
+
img.onerror = function img_onerror(event) {
|
118
118
|
console.log('Image ' + url + ' could not be decoded');
|
119
119
|
if (onerror) onerror();
|
120
120
|
};
|
@@ -123,10 +123,10 @@ mergeInto(LibraryManager.library, {
|
|
123
123
|
Module['preloadPlugins'].push(imagePlugin);
|
124
124
|
|
125
125
|
var audioPlugin = {};
|
126
|
-
audioPlugin['canHandle'] = function(name) {
|
126
|
+
audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
|
127
127
|
return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
|
128
128
|
};
|
129
|
-
audioPlugin['handle'] = function(byteArray, name, onload, onerror) {
|
129
|
+
audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
|
130
130
|
var done = false;
|
131
131
|
function finish(audio) {
|
132
132
|
if (done) return;
|
@@ -152,7 +152,7 @@ mergeInto(LibraryManager.library, {
|
|
152
152
|
#endif
|
153
153
|
var audio = new Audio();
|
154
154
|
audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
|
155
|
-
audio.onerror = function(event) {
|
155
|
+
audio.onerror = function audio_onerror(event) {
|
156
156
|
if (done) return;
|
157
157
|
console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
|
158
158
|
function encode64(data) {
|
@@ -250,13 +250,24 @@ mergeInto(LibraryManager.library, {
|
|
250
250
|
contextAttributes.preserveDrawingBuffer = true;
|
251
251
|
#endif
|
252
252
|
|
253
|
-
|
253
|
+
var errorInfo = '?';
|
254
|
+
function onContextCreationError(event) {
|
255
|
+
errorInfo = event.statusMessage || errorInfo;
|
256
|
+
}
|
257
|
+
canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
|
258
|
+
try {
|
259
|
+
['experimental-webgl', 'webgl'].some(function(webglId) {
|
260
|
+
return ctx = canvas.getContext(webglId, contextAttributes);
|
261
|
+
});
|
262
|
+
} finally {
|
263
|
+
canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
|
264
|
+
}
|
254
265
|
} else {
|
255
266
|
ctx = canvas.getContext('2d');
|
256
267
|
}
|
257
268
|
if (!ctx) throw ':(';
|
258
269
|
} catch (e) {
|
259
|
-
Module.print('Could not create canvas
|
270
|
+
Module.print('Could not create canvas: ' + [errorInfo, e]);
|
260
271
|
return null;
|
261
272
|
}
|
262
273
|
if (useWebGL) {
|
@@ -268,7 +279,7 @@ mergeInto(LibraryManager.library, {
|
|
268
279
|
(function(prop) {
|
269
280
|
switch (typeof tempCtx[prop]) {
|
270
281
|
case 'function': {
|
271
|
-
wrapper[prop] = function() {
|
282
|
+
wrapper[prop] = function gl_wrapper() {
|
272
283
|
if (GL.debug) {
|
273
284
|
var printArgs = Array.prototype.slice.call(arguments).map(Runtime.prettyPrint);
|
274
285
|
Module.printErr('[gl_f:' + prop + ':' + printArgs + ']');
|
@@ -359,16 +370,20 @@ mergeInto(LibraryManager.library, {
|
|
359
370
|
canvas.requestFullScreen();
|
360
371
|
},
|
361
372
|
|
362
|
-
requestAnimationFrame: function(func) {
|
363
|
-
if (
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
373
|
+
requestAnimationFrame: function requestAnimationFrame(func) {
|
374
|
+
if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
|
375
|
+
setTimeout(func, 1000/60);
|
376
|
+
} else {
|
377
|
+
if (!window.requestAnimationFrame) {
|
378
|
+
window.requestAnimationFrame = window['requestAnimationFrame'] ||
|
379
|
+
window['mozRequestAnimationFrame'] ||
|
380
|
+
window['webkitRequestAnimationFrame'] ||
|
381
|
+
window['msRequestAnimationFrame'] ||
|
382
|
+
window['oRequestAnimationFrame'] ||
|
383
|
+
window['setTimeout'];
|
384
|
+
}
|
385
|
+
window.requestAnimationFrame(func);
|
370
386
|
}
|
371
|
-
window.requestAnimationFrame(func);
|
372
387
|
},
|
373
388
|
|
374
389
|
// generic abort-aware wrapper for an async callback
|
@@ -497,7 +512,7 @@ mergeInto(LibraryManager.library, {
|
|
497
512
|
var xhr = new XMLHttpRequest();
|
498
513
|
xhr.open('GET', url, true);
|
499
514
|
xhr.responseType = 'arraybuffer';
|
500
|
-
xhr.onload = function() {
|
515
|
+
xhr.onload = function xhr_onload() {
|
501
516
|
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
|
502
517
|
onload(xhr.response);
|
503
518
|
} else {
|
@@ -610,7 +625,7 @@ mergeInto(LibraryManager.library, {
|
|
610
625
|
http.responseType = 'arraybuffer';
|
611
626
|
|
612
627
|
// LOAD
|
613
|
-
http.onload = function(e) {
|
628
|
+
http.onload = function http_onload(e) {
|
614
629
|
if (http.status == 200) {
|
615
630
|
FS.createDataFile( _file.substr(0, index), _file.substr(index + 1), new Uint8Array(http.response), true, true);
|
616
631
|
if (onload) Runtime.dynCall('vii', onload, [arg, file]);
|
@@ -620,12 +635,12 @@ mergeInto(LibraryManager.library, {
|
|
620
635
|
};
|
621
636
|
|
622
637
|
// ERROR
|
623
|
-
http.onerror = function(e) {
|
638
|
+
http.onerror = function http_onerror(e) {
|
624
639
|
if (onerror) Runtime.dynCall('vii', onerror, [arg, http.status]);
|
625
640
|
};
|
626
641
|
|
627
642
|
// PROGRESS
|
628
|
-
http.onprogress = function(e) {
|
643
|
+
http.onprogress = function http_onprogress(e) {
|
629
644
|
var percentComplete = (e.position / e.totalSize)*100;
|
630
645
|
if (onprogress) Runtime.dynCall('vii', onprogress, [arg, percentComplete]);
|
631
646
|
};
|
@@ -705,7 +720,7 @@ mergeInto(LibraryManager.library, {
|
|
705
720
|
|
706
721
|
assert(runDependencies === 0, 'async_load_script must be run when no other dependencies are active');
|
707
722
|
var script = document.createElement('script');
|
708
|
-
script.onload = function() {
|
723
|
+
script.onload = function script_onload() {
|
709
724
|
if (runDependencies > 0) {
|
710
725
|
dependenciesFulfilled = onload;
|
711
726
|
} else {
|
@@ -720,7 +735,7 @@ mergeInto(LibraryManager.library, {
|
|
720
735
|
emscripten_set_main_loop: function(func, fps, simulateInfiniteLoop) {
|
721
736
|
Module['noExitRuntime'] = true;
|
722
737
|
|
723
|
-
Browser.mainLoop.runner = function() {
|
738
|
+
Browser.mainLoop.runner = function Browser_mainLoop_runner() {
|
724
739
|
if (ABORT) return;
|
725
740
|
if (Browser.mainLoop.queue.length > 0) {
|
726
741
|
var start = Date.now();
|
@@ -777,11 +792,11 @@ mergeInto(LibraryManager.library, {
|
|
777
792
|
Browser.mainLoop.scheduler();
|
778
793
|
}
|
779
794
|
if (fps && fps > 0) {
|
780
|
-
Browser.mainLoop.scheduler = function() {
|
795
|
+
Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() {
|
781
796
|
setTimeout(Browser.mainLoop.runner, 1000/fps); // doing this each time means that on exception, we stop
|
782
797
|
}
|
783
798
|
} else {
|
784
|
-
Browser.mainLoop.scheduler = function() {
|
799
|
+
Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() {
|
785
800
|
Browser.requestAnimationFrame(Browser.mainLoop.runner);
|
786
801
|
}
|
787
802
|
}
|
@@ -848,7 +863,7 @@ mergeInto(LibraryManager.library, {
|
|
848
863
|
var styleSheet = document.styleSheets[0];
|
849
864
|
var rules = styleSheet.cssRules;
|
850
865
|
for (var i = 0; i < rules.length; i++) {
|
851
|
-
if (rules[i].cssText.substr(0,
|
866
|
+
if (rules[i].cssText.substr(0, 6) == 'canvas') {
|
852
867
|
styleSheet.deleteRule(i);
|
853
868
|
i--;
|
854
869
|
}
|
@@ -867,24 +882,6 @@ mergeInto(LibraryManager.library, {
|
|
867
882
|
{{{ makeSetValue('isFullscreen', '0', 'Browser.isFullScreen ? 1 : 0', 'i32') }}};
|
868
883
|
},
|
869
884
|
|
870
|
-
emscripten_get_now: function() {
|
871
|
-
if (!_emscripten_get_now.actual) {
|
872
|
-
if (ENVIRONMENT_IS_NODE) {
|
873
|
-
_emscripten_get_now.actual = function() {
|
874
|
-
var t = process['hrtime']();
|
875
|
-
return t[0] * 1e3 + t[1] / 1e6;
|
876
|
-
}
|
877
|
-
} else if (typeof dateNow !== 'undefined') {
|
878
|
-
_emscripten_get_now.actual = dateNow;
|
879
|
-
} else if (ENVIRONMENT_IS_WEB && window['performance'] && window['performance']['now']) {
|
880
|
-
_emscripten_get_now.actual = function() { return window['performance']['now'](); };
|
881
|
-
} else {
|
882
|
-
_emscripten_get_now.actual = Date.now;
|
883
|
-
}
|
884
|
-
}
|
885
|
-
return _emscripten_get_now.actual();
|
886
|
-
},
|
887
|
-
|
888
885
|
emscripten_create_worker: function(url) {
|
889
886
|
url = Pointer_stringify(url);
|
890
887
|
var id = Browser.workers.length;
|
@@ -895,7 +892,7 @@ mergeInto(LibraryManager.library, {
|
|
895
892
|
buffer: 0,
|
896
893
|
bufferSize: 0
|
897
894
|
};
|
898
|
-
info.worker.onmessage = function(msg) {
|
895
|
+
info.worker.onmessage = function info_worker_onmessage(msg) {
|
899
896
|
var info = Browser.workers[id];
|
900
897
|
if (!info) return; // worker was destroyed meanwhile
|
901
898
|
var callbackId = msg.data['callbackId'];
|
@@ -9,10 +9,16 @@
|
|
9
9
|
var LibraryEGL = {
|
10
10
|
$EGL: {
|
11
11
|
// This variable tracks the success status of the most recently invoked EGL function call.
|
12
|
-
|
12
|
+
errorCode: 0x3000 /* EGL_SUCCESS */,
|
13
|
+
defaultDisplayInitialized: false,
|
14
|
+
currentContext: 0 /* EGL_NO_CONTEXT */,
|
15
|
+
currentReadSurface: 0 /* EGL_NO_SURFACE */,
|
16
|
+
currentDrawSurface: 0 /* EGL_NO_SURFACE */,
|
17
|
+
|
18
|
+
stringCache: {},
|
13
19
|
|
14
20
|
setErrorCode: function(code) {
|
15
|
-
EGL.
|
21
|
+
EGL.errorCode = code;
|
16
22
|
},
|
17
23
|
|
18
24
|
chooseConfig: function(display, attribList, config, config_size, numConfigs) {
|
@@ -63,6 +69,7 @@ var LibraryEGL = {
|
|
63
69
|
if (minorVersion) {
|
64
70
|
{{{ makeSetValue('minorVersion', '0', '4', 'i32') }}}; // Advertise EGL Minor version: '4'
|
65
71
|
}
|
72
|
+
EGL.defaultDisplayInitialized = true;
|
66
73
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
67
74
|
return 1;
|
68
75
|
}
|
@@ -78,18 +85,10 @@ var LibraryEGL = {
|
|
78
85
|
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
|
79
86
|
return 0;
|
80
87
|
}
|
81
|
-
|
82
|
-
EGL.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
// EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
|
87
|
-
eglTerminate: function(display) {
|
88
|
-
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
|
89
|
-
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
|
90
|
-
return 0;
|
91
|
-
}
|
92
|
-
// TODO: Tear down EGL here. Currently a no-op since we don't need to actually do anything here for the browser.
|
88
|
+
EGL.currentContext = 0;
|
89
|
+
EGL.currentReadSurface = 0;
|
90
|
+
EGL.currentDrawSurface = 0;
|
91
|
+
EGL.defaultDisplayInitialized = false;
|
93
92
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
94
93
|
return 1;
|
95
94
|
},
|
@@ -246,6 +245,12 @@ var LibraryEGL = {
|
|
246
245
|
EGL.setErrorCode(0x300D /* EGL_BAD_SURFACE */);
|
247
246
|
return 1;
|
248
247
|
}
|
248
|
+
if (EGL.currentReadSurface == surface) {
|
249
|
+
EGL.currentReadSurface = 0;
|
250
|
+
}
|
251
|
+
if (EGL.currentDrawSurface == surface) {
|
252
|
+
EGL.currentDrawSurface = 0;
|
253
|
+
}
|
249
254
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
250
255
|
return 1; /* Magic ID for Emscripten 'default surface' */
|
251
256
|
},
|
@@ -263,6 +268,7 @@ var LibraryEGL = {
|
|
263
268
|
EGL.windowID = _glutCreateWindow();
|
264
269
|
if (EGL.windowID != 0) {
|
265
270
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
271
|
+
// Note: This function only creates a context, but it shall not make it active.
|
266
272
|
return 62004; // Magic ID for Emscripten EGLContext
|
267
273
|
} else {
|
268
274
|
EGL.setErrorCode(0x3009 /* EGL_BAD_MATCH */); // By the EGL 1.4 spec, an implementation that does not support GLES2 (WebGL in this case), this error code is set.
|
@@ -278,10 +284,17 @@ var LibraryEGL = {
|
|
278
284
|
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
|
279
285
|
return 0;
|
280
286
|
}
|
287
|
+
if (context != 62004 /* Magic ID for Emscripten EGLContext */) {
|
288
|
+
EGL.setErrorCode(0x3006 /* EGL_BAD_CONTEXT */);
|
289
|
+
return 0;
|
290
|
+
}
|
281
291
|
|
282
292
|
_glutDestroyWindow(EGL.windowID);
|
283
293
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
284
|
-
|
294
|
+
if (EGL.currentContext == context) {
|
295
|
+
EGL.currentContext = 0;
|
296
|
+
}
|
297
|
+
return 1 /* EGL_TRUE */;
|
285
298
|
},
|
286
299
|
|
287
300
|
// EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
|
@@ -405,7 +418,7 @@ var LibraryEGL = {
|
|
405
418
|
|
406
419
|
// EGLAPI EGLint EGLAPIENTRY eglGetError(void);
|
407
420
|
eglGetError: function() {
|
408
|
-
return EGL.
|
421
|
+
return EGL.errorCode;
|
409
422
|
},
|
410
423
|
|
411
424
|
// EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
|
@@ -416,15 +429,19 @@ var LibraryEGL = {
|
|
416
429
|
}
|
417
430
|
//\todo An EGL_NOT_INITIALIZED error is generated if EGL is not initialized for dpy.
|
418
431
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
432
|
+
if (EGL.stringCache[name]) return EGL.stringCache[name];
|
433
|
+
var ret;
|
419
434
|
switch(name) {
|
420
|
-
case 0x3053 /* EGL_VENDOR */:
|
421
|
-
case 0x3054 /* EGL_VERSION */:
|
422
|
-
case 0x3055 /* EGL_EXTENSIONS */:
|
423
|
-
case 0x308D /* EGL_CLIENT_APIS */:
|
435
|
+
case 0x3053 /* EGL_VENDOR */: ret = allocate(intArrayFromString("Emscripten"), 'i8', ALLOC_NORMAL); break;
|
436
|
+
case 0x3054 /* EGL_VERSION */: ret = allocate(intArrayFromString("1.4 Emscripten EGL"), 'i8', ALLOC_NORMAL); break;
|
437
|
+
case 0x3055 /* EGL_EXTENSIONS */: ret = allocate(intArrayFromString(""), 'i8', ALLOC_NORMAL); break; // Currently not supporting any EGL extensions.
|
438
|
+
case 0x308D /* EGL_CLIENT_APIS */: ret = allocate(intArrayFromString("OpenGL_ES"), 'i8', ALLOC_NORMAL); break;
|
424
439
|
default:
|
425
440
|
EGL.setErrorCode(0x300C /* EGL_BAD_PARAMETER */);
|
426
441
|
return 0;
|
427
442
|
}
|
443
|
+
EGL.stringCache[name] = ret;
|
444
|
+
return ret;
|
428
445
|
},
|
429
446
|
|
430
447
|
// EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
|
@@ -471,21 +488,46 @@ var LibraryEGL = {
|
|
471
488
|
eglMakeCurrent: function(display, draw, read, context) {
|
472
489
|
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
|
473
490
|
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
|
474
|
-
return 0
|
491
|
+
return 0 /* EGL_FALSE */;
|
475
492
|
}
|
476
493
|
//\todo An EGL_NOT_INITIALIZED error is generated if EGL is not initialized for dpy.
|
477
|
-
if (context != 62004 /* Magic ID for Emscripten EGLContext */) {
|
494
|
+
if (context != 0 && context != 62004 /* Magic ID for Emscripten EGLContext */) {
|
478
495
|
EGL.setErrorCode(0x3006 /* EGL_BAD_CONTEXT */);
|
479
496
|
return 0;
|
480
497
|
}
|
481
|
-
if (read != 62006 || draw != 62006 /* Magic ID for Emscripten 'default surface' */) {
|
498
|
+
if ((read != 0 && read != 62006) || (draw != 0 && draw != 62006 /* Magic ID for Emscripten 'default surface' */)) {
|
482
499
|
EGL.setErrorCode(0x300D /* EGL_BAD_SURFACE */);
|
483
500
|
return 0;
|
484
501
|
}
|
502
|
+
EGL.currentContext = context;
|
503
|
+
EGL.currentDrawSurface = draw;
|
504
|
+
EGL.currentReadSurface = read;
|
485
505
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|
486
|
-
return 1
|
506
|
+
return 1 /* EGL_TRUE */;
|
507
|
+
},
|
508
|
+
|
509
|
+
// EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
|
510
|
+
eglGetCurrentContext: function() {
|
511
|
+
return EGL.currentContext;
|
487
512
|
},
|
488
513
|
|
514
|
+
// EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
|
515
|
+
eglGetCurrentSurface: function(readdraw) {
|
516
|
+
if (readdraw == 0x305A /* EGL_READ */) {
|
517
|
+
return EGL.currentReadSurface;
|
518
|
+
} else if (readdraw == 0x3059 /* EGL_DRAW */) {
|
519
|
+
return EGL.currentDrawSurface;
|
520
|
+
} else {
|
521
|
+
EGL.setErrorCode(0x300C /* EGL_BAD_PARAMETER */);
|
522
|
+
return 0 /* EGL_NO_SURFACE */;
|
523
|
+
}
|
524
|
+
},
|
525
|
+
|
526
|
+
// EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
|
527
|
+
eglGetCurrentDisplay: function() {
|
528
|
+
return EGL.currentContext ? 62000 /* Magic ID for Emscripten 'default display' */ : 0;
|
529
|
+
},
|
530
|
+
|
489
531
|
// EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
|
490
532
|
eglSwapBuffers: function() {
|
491
533
|
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
|