详解Android获得系统GPU参数 gl.glGetString
程序员文章站
2022-04-13 22:46:05
详解android获得系统gpu参数 gl.glgetstring
通过文档的查找,以及源码的剖析,android的gpu信息需要通过opengl来获取,android...
详解android获得系统gpu参数 gl.glgetstring
通过文档的查找,以及源码的剖析,android的gpu信息需要通过opengl来获取,android framework层提供gl10来获取相应的参数,而gl10要在使用自定义的view时才可以获得,下面是获得gpu信息的例子:
1.实现render类
class demorenderer implements glsurfaceview.renderer { public void onsurfacecreated(gl10 gl, eglconfig config) { log.d("systeminfo", "gl_renderer = " +gl.glgetstring(gl10.gl_renderer)); log.d("systeminfo", "gl_vendor = " + gl.glgetstring(gl10.gl_vendor)); log.d("systeminfo", "gl_version = " + gl.glgetstring(gl10.gl_version)); log.i("systeminfo", "gl_extensions = " + gl.glgetstring(gl10.gl_extensions)); } @override public void ondrawframe(gl10 arg0) { // todo auto-generated method stub } @override public void onsurfacechanged(gl10 arg0, int arg1, int arg2) { // todo auto-generated method stub } }
2.实现glsurfaceview
class demoglsurfaceview extends glsurfaceview { demorenderer mrenderer; public demoglsurfaceview(context context) { super(context); seteglconfigchooser(8, 8, 8, 8, 0, 0); mrenderer = new demorenderer(); setrenderer(mrenderer); } }
3.在activity中 new 一个 demoglsurfaceview 对象
4.设置这个view对象
public class demo extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); glsurfaceview glview = new demoglsurfaceview(this); this.setcontentview(glview); } }
以上就是android获取gpu 参数的例子,如果大家研究android gpu 的知识,必须研究android gpu的源码,这里只是给个小例子,希望能帮助到大家,谢谢大家对本站的支持!