aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library_browser.js30
-rw-r--r--src/library_glut.js7
2 files changed, 20 insertions, 17 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
diff --git a/src/library_glut.js b/src/library_glut.js
index d5f1b7b0..d6293d85 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -489,10 +489,9 @@ var LibraryGLUT = {
GLUT.requestedAnimationFrame = true;
Browser.requestAnimationFrame(function() {
GLUT.requestedAnimationFrame = false;
- if (ABORT) return;
- if (Module['preMainLoop']) Module['preMainLoop']();
- Runtime.dynCall('v', GLUT.displayFunc);
- if (Module['postMainLoop']) Module['postMainLoop']();
+ Browser.mainLoop.runIter(function() {
+ Runtime.dynCall('v', GLUT.displayFunc);
+ });
});
}
},