-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL_RWops I/O macros (SDL_RWwrite() et al) are problematic. #2754
Comments
The safest thing is likely for you to use the SDL2 port, issue #2404 , which should have fully-functional RWops stuff. Otherwise, this might be solvable in the SDL1 code, but we that would be less preferable. |
OK, I'll take a look at that and see if I can make the SDL2 solution work for me -- there are probably other benefits to an SDL upgrade anyway. If I make any progress either way I'll let you know. |
OK, I've (finally) got the version of SDL2 from https://github.com/Daft-Freak/SDL-emscripten compiling against a recent emsdk_portable, and everything seems to be working as intended! We can probably flag this as resolved, as SDL1 isn't a priority for me personally any more. The only minor niggle I have is that I had interference from the old SDL1 headers still being on the include path, so I ended up 'fixing' that by going into tools/shared.py and commenting out the entry in C_INCLUDE_PATHS (i.e. this line: https://github.com/kripken/emscripten/blob/master/tools/shared.py#L722). Is there a more elegant way to do that? :D |
Not currently, but when we finish the SDL2 work, the plan is to have |
Removing the old SDL linking is #2730. |
I'm trying to cross compile my codebase with Emscripten, and I ran into the following problem with my File class, which is a (pretty thin) wrapper around an SDL_RWops:
When this executes, I get the following trace in the Firefox console:
Here's the (start of the) generated code, up to the end of the line marked as "problem line" above:
I initially thought this might be due to incompatible function pointers (as there are some minor differences between my native SDL headers and the ones Emscripten uses).
But now I think it's an issue with the fact that SDL_RWwrite() is implemented as a macro in "SDL_rwops.h" as follows:
Looking at the assignments to vars $12, $13, $14, the compiled JS looks like it's trying to treat the 'rwops' variable as a pointer into "heap" memory and pull out the 'write' function pointer, as the native code in the macro would. But in library_sdl.js, rwops objects are currently implemented as JavaScript Objects, and (AFAICT) they don't even have a 'write' member, so I'm not sure how this is going to work.
This issue probably applies to the other macros in "SDL_rwops.h" as well (SDL_RWread, SDL_RWseek, etc.)
As the majority of my I/O is done through RWops, then I don't know how much further I can go with my port for the time being. Depending on the timeline for a full SDL_RWops-compatible version of in Emscripten, I may consider an interim solution, and I'm not sure which is going to be the least amount of work:
My temptation right now is go with option #1, but if there is 'official' work planned in this area in the short term, then I might leave this alone for now and wait for a later Emscripten release. On the other hand, if anyone thought it was useful, then I could have a go at putting a patch together if I'm able to come up with a solution that works.
It's a fascinating piece of tech, by the way :)
The text was updated successfully, but these errors were encountered: