2014-08-30 1961 views
1

我需要動態檢查用過的設備是否支持openGL ES 3.0。有沒有辦法檢查Android設備是否支持openGL ES 3.0?

我該怎麼做?

我找不到任何谷歌或在這裏...

感謝

+0

http://stackoverflow.com/questions/9198293/is-there-a-way-to-check-if-android-device-supports-opengl-es-2-0 google on google ... – TheWhiteLlama 2014-08-30 15:40:36

+0

除了這個問題上的最高票數和被接受的答案沒有真正地回答它。 – 2014-08-30 16:03:06

+1

ohhhh你就像愛因斯坦,兄弟,這個問題是爲opengl 2.0 – NullPointerException 2014-08-30 16:03:37

回答

1

我覺得這個代碼將有助於你

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

這篇文章可以幫助您更

http://www.learnopengles.com/android-lesson-one-getting-started/

+0

我不認爲這給出了所需的信息。基於'ConfigurationInfo'文檔,聽起來像這樣會在應用程序清單中給出應用程序所請求的版本,而不是設備支持的版本。 – 2014-08-30 15:52:28

+0

這不會檢查設備支持的版本,但會檢查您配置應用的方式。 – crazypeter 2017-11-29 21:45:44

1

這是在Android SDK docume中記錄的ntation:

http://developer.android.com/guide/topics/graphics/opengl.html#version-check

你基本上有3種選擇:

  1. 如果你的應用程序只與ES 3.0的作品,你要求的版本在你的清單:

    <uses-feature android:glEsVersion="0x00030000" android:required="true" /> 
    
  2. 你嘗試使用eglCreateContext()創建一個ES 3.0上下文,並檢查它是否成功。

  3. 您創建ES 2.0上下文,然後使用glGetString(GL_VERSION)檢查支持的版本。

上面的鏈接有解決方案2每一件你的手機信息是在此應用程序示例代碼和3

-1

是下載CPU-Z和。

其在Play商店中的圖片爲:CPU-Z。

0

我打算擴展this answer。這個答案的最初部分是配置信息並獲得reqGlEsVersion。它獲取設備的實際GL版本,而不是在某些評論中建議的清單中聲明的​​必需版本。

但是,我偶然發現了ConfigurationInfo類中一個相當明顯的方法,叫做getGlEsVersion。它依賴於ConfigurationInfo類中的reqGlEsVersion系統,並返回一個String值。與一些微小的安裝,我做一個簡單的試驗片段:

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

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

我上運行測試GLES 3.2和應用程序在清單

聲明GLES3.0的裝置即打印,在各自的順序:

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 

這三個打印語句的全部內容都表明這兩種方法都有效。它打印支持該設備的版本,而不是在某些註釋中提到的清單中聲明的​​版本。

因此,您可以使用以下任一方法檢查給定設備上的OpenGL ES版本。就個人而言,我用這個:

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"); 

,但是這也適用:

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

你當然可以顯示一個麪包和退出,一個對話框,一個活動,一個片段,不管你覺得像。我只是拋出一個異常,因爲我在manifest中聲明瞭GLES3的用法,這意味着拋出不應該發生在第一位。

而對於清單標籤:

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

這不會阻止安裝,如果他們已經有了例如與GLES2或應用更低從APK文件或USB調試直接安裝。這是一個標誌,告知Google Play(或任何其他存在並檢查該商店的商店),GLES <(在這種情況下)3不受支持,Google Play將阻止安裝。但任何人都可以從一個忽略這種事情的鏡像安裝它,所以標籤本身不是阻止GLES2和更低級設備安裝的方式。

當然有eglCreateContext()方法,但只適用於本機系統。它不適用於諸如LibGDX之類的東西或任何使用單獨渲染器的東西,因爲它會創建與庫所使用的不同的上下文。

glGetString(GL_VERSION)大多數情況下都可以工作,假設該方法受庫/框架支持。儘管它本地集成到GLES2中。

相關問題