Improve consistency of frame timing (thanks @mauvecow)
This commit is contained in:
@@ -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 ();
|
||||
|
||||
@@ -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*);
|
||||
|
||||
Reference in New Issue
Block a user