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

详解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参数 gl.glGetString 的全部内容, 来源链接: utcz.com/z/333560.html

回到顶部