Android设备GLES版本查询

如果不在代码中使用,只是想知道你手头Android设备所使用的GLES的版本,可以用如下1)和2)中的个方法:

1) 查询系统属性ro.opengles.version

可以直接使用adb shell 命令getprop ro.opengles.version来查询gles版本号。

这个属性在ActivityManagerService中有用到,ams有一个final成员变量GL_ES_VERSION, 它是在ActivityManagerService的构造函数中被赋值的:

public class ActivityManagerService extends IActivityManager.Stub
        implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {
    .....
    /**
     * Hardware-reported OpenGLES version.
     */
    final int GL_ES_VERSION;
    ......
    // Note: This method is invoked on the main thread but may need to attach various
    // handlers to other threads.  So take care to be explicit about the looper.
    public ActivityManagerService(Context systemContext) {
        ......
        GL_ES_VERSION = SystemProperties.getInt("ro.opengles.version",
            ConfigurationInfo.GL_ES_VERSION_UNDEFINED);
        ......
    }
    .......
}

所以只读属性ro.opengles.version就保存着当前Android设备的gles版本;同时查看ams中对GL_ES_VERSION的使用可知,ams的getDeviceConfigurationInfo方法返回的ConfigurationInfo对象中的字段reqGlEsVersion也是使用的GL_ES_VERSION的值,所以用如下代码可以在应用内获取当前设备的gles版本号:

    private int getGLESVersion(){
        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo ci = am.getDeviceConfigurationInfo();
        return ci.reqGlEsVersion;
    }

2) 查看开机log

原生Android SurfaceFlinger初始化过程中会在logcat中打印如下信息:

从这里也可以看到GLES的版本号。

gl接口也提供了查询其版本号的接口,在代码中查询时可以这样使用:

#include <GLES/gl.h>
#include <log/log.h>

void getGlVersion() {
    const char* version = (const char*)glGetString(GL_VERSION);
    ALOGI("GL_VERSION: %s", version);
}
    

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值