mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
resize event handling tweaks
Fixes Android and somehow optimizes resizing with lots of gamestates
This commit is contained in:
parent
f375b6f0b1
commit
6899ea5f52
1 changed files with 10 additions and 6 deletions
|
@ -48,19 +48,23 @@ static inline void HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) {
|
|||
}
|
||||
break;
|
||||
|
||||
case ALLEGRO_EVENT_DISPLAY_RESIZE:
|
||||
if ((ev->display.width != al_get_display_width(game->display)) || (ev->display.height != al_get_display_height(game->display))) {
|
||||
case ALLEGRO_EVENT_DISPLAY_RESIZE: {
|
||||
bool changed = (ev->display.width != al_get_display_width(game->display)) || (ev->display.height != al_get_display_height(game->display));
|
||||
|
||||
#ifdef LIBSUPERDERPY_IMGUI
|
||||
ImGui_ImplAllegro5_InvalidateDeviceObjects();
|
||||
ImGui_ImplAllegro5_InvalidateDeviceObjects();
|
||||
#endif
|
||||
al_acknowledge_resize(game->display);
|
||||
al_acknowledge_resize(game->display);
|
||||
#ifdef LIBSUPERDERPY_IMGUI
|
||||
ImGui_ImplAllegro5_CreateDeviceObjects();
|
||||
ImGui_ImplAllegro5_CreateDeviceObjects();
|
||||
#endif
|
||||
// SetupViewport can be expensive, so don't do it when the resize event is already outdated or doesn't change anything
|
||||
if (changed && ((ev->display.width == al_get_display_width(game->display)) || (ev->display.height == al_get_display_height(game->display)))) {
|
||||
SetupViewport(game);
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
case ALLEGRO_EVENT_KEY_DOWN:
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
if ((ev->keyboard.keycode == ALLEGRO_KEY_MENU) || (ev->keyboard.keycode == ALLEGRO_KEY_TILDE) || (ev->keyboard.keycode == ALLEGRO_KEY_BACKQUOTE)) {
|
||||
|
|
Loading…
Reference in a new issue