Reputation: 61
I am a bit confused about filesystem in Android from ndk's perspective.
I am building it with custom ant files. All I want for now is to read some text files containing my shaders.
As far as I understand:
Assets are files < 1Mb which can be accessed in plain text form, but not via url or filepaths . I've found on the Internet that it is better to use gradle (like in android studio) to use assets.
Resources (res directory) can be accessed via url, but in packed form (one have to extract from them like from .zip)
So I decided to use assets. Where should I put my assets folder? All examples I've found were relative to AndroidStudio (src/main/assets) but I use src/com/normalpackage/sources.java and jni/sources.cpp
I even think about creating a program which will take my assets directory as input and on the output I will get a .hpp file containing:
struct MyFile{
uchar* filepath;
uchar* data;
...
};
MyFile f1(filepath,data1)
MyFile f2(filepath,data2)
...
//or put it in std::map or something
(packed in data structures, ready to compile it with source code) I think that it won't be a good solution due to increased compile time (in future I would like to import not only shaders, but also images or audio), but I am might be wrong here (what do you think?).
So, what should I choose?
Upvotes: 0
Views: 1565
Reputation: 2711
From the NDK you can use AAsset_read
to access the assets folder, and I think this will be the best way. You can look here for an example: How To Get File In Assets From Android NDK
Upvotes: 1