Closed gliheng closed 6 years ago
Thanks! Looks great.
I added a version_4
tag for this now. Would you like to open a PR in emscripten that adds a test for this, and updates the port to that version?
Okay, I'll do that.
And here's the pull request to emscripten with tests.
Posted upstream for consideration at https://bugzilla.libsdl.org/show_bug.cgi?id=4203
A bit late, but this patch shouldn't be necessary.
IMG_Load
calls IMG_LoadTyped_RW
which has handling for preloaded images already. However, it fails as emscripten_run_preload_plugins_data
doesn't actually create the filename it returns, so it fails to open the file and returns early. I tried switching that true
to false
and reverting to version_3
and the test still passes.
Hmm, what patch are you writing about? The one I sent upstream is from the SDL2 emscripten port (but not in upstream https://hg.libsdl.org/SDL_image/file/tip/IMG.c). The other 2 referenced here are already merged?
This PR shouldn't be needed after my original patch (58d0d10569b633375a2a24958f62a29e7899083e). It looks like it might be hiding an Emscripten bug. It may make sense to upstream that patch though (with the fix from 38ddf6804e271da91691bd8eb42b2e72e49cff45), I just never looked into it.
EDIT: Though, the point of emscripten_run_preload_plugins_data
is to avoid writing the file. And the "fake filename" was designed for the old JS IMG_Load
. It still seems wrong to duplicate the Emscripten support for just that function though...
It's worth nothing that the equivalent preloadedAudios wasn't ported to SDL2(_mixer) at all.
I'm trying to pull data from web then put it on the canvas. After I pass the image data to
emscripten_run_preload_plugins_data
, I useIMG_Load
to get a surface and I got a NULL pointer. I read SDL1 test case and it works fine, but SDL2 does not have a test case foremscripten_run_preload_plugins_data
.After some digging, I think IMG_Load should attempt to read from preloaded data and here's the fix for IMG_Load.