2016-09-05 71 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; 
    } 
}