user7428910
user7428910

Reputation: 61

NDK c++ load shaders from file Android

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:

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

Answers (1)

yakobom
yakobom

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

Related Questions