Dev2rights
Dev2rights

Reputation: 3487

Correct point to release OpenGLES Resources Android NDK

At what stage in the NDK App event lifecycle should i be releasing all my OpenGLES resources?

This includes OpenGLES VBO's and Textures mainly.

DETAILS:

Im releasing in either the APP_CMD_PAUSE or APP_CMD_TERM_WINDOW.

I am logging out each following app event to make sure im exiting smoothly and on doing this i seem to be missing APP_CMD_STOP. I also seem not to be exiting the looper and app smoothly.

I dont have any noticeable side effects of this, however it would appear to me that the app was shut down correctly, but the final stages of the app lifecycle aren't logged out when i release the resources to early. I fear this means that the app isn't shutting down smoothly.

Some clarification on this would be welcomed.

Upvotes: 2

Views: 491

Answers (1)

Jesse Hall
Jesse Hall

Reputation: 6797

Failing to release resources shouldn't prevent you from seeing APP_CMD_STOP. If you just comment out the release code, do you get the command?

You should release the window EGLSurface in APP_CMD_TERM_WINDOW, and re-create it if you get APP_CMD_INIT_WINDOW. Don't forget the eglMakeCurrent calls in both places.

You can keep the EGLContext and all your GL objects/data around when you're in the background so you can resume quickly if the user returns to your application soon. You should release those if you get an APP_CMD_LOW_MEMORY or during exit (android_app::destroyRequested==1).

Upvotes: 0

Related Questions