|
@@ -392,22 +392,30 @@ void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
|
|
|
SDL_RenderPresent(renderer);
|
|
|
}
|
|
|
|
|
|
-void loop()
|
|
|
+static void MoveAllSprites()
|
|
|
{
|
|
|
- Uint32 now;
|
|
|
int i;
|
|
|
- SDL_Event event;
|
|
|
|
|
|
- /* Check for events */
|
|
|
- while (SDL_PollEvent(&event)) {
|
|
|
- SDLTest_CommonEvent(state, &event, &done);
|
|
|
- }
|
|
|
for (i = 0; i < state->num_windows; ++i) {
|
|
|
if (state->windows[i] == NULL) {
|
|
|
continue;
|
|
|
}
|
|
|
MoveSprites(state->renderers[i], sprites[i]);
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+void loop()
|
|
|
+{
|
|
|
+ Uint32 now;
|
|
|
+ SDL_Event event;
|
|
|
+
|
|
|
+ /* Check for events */
|
|
|
+ while (SDL_PollEvent(&event)) {
|
|
|
+ SDLTest_CommonEvent(state, &event, &done);
|
|
|
+ }
|
|
|
+
|
|
|
+ MoveAllSprites();
|
|
|
+
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
if (done) {
|
|
|
emscripten_cancel_main_loop();
|
|
@@ -426,6 +434,14 @@ void loop()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static int SDLCALL ExposeEventWatcher(void *userdata, SDL_Event *event)
|
|
|
+{
|
|
|
+ if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_EXPOSED) {
|
|
|
+ MoveAllSprites();
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
int i;
|
|
@@ -568,6 +584,9 @@ int main(int argc, char *argv[])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /* Add an event watcher to redraw from within modal window resize/move loops */
|
|
|
+ SDL_AddEventWatch(ExposeEventWatcher, NULL);
|
|
|
+
|
|
|
/* Main render loop */
|
|
|
frames = 0;
|
|
|
next_fps_check = SDL_GetTicks() + fps_check_delay;
|