mainloop: React to expose events when the engine is paused

When the engine is paused, it doesn't redraw the window content anymore.
On uncomposited environments, this means that the window content can be
lost. Enable expose events and react to them when the engine is paused
(if it's not, the whole window will be repainted soon anyway, so we can
ignore them).
This commit is contained in:
Sebastian Krzyszkowiak 2020-11-07 06:17:54 +01:00
parent f5eb7b088b
commit 6f22f54f5d
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 7 additions and 1 deletions

View file

@ -240,7 +240,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
windowMode |= ALLEGRO_RESIZABLE;
}
al_set_new_display_flags(windowMode | ALLEGRO_OPENGL | ALLEGRO_PROGRAMMABLE_PIPELINE);
al_set_new_display_flags(windowMode | ALLEGRO_OPENGL | ALLEGRO_PROGRAMMABLE_PIPELINE | ALLEGRO_GENERATE_EXPOSE_EVENTS);
al_set_new_display_option(ALLEGRO_VSYNC, 2 - strtol(GetConfigOptionDefault(game, "SuperDerpy", "vsync", "1"), NULL, 10), ALLEGRO_SUGGEST);
#ifdef LIBSUPERDERPY_ORIENTATION_LANDSCAPE

View file

@ -48,6 +48,12 @@ static inline bool HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) {
}
break;
case ALLEGRO_EVENT_DISPLAY_EXPOSE:
if (game->_priv.paused) {
RedrawScreen(game);
}
break;
case ALLEGRO_EVENT_DISPLAY_RESIZE:
PrintConsole(game, "Resize event: %dx%d", ev->display.width, ev->display.height);
#ifdef LIBSUPERDERPY_IMGUI