Question

i have a game running in a GLSurfaceView embedded in a regular Android layout. After the app has been running for a while and a lot of textures have been created and then later deleted ( all shown texts are dynamically rendered into textures and if not used, deleted again ), textures from the other layout elements lose their textures.

For example textviews or buttons lose their text textures.messed up button text

This seems to be a problem of all Android Versions > 3 where the layout is rendered by the OpenGL ES renderer.

Non of the game textures ever get lost. Only the view textures.

the glGenTextures and glDeleteTextures are synchronized so that should not be an issue..

Is there something else one must take care of when mixing regular android views and OpenGL?

Was it helpful?

Solution 2

Since I was doing all the texture handling queued to the surfaceview anyway, it could not be caused by that ( like CFlex pointed out).

In the end it was to be the following: I was calling some gl methods in the constructor of the renderer. however, the renderer is constructor before the context is created since the renderer has to passed to the surfaceview since on init. So the gl calls seemed to mess up the layout context.

funny enough, most devices didn't seem to care ( other than the described behaviour of losing textures). however, the lg p990 crashed on startup with a "context not created" exception and that gave the final clue. after doing the gl initialization not in the renderer constructor but later on the effect went away.

and please. vote up CFlex's answer since it addresses one important half of the problem.

OTHER TIPS

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...

I had the same problem. Next line helped me to solve this.

<application android:hardwareAccelerated="false" ...>

Wondering what problem was not on all devices which I tested.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top