user1974633
user1974633

Reputation: 59

Best way to force android to destroy textures and shaders

I was wondering what is the best way to force android to destroy all textures and shader programs?

I found that calling GLSurfaceView.onPause and then GLSurfaceView.onResume seems to work, but I am not sure if that is correct. The other thing I thought of was to break the game into 2 activities and transfer control back and forth each time a new level needed to be loaded but that seemed to be an ugly approach.

Upvotes: 0

Views: 751

Answers (1)

Tim
Tim

Reputation: 35923

I think what you have (pause/resume) should work.

On pre-honeycomb devices, pausing the glsurfaceview destroys the context, which will destroy all of the shaders and resources.

After honeycomb, there is a function called setPreserveEGLContextOnPause, which gives you the option to retain the context when the surfaceview is paused. This defaults to false, so unless you want to preserve your context it will always be destroyed by a pause event.

Upvotes: 2

Related Questions