3
\$\begingroup\$

I am creating a framework for OpenGL ES 2.0 for Android. How can I cleanly dispose of my OpenGL resources when my Android app is done?

I check for isFinished() in the onPause() event and 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?

\$\endgroup\$
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – fadden Jan 23 '13 at 17:56
  • 1
    \$\begingroup\$ @fadden: You should post that as an answer \$\endgroup\$ – Kromster Feb 17 '14 at 4:05
3
\$\begingroup\$

As has been noted, if you are using GLSurfaceView, you don't need to handle the cleanup as the resources will be released when the context is lost.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.