emscripten: fix fullscreen with fixed_size param

This commit is contained in:
Sebastian Krzyszkowiak 2019-12-09 02:02:50 +01:00
parent 34bcf97375
commit 7d816e28ef
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 9 additions and 1 deletions

View file

@ -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);
}

View file

@ -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");