详解Android获得系统GPU参数 gl.glGetString
详解Android获得系统GPU参数gl.glGetString
通过文档的查找,以及源码的剖析,Android的GPU信息需要通过OpenGL来获取,androidframework层提供GL10来获取相应的参数,而GL10要在使用自定义的View时才可以获得,下面是获得GPU信息的例子:
1.实现Render类
classDemoRendererimplementsGLSurfaceView.Renderer{ publicvoidonSurfaceCreated(GL10gl,EGLConfigconfig) { 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 publicvoidonDrawFrame(GL10arg0){ //TODOAuto-generatedmethodstub } @Override publicvoidonSurfaceChanged(GL10arg0,intarg1,intarg2){ //TODOAuto-generatedmethodstub } }
2.实现GLSurfaceView
classDemoGLSurfaceViewextendsGLSurfaceView{ DemoRenderermRenderer; publicDemoGLSurfaceView(Contextcontext){ super(context); setEGLConfigChooser(8,8,8,8,0,0); mRenderer=newDemoRenderer(); setRenderer(mRenderer); } }
3.在Activity中new一个DemoGLSurfaceView对象
4.设置这个View对象
publicclassDemoextendsActivity{ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); GLSurfaceViewglView=newDemoGLSurfaceView(this); this.setContentView(glView); } }
以上就是Android获取GPU参数的例子,如果大家研究AndroidGPU的知识,必须研究AndroidGPU的源码,这里只是给个小例子,希望能帮助到大家,谢谢大家对本站的支持!