- OpenGL 是跨平台的图像API,定义了3D图像处理的标准
- OpenGL ES是为OPenGL在嵌入式设备上的标准
安卓支持如下OpenGL
- OpenGL ES 1.0 and 1.1 - This API specification is supported by Android 1.0 and higher.
- OpenGL ES 2.0 - This API specification is supported by Android 2.2 (API level 8) and higher.
- OpenGL ES 3.0 - This API specification is supported by Android 4.3 (API level 18) and higher.
- OpenGL ES 3.1 - This API specification is supported by Android 5.0 (API level 21) and higher.
OpenGL ES 3.0以上需要厂家在设备上安装某图像处理,Android4.3以上可能不支持OpenGL ES 3.0
The Basics
Android中两个class需要特别注意
GLSurfaceView
这是一个view,用来绘画和管理对象,和SurfaceView很相似
GLSurfaceView.Renderer
在GLSurfaceView中绘画的接口,提供了必要的方法
- onSurfaceCreated(): //初始化环境
- onDrawFrame(): //绘画对象
- onSurfaceChanged(): //当界面改变时,比如屏幕旋转
OpenGL ES packages
OpenGL ES 1.0/1.1 API Packages
android.opengl
javax.microedition.khronos.opengles
OpenGL ES 2.0 API Class
android.opengl.GLES20
OpenGL ES 3.0/3.1 API Packages
android.opengl
Declaring OpenGL Requirements
在AndroidManifest.xml中声明OpenGL版本要求
For OpenGL ES 2.0:
<!-- Tell the system this app requires OpenGL ES 2.0. -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
For OpenGL ES 3.0:
<!-- Tell the system this app requires OpenGL ES 3.0. -->
<uses-feature android:glEsVersion="0x00030000" android:required="true" />
纹理压缩要求
<supports-gl-texture>