mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-12 20:18:00 +01:00
emscripten: fix fullscreen with fixed_size param
This commit is contained in:
parent
34bcf97375
commit
7d816e28ef
2 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue