How to detect OpenGl version at run time. Android

孤人 提交于 2019-12-29 01:53:11

问题


How can I detect witch openGl version my device is running? All what I found is android saying that all devices 2.3+ support openGL 2.0. Witch is not true as I found devices that been upgraded to version 2.3 but they system doesn't support it.


回答1:


glGetString(GL_VERSION)

See more at: http://www.khronos.org/opengles/documentation/opengles1_0/html/glGetString.html




回答2:


From the Android CTS's (Compatibility Test Suite) OpenGlEsVersionTest.java:

private static int getVersionFromPackageManager(Context context) {
    PackageManager packageManager = context.getPackageManager();
    FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
    if (featureInfos != null && featureInfos.length > 0) {
        for (FeatureInfo featureInfo : featureInfos) {
            // Null feature name means this feature is the open gl es version feature.
            if (featureInfo.name == null) {
                if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
                    return getMajorVersion(featureInfo.reqGlEsVersion);
                } else {
                    return 1; // Lack of property means OpenGL ES version 1
                }
            }
        }
    }
    return 1;
}

/** @see FeatureInfo#getGlEsVersion() */
private static int getMajorVersion(int glEsVersion) {
    return ((glEsVersion & 0xffff0000) >> 16);
}

It actually provides a few other ways as well and the test verifies that they all return the same results.



来源:https://stackoverflow.com/questions/10684918/how-to-detect-opengl-version-at-run-time-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!