开发者

Android OpenGL ES GL10 or GL11

开发者 https://www.devze.com 2023-02-06 19:49 出处:网络
What is the different beetween this, and how i can query what is supported by the actual phon开发者_Python百科e? (GL10 or GL11)

What is the different beetween this, and how i can query what is supported by the actual phon开发者_Python百科e? (GL10 or GL11)

i have a HTC Legend, that is supported GL11 or not? Or hero...etc... ?


There's an API for that:

public int getGLVersion() 
{
    ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    return info.reqGlEsVersion;
}

The upper order 16 bits represent the major version and the lower order 16 bits the minor version. For more information, visit this link. So:

  • For OpenGLES 1.1, getGLVersion() == 0x00010001
  • For OpenGLES 2.0, getGLVersion() == 0x00020000

If you want the string representation (for display), call ConfigurationInfo.getGlEsVersion()


You can use instanceof on your GL10 instance to test if GL11 or higher is supported:

public void onSurfaceCreated(GL10 gl, EGLConfig config)
{        
  if(gl instanceof GL11)
  {
    // ...
  }
}


Use glGetString to query the version info, You have to be careful when parsing the returned string - some implementations don't quite follow the spec - but the code here works for me.


In practice, anything that actually has graphics hardware, will support 1.1. 1.0 was a profile designed for software implementations, and there exists no hardware that supports only 1.0 afaik.

If it doesn't have graphics hardware, you don't really want to run your gl app on it anyhow because of very poor performance, so you could just as well set AndroidManifest.xml to specify version 0x00010001, and then you know it will support GL11.

Also, anything released in '11 or later will most probably support GLES 2.0 (and all gl2.0 support gl1.1)

Check the android market stats, 90.5% of devices support 2.0, and 1.0 isn't even in the stats, because 1.0 is never used by anyone.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号