Reputation: 43
I have some problems pausing my application. I use separate thread for game logic. So I pause my thread but I don't know how to properly pause and recreate OpenGL view. Here's my code. It works but I think there might be memory leaks. Display is GLSurfaceView and Renderer is GLSurfaceView.Renderer.
@Override
public void onPause()
{
super.onPause();
display = null;
game.pause();
Game.texturesLoaded = false;
}
@Override
public void onResume()
{
// TODO normal pause
super.onResume();
display = new Display(this);
display.setRenderer(renderer);
setContentView(display);
game.resume();
}
Upvotes: 2
Views: 1361
Reputation: 26925
Recreating any OpenGL related stuff should be done via onSurfaceCreated()
.
Upvotes: 1
Reputation: 4150
It should be enough to simply call display.onPause()
and display.onResume()
.
See the Activity Life-Cycle section of http://developer.android.com/reference/android/opengl/GLSurfaceView.html
Upvotes: 0