SDL icon indicating copy to clipboard operation
SDL copied to clipboard

emscripten: use webgl APIs directly and add canvas selector hint

Open Daft-Freak opened this issue 3 years ago • 5 comments

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

Daft-Freak avatar Aug 26 '22 17:08 Daft-Freak

Note: I haven't tested this after today's rebase. Will try to get that done tomorrow.

Daft-Freak avatar Aug 26 '22 17:08 Daft-Freak

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.

icculus avatar Aug 27 '22 03:08 icculus

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...

Daft-Freak avatar Aug 27 '22 14:08 Daft-Freak

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.

Neuhaus24 avatar Sep 07 '22 10:09 Neuhaus24

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....

Daft-Freak avatar Sep 07 '22 11:09 Daft-Freak

Is there an open issue in emscripten about this issue? If not is there somewhere where a workaround is documented?

Neuhaus24 avatar Oct 19 '22 11:10 Neuhaus24

I merged it, yolo. :)

If this becomes a problem, we'll deal with it.

icculus avatar Nov 23 '22 18:11 icculus

@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?

jspanchu avatar Oct 28 '23 16:10 jspanchu

Probably too large, but are we maybe due for a 2.32.0 release, @slouken?

icculus avatar Oct 28 '23 16:10 icculus

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

past-due avatar Jan 29 '24 23:01 past-due

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.

icculus avatar Jan 30 '24 01:01 icculus

@Daft-Freak can you confirm that this change doesn't break any of the existing SDL2 tests in the emscripten?

sbc100 avatar Jan 30 '24 02:01 sbc100

Last time I checked it broke some of the GL tests that relied on legacy emulation.

Daft-Freak avatar Jan 30 '24 11:01 Daft-Freak