2016-09-05 73 views
0

我的問題是:是GLSurfaceView支持EGL上下文3.0 for api18 +。 因爲我用setEGLContextClientVersion(3)然後崩潰accurs,我沒有隻與具有機器人4.4.2 和清單包含GLSurfaceView與opengl ES 3.0

<uses-feature android:glEsVersion="0x00030000" android:required="true"/> 
+0

設備是否支持ES 3.0嗎? –

回答

0

作爲official documentation狀態之一設備嘗試過,該設備可能不支持OpenGL 3.0,所以你應該在設置egl上下文版本之前檢查一下。

但是,如果您在清單中爲uses-feature指定required=true,則一旦該應用在Google Play商店中發佈,對於那些不支持它的設備,該應用將不可見。所以他們將無法安裝它,除非他們設法從其他來源下載APK。

要檢查3.0可你能做到以下幾點:

private static double glVersion = 3.0; 

private static class ContextFactory implements GLSurfaceView.EGLContextFactory { 

    private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098; 

    public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { 
      Log.w(TAG, "creating OpenGL ES " + glVersion + " context"); 
      int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, (int) glVersion, EGL10.EGL_NONE }; 
      // attempt to create a OpenGL ES 3.0 context 
      EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); 
      return context; // returns null if 3.0 is not supported; 
    } 
}