详解Android获得系统GPU参数 gl.glGetString
发布时间:2020-10-20 22:27:12
来源:脚本之家
阅读:150
作者:lqh
详解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的源码,这里只是给个小例子,希望能帮助到大家,谢谢大家对本站的支持!