0

I'm having opengl shader files which I want to load(using fopen) dynamically. How I can package these files in APK?

I tried this in gradle(assuming my shader file extn is glsh):

{
    ....
    dependencies {
        compile fileTree(dir: <shader file path>, include: '*.glsh')
    }
}

This does not work. Also tried "files" dependencies, but I got error saying supports only "jar".

I'm using Android Studio. Anyone please help.

raknas
  • 59
  • 1
  • 6

1 Answers1

0

You can put your files into the assets folder (on the same level as the res folder if not present) and read them from it at runtime.

Community
  • 1
  • 1
AndroidEx
  • 15,524
  • 9
  • 54
  • 50
  • I tried that. In my case that would be a problem. My code is in JNI and I need to pass resource manager from java to jni and use AAssetManager_fromJava. Then my code would not be be clean. Instead I would just simply load a file from current path. – raknas May 16 '15 at 05:26
  • @raknas what if you copy files from assets to the device once, when the app is launched for the first time. In this case you won't need an asset manager instance. – AndroidEx May 16 '15 at 05:57
  • If I need to do it once, I can do always. But as I said - does not suit well in my library module. From app activity I need to pass ResourceManager to my library Initializer and subsequently pass it to JNI Layer. I tried and it works. But I would prefer to have it packaged in a cleaner way - like '.so" files are packaged. – raknas May 16 '15 at 08:02