Thursday, August 1, 2013

Check OpenGL ES capability on Android

There are lots of Android devices around the world. And when you want to create one application that need OpenGL ES, you would think (what I thought) if the user's device can run smoothly by checking the OpenGL ES version because this is important.

So how to check the OpenGL ES version?

  1. By using SystemService. This is the simplest one. You don't need to create any OpenGL ES component.
    final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x30000;
  2. By using glGetService. By doing this, you can get more information, like the vendor, chip, shading version, etc. But, you need to have GL context first.
    String glVersion = GLES20.glGetString(GLES20.GL_VERSION);
    String glRenderer = GLES20.glGetString(GLES20.GL_RENDERER);
    String glVendor = GLES20.glGetString(GLES20.GL_VENDOR);
    String glShadingLanguageVersion = GLES20.glGetString(GLES20.GL_SHADING_LANGUAGE_VERSION);
    String glExtensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);

No comments:

Post a Comment

[ROM] Samsung S7 Stock Firmware BRI (Taiwan台灣)

Latest ROM: G930FXXU1DQEU Download: https://kfhost.net/tpl/firmwares.php?record=B7E6DE774E3811E7963AFA163EE8F90B Reference: http://...