Send both update and render events on Windows resize/move
This commit is contained in:
@@ -127,26 +127,7 @@ namespace lime {
|
|||||||
|
|
||||||
case SDL_USEREVENT:
|
case SDL_USEREVENT:
|
||||||
|
|
||||||
if (!inBackground) {
|
SendUpdateEvent();
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_APP_WILLENTERBACKGROUND:
|
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) {
|
void SDLApplication::SetFrameRate (double frameRate) {
|
||||||
|
|
||||||
if (frameRate > 0) {
|
if (frameRate > 0) {
|
||||||
@@ -1014,14 +1020,11 @@ namespace lime {
|
|||||||
|
|
||||||
winTimerActive = SetTimer (GetActiveWindow (), winTimerID, currentApplication->framePeriod, nullptr);
|
winTimerActive = SetTimer (GetActiveWindow (), winTimerID, currentApplication->framePeriod, nullptr);
|
||||||
|
|
||||||
// TODO: Are we thread-safe to call GL here?
|
|
||||||
RenderEvent::Dispatch (¤tApplication->renderEvent);
|
|
||||||
|
|
||||||
} else if (message.msg == WM_TIMER) {
|
} else if (message.msg == WM_TIMER) {
|
||||||
|
|
||||||
if (message.wParam == winTimerID) {
|
if (message.wParam == winTimerID) {
|
||||||
|
|
||||||
RenderEvent::Dispatch (¤tApplication->renderEvent);
|
currentApplication->SendUpdateEvent ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ namespace lime {
|
|||||||
void ProcessTextEvent (SDL_Event* event);
|
void ProcessTextEvent (SDL_Event* event);
|
||||||
void ProcessTouchEvent (SDL_Event* event);
|
void ProcessTouchEvent (SDL_Event* event);
|
||||||
void ProcessWindowEvent (SDL_Event* event);
|
void ProcessWindowEvent (SDL_Event* event);
|
||||||
|
void SendUpdateEvent ();
|
||||||
int WaitEvent (SDL_Event* event);
|
int WaitEvent (SDL_Event* event);
|
||||||
|
|
||||||
static void UpdateFrame ();
|
static void UpdateFrame ();
|
||||||
|
|||||||
Reference in New Issue
Block a user