如何确定Android设备是否具有代码中的GPU?

时间:2011-11-18 16:03:43

标签: android gpu

我想知道Android设备是否有GPU,有没有办法从代码中确定?我在NDK中查看了cpufeatures.h但似乎没有关于GPU的任何内容

1 个答案:

答案 0 :(得分:1)

这是诀窍,

final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        final ConfigurationInfo configurationInfo = activityManager
                .getDeviceConfigurationInfo();
        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

    if (supportsEs2) {
        Log.i("JO", "configurationInfo.reqGlEsVersion:"
                + configurationInfo.reqGlEsVersion + "supportsEs2:"
                + supportsEs2);
        // Request an OpenGL ES 2.0 compatible context.
        myGlsurfaceView.setEGLContextClientVersion(2);

        final DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

        // Set the renderer to our demo renderer, defined below.
        myRenderer = new MyRenderer(this, myGlsurfaceView);