aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-16 14:38:43 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-16 14:38:43 -0700
commit7acb48826165890ebc9d3794d8d7473aa62b762e (patch)
treef23f1e3ac029b6f359c5986da7b1b903d6032731 /src/library_browser.js
parentb8d63ddfd7e620e812f35ff12e4869f0bc7a9473 (diff)
share main loop iter logic with emscripten_*_loop and glut
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 86447bc9..8509c9d7 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -41,6 +41,21 @@ mergeInto(LibraryManager.library, {
Module['setStatus']('');
}
}
+ },
+ runIter: function(func) {
+ if (ABORT) return;
+ if (Module['preMainLoop']) Module['preMainLoop']();
+ try {
+ func();
+ } catch (e) {
+ if (e instanceof ExitStatus) {
+ return;
+ } else {
+ if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
+ throw e;
+ }
+ }
+ if (Module['postMainLoop']) Module['postMainLoop']();
}
},
isFullScreen: false,
@@ -954,24 +969,13 @@ mergeInto(LibraryManager.library, {
Browser.mainLoop.method = ''; // just warn once per call to set main loop
}
- if (Module['preMainLoop']) Module['preMainLoop']();
-
- try {
+ Browser.mainLoop.runIter(function() {
if (typeof arg !== 'undefined') {
Runtime.dynCall('vi', func, [arg]);
} else {
Runtime.dynCall('v', func);
}
- } catch (e) {
- if (e instanceof ExitStatus) {
- return;
- } else {
- if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
- throw e;
- }
- }
-
- if (Module['postMainLoop']) Module['postMainLoop']();
+ });
if (Browser.mainLoop.shouldPause) {
// catch pauses from the main loop itself