From 7d816e28ef00223dba206ac02c901b4cce5b4b1b Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Mon, 9 Dec 2019 02:02:50 +0100 Subject: [PATCH] emscripten: fix fullscreen with fixed_size param --- src/mainloop.c | 4 +++- src/utils.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mainloop.c b/src/mainloop.c index a21376e..8458a73 100644 --- a/src/mainloop.c +++ b/src/mainloop.c @@ -50,7 +50,6 @@ static inline bool HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) { case ALLEGRO_EVENT_DISPLAY_RESIZE: PrintConsole(game, "Resize event: %dx%d", ev->display.width, ev->display.height); - #ifdef LIBSUPERDERPY_IMGUI ImGui_ImplAllegro5_InvalidateDeviceObjects(); #endif @@ -62,6 +61,9 @@ static inline bool HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) { // SetupViewport can be expensive, so don't do it when the resize event is already outdated or doesn't change anything if (((ev->display.width != game->_priv.window_width) || (ev->display.height != game->_priv.window_height)) && (ev->display.width == al_get_display_width(game->display)) && (ev->display.height == al_get_display_height(game->display))) { + if (game->_priv.params.fixed_size) { + al_resize_display(game->display, game->_priv.params.width, game->_priv.params.height); + } SetupViewport(game); } diff --git a/src/utils.c b/src/utils.c index 6ebc195..67b335f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -688,6 +688,12 @@ SYMBOL_EXPORT void QuitGame(struct Game* game, bool allow_pausing) { } SYMBOL_EXPORT bool ToggleFullscreen(struct Game* game) { + if (IS_EMSCRIPTEN && game->_priv.params.fixed_size) { + al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, true); + SetupViewport(game); + PrintConsole(game, "Fullscreen toggled"); + return true; + } game->config.fullscreen = !game->config.fullscreen; if (game->config.fullscreen) { SetConfigOption(game, "SuperDerpy", "fullscreen", "1");