onNativeWindowCreated (ANativeActivity *activity, ANativeWindow *window)
onNativeWindowDestroyed (ANativeActivity *activity, ANativeWindow *window)
And their relation with an OpengGL contextMore specifically those calls and when I should be using calls to OpenGL and creating rendering systems like a SpriteBatcher
Currently in my activity, I have it setup where the onNativeWindowCreated callback triggers the creation of a EGLDisplay, which in turn creates an OpenGL context. In addition, this trigger (the onNativeWindowCreated one) also creates my SpriteBatcher rendering class.
//In Trigger for onNativeWindowCreated
//Code that creates and sets up opengl
CreateEGLDisplay();
//Code that creates everything needed by the sprite batcher
//(OpenGL calls happen here, creation of buffers and etc)
spriteBatcher = new SpriteBatcher();
And the onNativeWindowDestroyed callback triggers a method to destroy said EGLDisplay and the sprite batcher.
//In Trigger for onNativeWindowDestroyed
//Code that creates and sets up opengl
DestroyEGLDisplay();
//Free up the sprite batcher
delete spriteBatcher;
So I'm wondering is this how I should I be handling classes and things that make OpenGL calls? I know you need a OpenGL context in order to make those calls. But...Since I'm destroying the context when the window is killed (which I assume is perfectly normal or what I should be doing) I'm wondering how should OpenGL textures, buffers, and etc are handled. Do I just need to recreate them each time? Is this normal? Should I be doing it differently?