emscripten: Let SDL hints be set by URL parameters.

Any parameters (key/value pairs after the '?' in a URL) that have a keyname
that starts with `SDL_` will be put into Emscripten's environment variable
emulation table at startup, before SDL_main runs.

This lets users set hints the same way they might set them from a shell's
command line on a desktop platform:

For example:

`https://example.com/my_sdl3_application.html?SDL_RENDER_DRIVER=software`

Fixes #10154.
This commit is contained in:
Ryan C. Gordon
2024-07-03 20:05:43 -04:00
parent 9d47daef0a
commit f338fa20dd
3 changed files with 68 additions and 0 deletions

View File

@@ -1480,6 +1480,8 @@ elseif(EMSCRIPTEN)
# project. Uncomment at will for verbose cross-compiling -I/../ path info.
sdl_compile_options(PRIVATE "-Wno-warn-absolute-paths")
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/core/emscripten/*.c")
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/main/emscripten/*.c")
set(HAVE_SDL_MAIN_CALLBACKS TRUE)