1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00
planetblupi/src/platform/platform_sdl.cxx

36 lines
632 B
C++
Raw Normal View History

2018-07-18 18:29:55 +02:00
#include <functional>
#include "../blupi.h"
#include "../event.h"
#include "../platform.h"
std::function<void(const SDL_Event &)> Platform::handleEvent;
void
Platform::run (std::function<void(const SDL_Event &)> handleEvent)
{
SDL_TimerID updateTimer = SDL_AddTimer (
g_timerInterval,
[](Uint32 interval, void * param) -> Uint32 {
CEvent::PushUserEvent (EV_UPDATE);
return interval;
},
nullptr);
SDL_Event event;
while (SDL_WaitEvent (&event))
{
handleEvent (event);
if (event.type == SDL_QUIT)
break;
}
SDL_RemoveTimer (updateTimer);
}
void
Platform::timer (void *)
{
}