Send both update and render events on Windows resize/move

This commit is contained in:
Joshua Granick
2020-03-11 11:28:17 -07:00
parent c873ff2f2e
commit a2413c4fad
2 changed files with 28 additions and 24 deletions

View File

@@ -127,26 +127,7 @@ namespace lime {
case SDL_USEREVENT:
if (!inBackground) {
currentUpdate = SDL_GetTicks ();
applicationEvent.type = UPDATE;
applicationEvent.deltaTime = currentUpdate - lastUpdate;
lastUpdate = currentUpdate;
nextUpdate += framePeriod;
while (nextUpdate <= currentUpdate) {
nextUpdate += framePeriod;
}
ApplicationEvent::Dispatch (&applicationEvent);
RenderEvent::Dispatch (&renderEvent);
}
SendUpdateEvent();
break;
case SDL_APP_WILLENTERBACKGROUND:
@@ -827,6 +808,31 @@ namespace lime {
}
void SDLApplication::SendUpdateEvent () {
if (!inBackground) {
currentUpdate = SDL_GetTicks ();
applicationEvent.type = UPDATE;
applicationEvent.deltaTime = currentUpdate - lastUpdate;
lastUpdate = currentUpdate;
nextUpdate += framePeriod;
while (nextUpdate <= currentUpdate) {
nextUpdate += framePeriod;
}
ApplicationEvent::Dispatch (&applicationEvent);
RenderEvent::Dispatch (&renderEvent);
}
}
void SDLApplication::SetFrameRate (double frameRate) {
if (frameRate > 0) {
@@ -1014,14 +1020,11 @@ namespace lime {
winTimerActive = SetTimer (GetActiveWindow (), winTimerID, currentApplication->framePeriod, nullptr);
// TODO: Are we thread-safe to call GL here?
RenderEvent::Dispatch (&currentApplication->renderEvent);
} else if (message.msg == WM_TIMER) {
if (message.wParam == winTimerID) {
RenderEvent::Dispatch (&currentApplication->renderEvent);
currentApplication->SendUpdateEvent ();
}

View File

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