2016-03-29 47 views
0

我正在使用此代码在手机上获取OpenGL ES版本。getGlEsVersion()在我的nexus 5上使用android版本6.0.1返回3.0

int result; 
    ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); 
    ConfigurationInfo configInfo = activityManager 
      .getDeviceConfigurationInfo(); 
    if (configInfo.reqGlEsVersion != ConfigurationInfo.GL_ES_VERSION_UNDEFINED) { 
     result = configInfo.reqGlEsVersion; 
    } else { 
     result = 1 << 16; // Lack of property means OpenGL ES version 1 
    } 

    Log.e("reqGlEsVersion", String.valueOf(result)); 
    Log.e("getGlEsVersion", configInfo.getGlEsVersion()); 

我发现从这个链接验证码:Is there a way to check if Android device supports openGL ES 2.0?

在我的Nexus 5,我越来越GLES版本为3.0。但根据这个文档,http://developer.android.com/guide/topics/graphics/opengl.html,我应该得到3.1,因为“OpenGL ES 3.1 - 这个API规范是由Android 5.0(API级别21)和更高的支持。”

我想我应该得到3.1作为OpenGL ES版本。任何人都可以告诉我为什么我获得3.0作为OpenGL ES版本?

回答

1

虽然API 21 支持 GLES 3.1,但它不保证其可用性。这是检查在运行时使用的GLES版本的原因(正如在你链接的android文档中所解释的),否则你只需要在清单中要求它。

如果您有Nexus 5,它有一个Adreno 330,它只支持GLES 3.0。因此,如果您希望您的应用程序在Nexus 5上运行,那么您会遇到GLES 3.0,否则,您应该得到支持GLES 3.1的设备,并在您的清单中要求它。

相关问题