Android OpenGL ES 开发教程(13):阶段小结

jerry OpenGL ES 2015年11月25日 收藏

之前介绍了什么是 OpenGL ES ,OpenGL ES 管道的概念,什么是EGL,Android中OpenGL ES的开发包以及GLSurfaceView,OpenGL ES所支持的基本几何图形:点,线,面,已及如何使用这些基本几何通过构成较复杂的图像(20面体)。

但到目前为止还只是绘制2D图形,而忽略了一些重要的概念,3D坐标系,和3D坐标变换,在介绍OpenGL ES Demo程序框架时,创建一个OpenGLRenderer 实现 GLSurfaceView.Renderer接口

  1. public void onSurfaceChanged(GL10 gl, int width, int height) {
  2. // Sets the current view port to the new size.
  3. gl.glViewport(0, 0, width, height);
  4. // Select the projection matrix
  5. gl.glMatrixMode(GL10.GL_PROJECTION);
  6. // Reset the projection matrix
  7. gl.glLoadIdentity();
  8. // Calculate the aspect ratio of the window
  9. GLU.gluPerspective(gl, 45.0f,
  10. (float) width / (float) height,
  11. 0.1f, 100.0f);
  12. // Select the modelview matrix
  13. gl.glMatrixMode(GL10.GL_MODELVIEW);
  14. // Reset the modelview matrix
  15. gl.glLoadIdentity();
  16. }
  17. }

我们忽略了对glViewport,glMatrixMode,gluPerspective以及20面体时glLoadIdentity,glTranslatef,glRotatef等方法的介绍,这些都涉及到如何来为3D图形构建模型,在下面的几篇将详细介绍OpenGL ES的坐标系和坐标变换已经如何进行3D建模。