Android OpenES 版本
版本声明
<!-- Tell the system this app requires OpenGL ES 2.0. -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
版本查询
方法1
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
Log.e("MainActivity", "version: " + Integer.toHexString(configurationInfo.reqGlEsVersion));
方法2
GL gl 从Renderer的onSurfaceCreated获取
gl.glGetString(GL10.GL_VERSION)
总结
为了运行时确定 OpenGL ES 的版本,我们可以先拿到 configurationInfo.reqGlEsVersion
再在 setRenderer() 前调用 setEGLContextClientVersion();
其他
可以使用EGLContextFactory 创建EGLContext。(比如可以尝试创建高版本的EGLContext,判断是否支持高版本的OpenGL ES)
参考
[1]:https://blog.youkuaiyun.com/JektonLuo/article/details/79521382
[2]:https://developer.android.google.cn/guide/topics/graphics/opengl?hl=en#version-check