Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to check if Android device supports openGL ES 3.0?

I need to check dynamically if the used device supports openGL ES 3.0.

How can I do that?

I can't find anything in google or here...

like image 244
NullPointerException Avatar asked Aug 30 '14 15:08

NullPointerException


People also ask

How do I know if my phone has OpenGL?

You can check what GPU your phone has by installing CPU-Z from the Google Play Store. Then, search your GPU in your search engine and find its Web page. On the page, you will find the latest supported version of OpenGL ES.

Can I use OpenGL on Android?

The basics. Android supports OpenGL both through its framework API and the Native Development Kit (NDK).

Can I update OpenGL version Android?

You can't. You need to have a supported GPU which implements OGL 4.1 at the driver level. Your GPU is probably from the pre-DX11 era (Nvidia GeForce 8–300 series, AMD HD4000, Intel HD3000 and earlier). Those GPU series only supported DX10 and OpenGL 3.3 which are similar in terms of features.


2 Answers

I'm going to expand on this answer. There's the initial part in that answer with the configuration info and getting the reqGlEsVersion. Note that it gets the actual OpenGL version of the device, not the required one declared in the manifest as suggested in some comments.

However, I stumbled over a fairly obvious method in the ConfigurationInfo class called getGlEsVersion. It relies on the reqGlEsVersion system in the ConfigurationInfo class, and returns a String value. With some tiny setup, I made a simple test snippet:

ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();

System.out.println(Double.parseDouble(configurationInfo.getGlEsVersion()));
System.out.println(configurationInfo.reqGlEsVersion >= 0x30000);
System.err.println(String.format("%X", configurationInfo.reqGlEsVersion));

The device I tested on supports and uses GLES 3.2, and the test app declares GLES3.0 in the manifest

Runnig this prints:

3.2
true
30002 //A note about this one: It doesn't print as 0x30002 because of the printing method. But it is the same as 0x30002

The entire point of those three print statements was to show that either way works. It prints the version supported of the device, and not that declared in the manifest as mentioned in some comments.

So you can use either of these ways to check the version of OpenGL ES on a given device. Personally, I use this:

double version = Double.parseDouble(configurationInfo.getGlEsVersion());
System.out.println("Version: " + version);//Optional obviously, but this is the reason I use the String and parse it to a double
if(version < 3)
    throw new RuntimeException("Unsupported GLES version");

but this also works (and is slightly more memory efficient):

int version = configurationInfo.getGlEsVersion();
//format and print here if wanted
if(version < 0x30000)
    throw new RuntimeException("Unsupported GLES version");

you could of course show a toast and quit, a dialog, an activity, a fragment, whatever you feel like if the user doesn't meet the requirement. You also should, because if it comes from a third party site, there's a chance requirements were bypassed. I just throw an exception because I declare the usage of GLES3 in the manifest, meaning that throw shouldn't happen in the first place.

As for the manifest tag:

<uses-feature android:glEsVersion="0x00030000" android:required="true" />

This doesn't prevent apps with GLES2 or lower from installing it if they got for an instance a direct install from an APK file or through USB debugging. It's a flag that tells Google Play (or any other stores that exist and check for that) that GLES < (in this case) 3 isn't supported and Google Play would prevent the install. But anyone could install it from a mirror that ignores things like that, so the tag itself isn't a way of preventing GLES2 and lower devices from installing it.

And there's of course the eglCreateContext() method, but that only works with the native system. It does not work with things like LibGDX or anything that uses a separate renderer since it would create a different context than the library would use.

And glGetString(GL_VERSION) would work mostly anywhere, assuming the method is supported by the library/framework. It's natively integrated into GLES2 though, and requires actually creating the OpenGL context first. Using the first methods seem like a better choice on Android. However, this is, of course, up to you.

like image 183
Zoe stands with Ukraine Avatar answered Nov 13 '22 21:11

Zoe stands with Ukraine


yes download CPU-Z and every piece of info of your phone is in this app.

its on the play store as: CPU-Z.

like image 34
Lester Avatar answered Nov 13 '22 19:11

Lester