http://www.imobilebbs.com/wordpress/?p=1508
@Override
public void onDrawFrame(GL10 gl) {
logPrint("onDrawFrame");
//黑色背景
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
//启用阴影平滑
gl.glShadeModel(GL10.GL_SMOOTH);
//设置深度缓存
gl.glClearDepthf(1.0f);
//启用深度测试
gl.glEnable(GL10.GL_DEPTH_TEST);
//所做深度测试类型
gl.glDepthFunc(GL10.GL_LEQUAL);
//告诉系统对透视进行修正
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
logPrint("onSurfaceChanged");
//设置OpenGL场景大小
gl.glViewport(0, 0, width, height);
//设置投影矩阵
gl.glMatrixMode(GL10.GL_PROJECTION);
//重置当前指定的矩阵为单位矩阵
gl.glLoadIdentity();
GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
//选择模型观察矩阵
gl.glMatrixMode(GL10.GL_MODELVIEW);
//重置模型观察矩阵
gl.glLoadIdentity();
// TODO Auto-generated method stub
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
logPrint("onSurfaceCreated");
//清除屏幕和深度缓存
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
}