diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-06 22:12:46 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-06 22:12:46 -0500 |
commit | 7a63da01635ec01a09fad2cb3cbb0d7427664f3e (patch) | |
tree | 466f9f14bbc4e3ef66832038cd2f28d1d1ab10b3 | |
parent | d42013b7e6e9be7657936d67dc5aca4a47dc2ee1 (diff) |
warn when rendering without setAnimationFrame
-rw-r--r-- | src/library_browser.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 458a8dd2..5d53b867 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -13,6 +13,7 @@ mergeInto(LibraryManager.library, { $Browser: { mainLoop: { scheduler: null, + method: '', shouldPause: false, paused: false, queue: [], @@ -784,6 +785,11 @@ mergeInto(LibraryManager.library, { GL.newRenderingFrameStarted(); #endif + if (Browser.mainLoop.method === 'timeout' && Module.ctx) { + Module.printErr('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!'); + Browser.mainLoop.method = ''; // just warn once per call to set main loop + } + if (Module['preMainLoop']) { Module['preMainLoop'](); } @@ -814,11 +820,13 @@ mergeInto(LibraryManager.library, { if (fps && fps > 0) { Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() { setTimeout(Browser.mainLoop.runner, 1000/fps); // doing this each time means that on exception, we stop - } + }; + Browser.mainLoop.method = 'timeout'; } else { Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() { Browser.requestAnimationFrame(Browser.mainLoop.runner); - } + }; + Browser.mainLoop.method = 'rAF'; } Browser.mainLoop.scheduler(); |