2

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216

2 Answers2

5

glGetString(GL_VERSION)

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

Tim
  • 35,413
  • 11
  • 95
  • 121
  • If GL10 class is used, 1.1 is on the string, if OpenGL Es version is 3.0, results can confuse users. –  Mar 26 '16 at 01:16
5

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.

Anthony
  • 4,720
  • 1
  • 22
  • 9