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

后端 未结 7 1031
轻奢々
轻奢々 2020-12-02 23:16

I need to check dynamically if the used device supports openGL ES 2.0. How can i do that?

7条回答
  •  死守一世寂寞
    2020-12-02 23:46

    In addition to checking in code in the ways that others have mentioned, if you want to restrct it in market to ONLY those devices with 2.0 then in manifest:

        
    

    You should do both, I've had people install the apk directly on to unsuitable devices and had to deal with strange exceptions. Now I throw a 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");
        }
    

提交回复
热议问题