by aaronzheng » Thu Jan 14, 2010 10:35 am
[quote="zorro"]I think it worked because the phone didn't release your old resources, but this is not going to work all the times. I found on a forum some advices about pause/resuming in opengl on android and I found them useful. Here they are:
- Your activity should only be creating one GLSurfaceView in onCreate and releasing it in onDestroy
- Your activity onPause and onResume must call your GLSurfaceView's onPause and onResume.
- Ideally, your GLSurfaceView will create your renderer.
- Your renderer needs to reload everything (textures, vbos, etc) to video memory when the surface has hanged.
- After the surface has changed, when reloading, get all new texture and vertex buffer IDs. Do not use the old ones or you could crash the gl system.
So you must reload (load, when app starts first time) everything in onSurfaceCreated. If the system calls that it means that the surface was recreated and all GL data must be reloaded. You don't need to free the old textures yourself, they were lost when the surface was destroyed.[/quote]
Great Thanks for your advices.
I reload everything (textures, vbos, etc) to video memory when the surface has changed, it woks fine
when i press the "home" key to go out the game and switch back to the game by running-programming panel(by long pressing "home" key on my G1).
However, When i press the "nocall" key, the screen locked and turn black. then i press the "call" key to light the
screen, the handset hint me to press "menu" key to unlock, i unlock the screen, the result is the same as before, a few objects are drawing on the screen, lots of them are disappeared.
I am sure i reload everything after I press "call" key. :cry: