Is it possible to use stbi_load on Android?

378 views Asked by At

I am a newbie on openGLES, I just want to open an image serve my texture later.

Since most tutorial on the internet for openGL is based on development on laptop, they simply open image like:unsigned char *data = stbi_load("pic.jpg", &width, &height, &nrChannels, 0); and put the picture under same folder. But I then realized for Android set a correct path is not that simple. If I put the picture under same folder with my cpp file, it will not be found during runtime since the app is now on the real phone.

So the question is, Is it possible to use stbi_load on Android? Or should I find another way? BTW I have to use JNI and write opengl logic with CPP.

1

There are 1 answers

1
Michael On BEST ANSWER

I figure it out by myself in case someone encounter same issue.. Note in android you need to read from Sdcard not from drawable. Remember to grant permission.