SDL
SDL copied to clipboard
emscripten: use webgl APIs directly and add canvas selector hint
Description
The biggest part of this is removing the use of emscripten's EGL emulation, which allows us to specify the target element for rendering (instead of always using Module.canvas). May also improve multithreaded cases. (Based on a comment in #5260)
Also restores the ability to customise the used canvas that was lost when #canvas stopped meaning "use Module.canvas" by adding a hint to specify the selector used.
(I think the cursor code may still need updated, but this shouldn't make anything worse.)
Side note: the framebuffer code still attempts to support IE10/11, hah...
Existing Issue(s)
#5260
Note: I haven't tested this after today's rebase. Will try to get that done tomorrow.
Note: I haven't tested this after today's rebase.
When you're comfortable with the state of this, feel free to put this in revision control. It looks like a good change to me.
Ah, it breaks legacy GL emulation (GL 1.x-ish code). Which is something I've run into before (https://github.com/emscripten-core/emscripten/issues/7871). Hmm...
Just wanting to check what the status of this going forward is. I'm encountering the issue from https://github.com/libsdl-org/SDL/issues/5260 as I am trying to support multiple canvases on a page.
Yeah, I'm not sure. Losing LEGACY_GL would probably break some (basic) ports... and Emscripten has a bunch of tests for this working. But also, it seems incompatible with the idea of multiple contexts.
Didn't get any responses on my original issue about this, maybe I should try again....
Is there an open issue in emscripten about this issue? If not is there somewhere where a workaround is documented?
I merged it, yolo. :)
If this becomes a problem, we'll deal with it.
@icculus, @sbc100 I would really love to have this feature in emscripten 3.1.48. Is there a risk to cherry pick https://github.com/libsdl-org/SDL/commit/a5e9d9bd7ef195e27565a3e5743579eb0891b9f8 for the next 2.28.x release?
Probably too large, but are we maybe due for a 2.32.0 release, @slouken?
@icculus, @sbc100 I would really love to have this feature in emscripten 3.1.48. Is there a risk to cherry pick a5e9d9b for the next 2.28.x release?
@icculus Just bumping this again - would it be possible to cherry-pick this for a 2.x release? (We've hit an issue ourselves that this would seem to resolve, and it would be really nice to have this in 2.x)
I'm willing to cherry pick this to 2.30.0, if we all agree that if this breaks things using SDL2 in ways that are difficult for apps to trivially fix, it will be reverted for 2.30.1.
@Daft-Freak can you confirm that this change doesn't break any of the existing SDL2 tests in the emscripten?
Last time I checked it broke some of the GL tests that relied on legacy emulation.