mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
36 lines
632 B
C++
36 lines
632 B
C++
|
|
||
|
#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 *)
|
||
|
{
|
||
|
}
|