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.js66
1 files changed, 61 insertions, 5 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 27bf4a0c..99106fc3 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -347,11 +347,21 @@ mergeInto(LibraryManager.library, {
});
addRunDependency('al ' + url);
},
-
- setCanvasSize: function(width, height) {
+
+ resizeListeners: [],
+
+ updateResizeListeners: function() {
+ var canvas = Module['canvas'];
+ Browser.resizeListeners.forEach(function(listener) {
+ listener(canvas.width, canvas.height);
+ });
+ },
+
+ setCanvasSize: function(width, height, noUpdates) {
var canvas = Module['canvas'];
canvas.width = width;
canvas.height = height;
+ if (!noUpdates) Browser.updateResizeListeners();
}
},
@@ -364,14 +374,56 @@ mergeInto(LibraryManager.library, {
_file.substr(index +1),
_url, true, true,
function() {
- FUNCTION_TABLE[onload](file);
+ if (onload) FUNCTION_TABLE[onload](file);
},
function() {
- FUNCTION_TABLE[onerror](file);
+ if (onerror) FUNCTION_TABLE[onerror](file);
}
);
},
+ emscripten_async_prepare: function(file, onload, onerror) {
+ var _file = Pointer_stringify(file);
+ var data = FS.analyzePath(_file);
+ if (!data.exists) return -1;
+ var index = _file.lastIndexOf('/');
+ FS.createPreloadedFile(
+ _file.substr(0, index),
+ _file.substr(index +1),
+ new Uint8Array(data.object.contents), true, true,
+ function() {
+ if (onload) FUNCTION_TABLE[onload](file);
+ },
+ function() {
+ if (onerror) FUNCTION_TABLE[onerror](file);
+ },
+ true // don'tCreateFile - it's already there
+ );
+ return 0;
+ },
+
+ emscripten_async_prepare_data: function(data, size, suffix, arg, onload, onerror) {
+ var _suffix = Pointer_stringify(suffix);
+ if (!Browser.asyncPrepareDataCounter) Browser.asyncPrepareDataCounter = 0;
+ var name = 'prepare_data_' + (Browser.asyncPrepareDataCounter++) + '.' + _suffix;
+ var cname = _malloc(name.length+1);
+ writeStringToMemory(name, cname);
+ FS.createPreloadedFile(
+ '',
+ name,
+ {{{ makeHEAPView('U8', 'data', 'data + size') }}},
+ true, true,
+ function() {
+ if (onload) FUNCTION_TABLE[onload](arg, cname);
+ },
+ function() {
+ if (onerror) FUNCTION_TABLE[onerror](arg);
+ },
+ true // don'tCreateFile - it's already there
+ );
+ return 0;
+ },
+
emscripten_async_run_script__deps: ['emscripten_run_script'],
emscripten_async_run_script: function(script, millis) {
Module['noExitRuntime'] = true;
@@ -382,7 +434,7 @@ mergeInto(LibraryManager.library, {
}, millis);
},
- emscripten_set_main_loop: function(func, fps) {
+ emscripten_set_main_loop: function(func, fps, simulateInfiniteLoop) {
Module['noExitRuntime'] = true;
var jsFunc = FUNCTION_TABLE[func];
@@ -442,6 +494,10 @@ mergeInto(LibraryManager.library, {
}
}
Browser.mainLoop.scheduler();
+
+ if (simulateInfiniteLoop) {
+ throw 'emscripten_set_main_loop simulating infinite loop by throwing so we get right into the JS event loop';
+ }
},
emscripten_cancel_main_loop: function() {