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

I need to check dynamically if my device supports openGL ES 2.0. How can i do this?

+23
source share
7 answers

Yes. The following code will do the trick:

final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; 

Read this for more information: http://www.learnopengles.com/android-lesson-one-getting-started/

You may also need to prevent devices that do not support 2.0 from seeing your application on the market by adding the following to your manifest:

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

See also the uses-feature document .

+33
source

In addition to checking the code in other ways, if you want to restrict it to the market ONLY with these devices with 2.0, then in the manifest:

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

You have to do both, I had people who installed apk directly on inappropriate devices and had to deal with strange exceptions. Now I run runTime:

 private boolean detectOpenGLES20() { ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); ConfigurationInfo info = am.getDeviceConfigurationInfo(); return (info.reqGlEsVersion >= 0x20000); } //in activity onCreate if (!detectOpenGLES20()) { throw new RuntimeException("Open GL ES 2.0 was not found on device"); } 
+5
source

Defining OpenGL Extensions:

OpenGL implementations differ for Android devices in terms of the OpenGL ES API extensions that are supported. These extensions include texture compression, but usually also include other extensions for the OpenGL feature set.

To determine which texture compression formats and other OpenGL extensions are supported on a specific device:

Run the following code on the target devices to determine which texture compression formats are supported:

  String extensions = javax.microedition.khronos.opengles.GL10.glGetString(GL10.GL_EXTENSIONS); 

Warning. The results of this conversation are device dependent! You must run this call on several target devices to determine what types of compression are usually supported. Review the results of this method to determine which OpenGL extensions are supported on the device.

+2
source

You can use this code in your code:

  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()); 
+2
source

OpenGL ES was never used, but saw that it has the same glGetString method as OpenGL. He should do the trick:

http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetString.xml

0
source

This code works fine ..

  // Check if the system supports OpenGL ES 2.0. final ActivityManager activityManager = ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); final ConfigurationInfo configurationInfo = activityManager .getDeviceConfigurationInfo(); final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000; if (supportsEs2) { Log.i("JO", "configurationInfo.reqGlEsVersion:" + configurationInfo.reqGlEsVersion + "supportsEs2:" + supportsEs2); // Request an OpenGL ES 2.0 compatible context. myGlsurfaceView.setEGLContextClientVersion(2); final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); // Set the renderer to our demo renderer, defined below. myRenderer = new MyRenderer(this, myGlsurfaceView); } else { // This is where you could create an OpenGL ES 1.x compatible // renderer if you wanted to support both ES 1 and ES 2. return; } 
0
source

For a while I was looking for the same answer. But, unfortunately, I could not find a suitable description for this. I just found a minute ago, and it seems to me that I would like to share it with everyone.

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FeatureInfo[] list = this.getPackageManager() .getSystemAvailableFeatures(); Toast.makeText(this, "OpenGL ES Version: " + list[list.length - 1].getGlEsVersion(), Toast.LENGTH_LONG).show(); } 
0
source

Source: https://habr.com/ru/post/1496629/


All Articles