[SDL] Android resource management
gabomdq at gmail.com
Mon Nov 7 15:49:42 PST 2011
> But this seems like a rather dirty, round-about way of doing things, plus
> really dangerous to boot. I'd think it would be safest to send resources
> via the JNI, ie. open them in Java (Davlik has easy access to JNI
> contents) and pass them to the native code. What I'm wondering is whether
> the SDL port has anything like this implemented or whether it needs to be
> written from scratch. Is this what you meant?
1) Put a image.png inside an "assets" directory in the Android project root
(that is where AndroidManifest.xml and build.xml live).
2) Call IMG_Load("image.png")
3) ndk-build, ant build, etc
SDL and Android work their magic behind the scenes, your image.png is going to
be placed inside the apk, and you don't have to worry about compression, where
it is decompressed or when, it just works. If you want to know the details,
I'm afraid you'll have to check for yourself in the source code.
This works for SDL_ttf as well if you want to load fonts for example using the
same technique (that's as far as I've tried, _image and _ttf, though I think
anything that uses RWOps should work in the same way).
More information about the SDL