Using the GLSurfaceView
to display camera preview data, i got the abnormal preview(as the following screenshot) if i do the following operations:
Finally, i found the solution as following:
In the CameraGLRender
, which implements GLSurfaceView.Renderer
, do something in the onSurfaceChanged
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(0, width, 0, height, -10f, 10f);
gl.glViewport(0, 0, width, height);
// ...
}
It works fine.