当手机从锁屏界面解锁后 发现在运行的程序上画出的图形全部变成了白色;
原来图形上的贴图都没有了;
如果 退出程序 再重新打开的话 那么显示正常;
我想锁屏幕的话 应该经过onSurfaceChanged 方法;所以 我怀疑是方法出问题了;
下面贴出 我的renderer 的主要代码
public abstract class AbstractRender implements Renderer{
AnimationCallback mCallback ;
int viewWidth ;
int viewHeight ;
int[] mViewport = null ;
float scale = 0.5f ;
public int[] textures ;
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glEnable(GL10.GL_TEXTURE_2D); //Enable Texture Mapping ( NEW )
gl.glShadeModel(GL10.GL_SMOOTH); //Enable Smooth Shading
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); //Black Background
gl.glClearDepthf(1.0f); //Depth Buffer Setup
gl.glEnable(GL10.GL_DEPTH_TEST); //Enables Depth Testing
gl.glDepthFunc(GL10.GL_LEQUAL); //The Type Of Depth Testing To Do
//Really Nice Perspective Calculations
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
//纹理相关
// IntBuffer textureBuffer = IntBuffer.allocate(6);
// gl.glGenTextures(6, textureBuffer);
//
// textures = textureBuffer.array();
// bindTexture(gl);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
viewWidth = width ;
viewHeight = height ;
mViewport = new int[]{0,0,width,height};
Log.d("onSurfaceChanged", "onSurfaceChanged,");
gl.glViewport(0, 0, width, height);
float ratio = (float)width/height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity(); //Reset The Projection Matrix
gl.glFrustumf(-ratio, ratio, -1, 1, 2, 12);
((CubeActivity)mCallback).mGrabber.getCurrentProjection(gl);
gl.glMatrixMode(GL10.GL_MODELVIEW); //Select The Modelview Matrix
gl.glLoadIdentity(); //Reset The Modelview Matrix
gl.glDisable(GL10.GL_DITHER);
gl.glActiveTexture(GL10.GL_TEXTURE0);