Improve consistency of frame timing (thanks @mauvecow)

This commit is contained in:
Joshua Granick
2015-10-19 19:15:40 -07:00
parent 4879c265a2
commit 83e0bd46c2
2 changed files with 21 additions and 1 deletions

View File

@@ -721,7 +721,7 @@ namespace lime {
#if (!defined (IPHONE) && !defined (EMSCRIPTEN))
if (active && (firstTime || SDL_WaitEvent (&event))) {
if (active && (firstTime || WaitEvent (&event))) {
firstTime = false;
@@ -796,6 +796,25 @@ namespace lime {
}
int SDLApplication::WaitEvent (SDL_Event *event) {
for(;;) {
SDL_PumpEvents ();
switch (SDL_PeepEvents (event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
case -1: return 0;
case 1: return 1;
default: SDL_Delay (1);
}
}
}
Application* CreateApplication () {
return new SDLApplication ();

View File

@@ -46,6 +46,7 @@ namespace lime {
void ProcessTextEvent (SDL_Event* event);
void ProcessTouchEvent (SDL_Event* event);
void ProcessWindowEvent (SDL_Event* event);
int WaitEvent (SDL_Event* event);
static void UpdateFrame ();
static void UpdateFrame (void*);