0

我正在使用此代码在手机上获取 OpenGL ES 版本。

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 support openGL ES 2.0?

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

我想我应该得到 3.1 作为 OpenGL ES 版本。谁能告诉我为什么我得到 3.0 作为 OpenGL ES 版本?

4

1 回答 1

1

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

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

于 2016-03-30T02:44:10.363 回答