-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Android: LoadTexture works, fopen doesn't? What magic is this? #636
Comments
Hey @SethArchambault! Great tracking exercise! You got almost there. ;) Due to Anroid APK internal filesystem, data should be loaded through the assets manager, that's what I'm doing with raylib, just replaced default fopen by a custom one that uses assets manager... That functionality is not directly exposed by raylib... mmmh... probably it should be... |
@raysan5 Haha, so close! Thanks! This is what I love about raylib, the ability to really track the code.. Not something I've ever been able to do in a massive object oriented framework.. Yeah sounds like a LoadFile() function could be useful? Anyways, this resolves it for me.. |
K I was stuck on this for a bit getting a SIGSEGV on AAssetManager_open, but I think I know why now! I need access to this (in core.c): Is this exposed by raylib at all? I need an assetManager to use in AAssetManager_open, and I see that I can't create my own - my theory is I need to use the same one that is used in InitAssetManager.. Thanks! |
Your assumption is right, you need to use the same. And no, by default is not exposed by raylib... but you can include |
@raysan5 Yes! Thank you, that was so simple! 👍 |
@raysan5 Hey even though my problem is solved, I realize I don't fully grasp how this is working. Like I get that I can access this function now, but it's confusing to me how I didn't have access it to before.. Trying to wrap my mind around it. Like, raylib.h gives me access to the LoadImage function, and that must use fopen eventually which has access to the android_fopen function, yet that's not exposed to me when I include raylib.h. I feel like I'm fundamentally missing a solid conceptualization of how files can use or not use header files to hide functionality.. Any good resource on this? |
Generally, a function provided by raylib for public use must only be exported in the library. On Unix that means you don't add a Additionally, it's customary to supply a header file which contains the declarations necessary to use the symbols. This provides type checking and a contract between library implementor and user on which symbols are usable how. So, to sum up because android is Linux, you could just copy the prototype out of the header ( or just include it) and call the function yourself. HTH. |
@a3f Thanks for the detailed explanation! @SethArchambault actually, the only thing you're doing is replacing |
Thanks! I think I've got it! |
I'm building a project on an Amazon Fire HD 8, and I've encountered this issue where fopen doesn't seem to find the file correctly. I was using fopen to load a data file, but I decided to test it out using an image file that I had already successfully loaded as a texture:
The result I got:
So I figured, hmm - LoadTexture must be doing something special - perhaps altering the path when it sees it's installed on Android somehow. So I set off to track down what that special thing could be:
Okay the princess must be in LoadImage:
Wait, this is verbatim what I'm doing in my own function!
I was stumped here.. then I decided to see what IsFileExtension did (nothing too interesting) - but I stumbled across this:
That looked like something...
Then I found this:
Which led me to the utils.c file, and this!
Which looks like the thing I want. But it doesn't appear to be used anywhere!
I'm very confused right now.. It looks like I should just be using this ASsetManager to open files, but how should I do this with raylib?
Thanks!
The text was updated successfully, but these errors were encountered: