I am writing code that will allow the user to browse through the files on their SD card to locate images and them load them using openGL ES 2.0. This works fine when I had used just an EditText to type in the file path, but now that I have implemented a file browser that makes the exact same call with a String of the file path I get "Call to openGL API without a current context" in the LogCat.
I assumed this had something to do with the loader activity being over top the GLSurfaceView so I set up that activity terminates before any of the openGL calls were ever made, but no dice.
What gives?
Here are some code snippets:
Called when the user has clicked a file within the loader
public void backOut(String filePath) {
// inform the main Activity of the file to load...
Intent i = new Intent();
i.putExtra("filePath", filePath);
setResult(Activity.RESULT_OK, i);
// ... and end the load activity
finish();
}
Inside the main Activity, which holds the GLSurfaceView
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (1) : {
if (resultCode == Activity.RESULT_OK) {
String toLoad = data.getStringExtra("filePath");
Log.v(TAG, toLoad);
gl.informRendererLoadTexture(toLoad);
}
break;
}
}
}
And in the GLSurfaceView
public void informRendererLoadTexture(String filePath){
_filePath = filePath;
queueEvent(new Runnable(){
public void run() {
_renderer.loadGLTexture(_filePath);
}});