Reputation: 4354
this is a weird one. I have a basic application (dashboard, ...) and a GLSurfaceview in which I draw 3D objects and textures. All runs pretty but when I go back in other activities, hmm well a screenshot is better than words:
This is the dashboard before
this is the opengl:
And this is my dashboard when I press back:
As you can see, the images are gone and text too. I run on 4.0+ so I suppose this is because android draws elements with opengl, as it doesn't do that on my 2.2 device.
Do you have an idea of what is causing this? It does not happen when I don't use texture btw.
Upvotes: 6
Views: 1726
Reputation: 1506
Could your issue be related to mine? Have a read to make sure it's not: Text only thing visible after pausing GLSurfaceView on Galaxy S3 - Text blur when moved. No button backgrounds
My issue was executing openGL functionality on the UI thread, which corrupted the openGL context used for hardware acceleration.
If you want to test: disable hardware acceleration app wide in the android manifest. If your issue disappears, it's likely the same issue I had. Read my answer to my own question to learn how to fix this issue while leaving hardware acceleration on.
<application android:hardwareAccelerated="false" ...>
Upvotes: 2
Reputation: 4354
Ok I found what was wrong to me. I was deleting textures on the UI Thread, by calling mTextureManager.deleteAllTextures()
on my fragment's onPause();
I solved it by deleting my textures with a
mSurfaceView.queueEvent(new Runnable(){
//delete all textures here
}
Hope this will help other guys...
Upvotes: 6
Reputation: 1767
If you are using textures and vertex buffers I believe those get cleared when you navigate away from a view. If you are getting a SurfaceDestoyed or SurfaceCreated call then I believe you have to recreate the textures and vbos and reload them to the graphics card.
I had a similar problem once where I introduced a bug that messed up the open gl state. Then when I went to another activity (that was hardware accelerated) that activity was all messed up as well. In my case I had to locate the open gl bug I made and fix it.
Upvotes: 3