Browse Source

Platform: this is all wrong anyway and mainLoopIteration() is useless.

The exec() should return int to be API-compatible with other
implementations.
pull/300/head
Vladimír Vondruš 7 years ago
parent
commit
e0019f511c
  1. 16
      src/Magnum/Platform/EmscriptenApplication.cpp
  2. 22
      src/Magnum/Platform/EmscriptenApplication.h

16
src/Magnum/Platform/EmscriptenApplication.cpp

@ -549,17 +549,15 @@ EmscriptenApplication::GLConfiguration::GLConfiguration():
_colorBufferSize{8, 8, 8, 0}, _depthBufferSize{24}, _stencilBufferSize{0} {}
#endif
void EmscriptenApplication::mainLoopIteration() {
if(!(_flags & Flag::Redraw)) return;
int EmscriptenApplication::exec() {
emscripten_set_main_loop_arg([](void* userData) {
auto& app = *static_cast<EmscriptenApplication*>(userData);
if(!(app._flags & Flag::Redraw)) return;
_flags &= ~Flag::Redraw;
drawEvent();
}
void EmscriptenApplication::exec() {
emscripten_set_main_loop_arg([](void* arg) {
static_cast<EmscriptenApplication*>(arg)->mainLoopIteration();
app._flags &= ~Flag::Redraw;
app.drawEvent();
}, this, 0, true);
return 0;
}
void EmscriptenApplication::exit(int) {

22
src/Magnum/Platform/EmscriptenApplication.h

@ -292,33 +292,23 @@ class EmscriptenApplication {
EmscriptenApplication& operator=(EmscriptenApplication&&) = delete;
/**
* @brief Execute main loop
* @brief Execute the application
*
* Calls @ref mainLoopIteration() in a loop until @ref exit() is
* Sets up Emscripten to execute event handlers until @ref exit() is
* called. See @ref MAGNUM_EMSCRIPTENAPPLICATION_MAIN() for usage
* information.
*/
void exec();
int exec();
/**
* @brief Exit application main loop
* @param exitCode Exit code for compatibility with other application
* implementations
*
* Stops main loop started by @ref exec().
* Stops execution started by @ref exec(). The @p exitCode is ignored
* and present only for API compatibility with other app
* implementations.
*/
void exit(int exitCode = 0);
/**
* @brief Run one iteration of application main loop
*
* Called internally from @ref exec(). If you want to have better
* control over how the main loop behaves, you can call this function
* yourself from your own `main()` function instead of it being called
* automatically from @ref exec() / @ref MAGNUM_EMSCRIPTENAPPLICATION_MAIN().
*/
void mainLoopIteration();
protected:
/* Nobody will need to have (and delete) EmscriptenApplication*, thus
this is faster than public pure virtual destructor */

Loading…
Cancel
Save