Android Asset Management with SDL2 |
AntTheAlchemist
|
RWops is the way to go. Everything is cross-platform, so my Android code is identical to the PC.I have sub-directories "images", "sound", "levels", etc. I copy all these directories into the android assets directory and they're picked up the same way on both platforms. So, basically, "assets" is the Android root directory.
|
|||||||||||
|
scanner_darkly
|
How do you handle the images? Maybe I'm just rusty with C parsing, but I can't seem to get a handle on how to send the filename to STB image. Could you post an example of one of your parses for your level or images if possible?
Thanks for the feedback. |
|||||||||||
|
scanner_darkly
|
I fixed the image loading issue by just using SDL Image (not sure why I didn't consider this earlier).
But I have stumbled into another predicament (the last one I think), and that's FreeType. I could use SDL_ttf but I don't want to rewrite all my text rendering if I can avoid it. Is there a way I can load my .ttf file from assets using SDL_RWops and then pass the file path into FT_New_Face(ftLibrary, filepath, 0, &face)? |
|||||||||||
|
AntTheAlchemist
|
Does FreeType have a FT_New_Face_From_Memory(), or something? A good library shouldn't restrict you to only using file names as parameters. It should offer loading from a stream, or from memory.
I opted to go with LodePNG for images. I load the file into memory using SDL_RWops and there's a lodepng_decode32() which takes a pointer to memory as source. You can override PNG's internal memory handlers to make it conform to any internal garbage collection, too, since image decoding can be memory intensive. |
|||||||||||
|
scanner_darkly
|
Ah, it appears so! Here's a code snippet from http://www.freetype.org/freetype2/docs/tutorial/step1.html:
I'm at work right now so I can't test this, but can I just use this method to parse the TTF file and then pass the char buffer into FT_New_Memory_Face? Here's the parsing code from https://wiki.libsdl.org/SDL_RWread :
Where filename is the TTF file I want to parse and res would be the buffer I pass into FT_New_Memory_Face. |
|||||||||||||||||
|
Android Asset Management with SDL2 |
SiPlus
|
There is FT_New_Memory_Face, you need to keep the file contents in
memory until you don't need the font anymore. On 26-Aug-15 16:10, AntTheAlchemist wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|