简体   繁体   中英

SDL - android port - how to open image in apk file from c code?

I am new to SDL and c/c++. Please, can somebody give an example of opening asset file in apk, which is called from native code? SDL 1.3 have "Android_JNI_FileOpen()" function, but I can't understand how to use it.

Actually what you need to do is to create SDL_RWops from file - on Android file is taken from apk. So simple.

Old code:

/* Load graphics */
image = IMG_Load("/sdcard/imagename.type");

New code:

/* Load graphics */
SDL_RWops *file = SDL_RWFromFile("imagename.type", "rb");
image = IMG_Load_RW(file, 1);

PS File must be in "assets" directory in apk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM