0

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?

user7428910
  • 61
  • 1
  • 7

1 Answers1

1

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

Community
  • 1
  • 1
yakobom
  • 2,681
  • 1
  • 25
  • 33
  • But where should I put assets folder? All tutorials are refering to src/main/assets, but it is connected with Android Studio gradle building system – user7428910 Feb 01 '17 at 07:08
  • According to the documentation of AAssetManager_open: "To open the top-level directory, pass in "" as the dirName". So I think it will open the default location. Anyway, you can simply try... – yakobom Feb 01 '17 at 07:15