OpenGL 包
一旦使用GLSurfaceView和GLSurfaceView.Renderer類給OpenGL建立瞭一個View容器,那麼就可以開始使用以下的類來調用OpenGL的API:
1. OpenGL ES 1.0/1.1 API 包
android.opengl——這個包給OpenGL ES 1.0/1.1提供瞭一個靜態的接口,並且比javax.microedition.khronos包接口具有更好的性能。
GLES10(https://developer.android.com/reference/android/opengl/GLES10.html)
GLES10Ext(https://developer.android.com/reference/android/opengl/GLES10Ext.html)
GLES11(https://developer.android.com/reference/android/opengl/GLES11.html)
GLES10Ext(https://developer.android.com/reference/android/opengl/GLES10Ext.html)
javax.microedition.khronos.opengles——這包提供瞭OpenGL ES 1.0/1.1的標準實現
GL10(https://developer.android.com/reference/javax/microedition/khronos/opengles/GL10.html)
GL10Ext(https://developer.android.com/reference/javax/microedition/khronos/opengles/GL10Ext.html)
GL11(https://developer.android.com/reference/javax/microedition/khronos/opengles/GL11.html)
GL11Ext(https://developer.android.com/reference/javax/microedition/khronos/opengles/GL11Ext.html)
GL11ExtensionPack(https://developer.android.com/reference/javax/microedition/khronos/opengles/GL11ExtensionPack.html)
2. OpenGL ES 2.0 API 類
android.opengl.ELES20——這個包提供OpenGL ES 2.0的接口,並且從Android2.2(API Level 8)開始有效。
如果想要立即創建與OpenGL有關的應用程序,請看OpenGL ES 1.0或OpenGL ES 2.0開發指南。
OpenGL ES 1.0:https://developer.android.com/resources/tutorials/opengl/opengl-es10.html
OpenGL ES 2.0:https://developer.android.com/resources/tutorials/opengl/opengl-es20.html
聲明OpenGL的需求
如果應用程序使用的OpenGL功能不是在所有的設備上都是有效的,那麼就必須在該應用的AndroidManifest.xml文件中包含這些功能需求。
通常OpenGL清單的聲明如下:
1. OpenGL ES的版本需求—如果應用程序隻支持OpenGL ES 2.0,那麼就必須通過把下列設置添加到清單中來聲明該需求:
<!– Tell the system this app requires OpenGL ES 2.0. –>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
添加這個聲明後,會導致Google Play限制該應用程序安裝在那些不支持OpenGL ES 2.0的設備上。
2. 紋理壓縮的需求—如果應用程序使用瞭紋理壓縮格式。就必須在該應用的清單文件中使用<supports-gl-texture>元素來聲明其所支持的格式。關於有效的紋理壓縮格式的更多信息,請看本文後續的“紋理壓縮支持”
在應用程序清單中聲明紋理壓縮需求會把該應用程序從那些不支持其聲明的壓縮格式的設備上隱藏掉(隻要有一種格式不被支持)。
作者:FireOfStar