From 3a757f10ada91833343364624322c4ab3ad4a8fc Mon Sep 17 00:00:00 2001 From: AliceLR Date: Sun, 10 May 2020 14:44:20 -0600 Subject: [PATCH] Also fix the software/softscale renderers for Emscripten --- src/render_sdl.c | 5 +++++ src/render_softscale.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/render_sdl.c b/src/render_sdl.c index b851e8d18..1e8e52d33 100644 --- a/src/render_sdl.c +++ b/src/render_sdl.c @@ -199,6 +199,11 @@ boolean sdl_set_video_mode(struct graphics_data *graphics, int width, sdl_destruct_window(graphics); +#if defined(__EMSCRIPTEN__) && SDL_VERSION_ATLEAST(2,0,10) + // Also, a hint needs to be set to make SDL_UpdateWindowSurface not crash. + SDL_SetHint(SDL_HINT_EMSCRIPTEN_ASYNCIFY, "0"); +#endif + render_data->window = SDL_CreateWindow("MegaZeux", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, sdl_flags(depth, fullscreen, fullscreen_windowed, resize)); diff --git a/src/render_softscale.c b/src/render_softscale.c index cfaec4ae9..2547ce4e4 100644 --- a/src/render_softscale.c +++ b/src/render_softscale.c @@ -320,6 +320,12 @@ static boolean softscale_set_video_mode(struct graphics_data *graphics, else SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); +#if defined(__EMSCRIPTEN__) && SDL_VERSION_ATLEAST(2,0,10) + // Not clear if this hint is required to make this renderer not crash, but + // considering both software and GLSL need it... + SDL_SetHint(SDL_HINT_EMSCRIPTEN_ASYNCIFY, "0"); +#endif + render_data->sdl.window = SDL_CreateWindow("MegaZeux", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, sdl_flags(depth, fullscreen, fullscreen_windowed, resize));