0

I want to write a native android library that can access shader and texture files from the res/raw folder of my application (or rather res/assets?) without being dependent of a specific activity object.

I want to avoid code like

Java_com_namespace_MyActivity_initAssetsManager(JNIEnv* env,  jobject obj) {
    AAssetManager* g_assetManager = nullptr;
    g_assetManager = AAssetManager_fromJava(env, obj);
    //log whatever operation ssucceeded or not.
}

Not sure if the way to do it is to #include <android_native_app_glue.h> in my source.cpp. The compiler don't recognize this header. I have to somehow add the android_native_app_glue lib to my cmakelists. I couldn't find an explanation how to do this. Google comes up only with examples using Android.mk.

1
  • You need an Activity reference in order to get at its assets. From a library perspective, you could ask the calling code to pass you an instance you can use. Alternatively you could say you want a reference to a GameActivity, which bundles a few commonly-used pointers. Commented May 12 at 11:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.