我如何检测我的纹理何时在 android 上被破坏?我的 GLSurfaceView 的渲染器类目前如下所示:
public void onDrawFrame(GL10 gl)
{
nativeLibrary.drawFrame();
}
public void onSurfaceChanged(GL10 gl, int width, int height)
{
if (reload)
{
library.glRecreate(); //this method reloads destroyed textures
}
else
{
nativeLibrary.init(width, height)); //this method initializes my game
reload = true;
}
}
public void onSurfaceCreated(GL10 gl, EGLConfig config)
{
}
问题是这并不总是有效。当我从我的游戏中按下主页按钮然后再次启动它时,它就像一个魅力。但是当我锁定设备,然后再次解锁时,所有纹理都是黑色的。当我锁定它时,一切似乎都重置了(我的游戏总是回到主菜单中)。当我使用主页按钮退出游戏并在此之后进行锁定/解锁时,游戏不会重置。