Browse Source

Platform: no need to have things at such level of ugliness.

pull/203/merge
Vladimír Vondruš 9 years ago
parent
commit
dcd2249039
  1. 18
      src/Magnum/Platform/Sdl2Application.cpp
  2. 5
      src/Magnum/Platform/Sdl2Application.h

18
src/Magnum/Platform/Sdl2Application.cpp

@ -58,13 +58,6 @@ Sdl2Application::InputEvent::Modifiers fixedModifiers(Uint16 mod) {
}
#ifdef CORRADE_TARGET_EMSCRIPTEN
Sdl2Application* Sdl2Application::_instance = nullptr;
void Sdl2Application::staticMainLoop() {
_instance->mainLoop();
}
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT
Sdl2Application::Sdl2Application(const Arguments& arguments): Sdl2Application{arguments, Configuration{}} {}
#endif
@ -79,11 +72,6 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): _glCont
#endif
_context{new Context{NoCreate, arguments.argc, arguments.argv}}, _flags{Flag::Redraw}
{
#ifdef CORRADE_TARGET_EMSCRIPTEN
CORRADE_ASSERT(!_instance, "Platform::Sdl2Application::Sdl2Application(): the instance is already created", );
_instance = this;
#endif
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
Error() << "Cannot initialize SDL.";
std::exit(1);
@ -325,8 +313,6 @@ Sdl2Application::~Sdl2Application() {
SDL_DestroyWindow(_window);
#else
SDL_FreeSurface(_glContext);
CORRADE_INTERNAL_ASSERT(_instance == this);
_instance = nullptr;
#endif
SDL_Quit();
}
@ -335,7 +321,9 @@ int Sdl2Application::exec() {
#ifndef CORRADE_TARGET_EMSCRIPTEN
while(!(_flags & Flag::Exit)) mainLoop();
#else
emscripten_set_main_loop(staticMainLoop, 0, true);
emscripten_set_main_loop_arg([](void* arg) {
static_cast<Sdl2Application*>(arg)->mainLoop();
}, this, 0, true);
#endif
return 0;
}

5
src/Magnum/Platform/Sdl2Application.h

@ -710,11 +710,6 @@ class Sdl2Application {
typedef Containers::EnumSet<Flag> Flags;
CORRADE_ENUMSET_FRIEND_OPERATORS(Flags)
#ifdef CORRADE_TARGET_EMSCRIPTEN
static Sdl2Application* _instance;
static void staticMainLoop();
#endif
void mainLoop();
#ifndef CORRADE_TARGET_EMSCRIPTEN

Loading…
Cancel
Save