Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am creating a framework for OpenGL ES 2.0 for android and my question is how can I cleanly dispose of my OpenGL resources when my android app is done?

I check for isFinished() in the onPause() event en then dispose of the resources but it calls the OpenGL functions from the main UI thread so it gives me an error (0x501).

When I try to call isFinished() inside my onDraw in my GLSurfaceView.Renderer class it is never called when I quit my app.

Anyone got any ideas?

EDIT: I guess I found the anwser to my question in the source code of android itself.

In the interface GLSurfaceView.Renderer the header comment for onSurfaceCreated() states the following: * Note that when the EGL context is lost, all OpenGL resources associated * with that context will be automatically deleted. You do not need to call * the corresponding "glDelete" methods such as glDeleteTextures to * manually delete these lost resources.

share|improve this question
If you're using GLSurfaceView, you don't really need to do anything -- it does it all for you. It actually discards everything whenever the activity is paused, which is good to know when figuring out where to allocate stuff, i.e. you want to create all your GL programs in onSurfaceCreated(). See code.google.com/p/android-breakout for an example. – fadden Jan 23 at 17:56

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.