Search code examples
iphoneopengl-estextureseaglview

iPhone: How much OpenGL cleanup do I need to do when a context goes away?


I several views in an iPhone app which happen to use independent openGL contexts. They are not necessarily long-lived so they go away before the process does. And they have a couple textures in each.

Does -releaseing the EAGLContext cause all that GL state to get cleaned up for me? Or am I leaking textures etc by not finding a place to call glDeleteTextures from?

Thanks.


Solution

  • All resources associated with a sharegroup are destroyed, when the last reference to that sharegroup is released (usually by destroying all of the shared contexts).

    Do be careful: when you make a context current for a thread, that counts as a reference. A context will not be deleted until it is detached from all threads that it may have been bound to.