Texture unloading/reloading results in black rectangles


I had problems with textures not being loaded after minimizing and resuming, so I started using unloadTextures() / reloadTextures() to do exactly that.

It fixed the issue, but created another, twice as weird, issue. The text on the native android buttons is becoming black rectangles after I resume! After some trial and error, I pinpointed the problem to the line:

ofLoadImage(myTexture, "myTexture.png");

That is being called from reloadTextures().

Now, if I remove this line, the text is ok, but the texture is not loaded correctly, and if I put this line, well… see the screenshot:

Believe me, before minimizing, the buttons have readable text!

So I’m thinking that somehow maybe ofLoadImage is running over texture memory it shouldn’t? I’m not sure, but I also think that ofImage/ofTexture are not handling correctly scenarios where clear() is called for a texture that is not allocated yet?

Any help with this will be appreciated.



UPDATE: I found one (ONE!!) case of this happening in a web search, and it’s indeed related to textures getting lost when the openGL context is replaced, but I’m not sure what I’m supposed to do other then use unload/reloadTextures properly! HELP!!

I tried to reproduce it by taking androidEmptyExample and just loading/unloading a texture but it doesn’t reproduce :frowning: I’m doing something wrong and it’s texture related and I don’t know what!! HELP!!