首页 > 系统 > Android > 正文

详解Android获得系统GPU参数 gl.glGetString

2019-12-12 02:28:41
字体:
来源:转载
供稿:网友

详解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的源码,这里只是给个小例子,希望能帮助到大家,谢谢大家对本站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表