Texture loss?


I’m seeing something where any image I load usually works fine at first but is then lost if you switch to another app then back again. The oF app has to be killed completely then restarted, or I get either a black texture or what looks like corruption/noise.

Is it like the Olden Days of Texture Management where I’ll have to reload textures whenever I regain focus?

1 Like
Is there an example or instructions somewhere on the "right" way to handle Android interrupting an OF program?

yes, it is : ) but for ofImage, ofBirmapString, ofVideoPlayer/Grabber and ofTrueTypeFont is taken care of by the same OF so you need to do nothing. i think in master the texture recovery is broken but in the development branch is working for sure.

If you create your own custom texture and fill it with your own data, since there’s no copy of the data binded to the texture there’s no way to recover it automatically so you’ll need to do it your self. if your application inherits from ofxAndroidApp instead of ofBaseApp you can have 3 methods:

void pause();  
void stop();  
void resume();  
void reloadTextures()  

in pause and stop the texture is going to be deleted but the ids are going to remain as they are so better if you delete them here but as far as i’ve tested is not really necesary. in resume, the application is going to the foreground again. in reloadTextures is where you want to reupload the data to your textures.

you can also use this to release/reserve any other resources that you may be using. most of them happen automatically, like the sound card or the camera. also you would want to stop or lower the refresh rate of threads that would consume the battery while in the background

1 Like

Thanks. Is it more useful to you if I switch to the development branch so I’m not bringing up issues you’ve already found?


yeah, sure, we wanted to merge it to master soon but windows is broken, i’m working in development so the latest fixes are there