Working with OpenGL ES - Android

Before 1992, Silicon Graphics (SGI) had a proprietary graphics standard called Integrated Raster Imaging System Graphics Library (IRIS GL) and known typically as just GL. In 1992, to clean up the code and make GL more maintainable, SGI created OpenGL and set up a consortium of companies to maintain the open standard form of GL. Today, this consortium is known as the nonprofit Khronos Group, with more than 100 member companies. OpenGL ES was developed in the early 2000s to extend this open library to embedded devices. OpenGL ES is a subset of OpenGL. EGL was developed shortly thereafter to provide a common interface layer to native platform graphics.

Within the interfaces, OpenGL is simply referred to as GL. This is true for OpenGL ES, as well. Within the text of this chapter, GL typically refers to the underlying objects and interfaces within OpenGL to be consistent with the naming conventions within the code. OpenGL ES typically refers to the Android implementation of the OpenGL ES subset of OpenGL. Finally, OpenGL is used in a more generic fashion to refer to the generic concept or library.

Leveraging OpenGL ES in Android

Android developers can implement 3D graphics applications in two ways:

  • The Android SDK provides OpenGL ES functionality within the android.opengl package in conjunction with the Khronos javax. microedition. khronos.opengles and javax. microedition. khronos.egl packages.
  • The Android Native Development Kit (NDK) can be used to leverage OpenGL ES 1.1 and 2.0 native libraries for optimum performance.

The Android SDK has support for different versions of OpenGL ES, depending on the API Level or platform version:

  • OpenGL ES 1.0 functionality (android.opengl) is fully supported on devices running Android 1.0 (API Level 1) and higher.
  • OpenGL ES 1.1 (android.opengl.GLES11) is fully supported by devices running Android 1.6 (API Level 4) and higher.
  • OpenGL ES 2.0 (android.opengl.GLES20) is fully supported by devices running Android 2.2 (API Level 8) and higher.

Ensuring Device Compatibility

Applications that require OpenGL functionality should declare this fact within the Android Manifest file using the <uses-feature> tag with the android: glEs Version attribute. This enables stores like the Android Market to filter the application and provide it only to devices that support the OpenGL version required by the application. The android:glEsVersion attribute is a 32-bit number where the high bits specify the major version and the low bits specify the minor version.

  • If the application requires OpenGL ES 1.0, then you do not need to declare any <uses-feature> tag, as this is the default for all applications. All Android devices support OpenGL ES 1.0.
  • If the application requires OpenGL ES 1.1, then you should declare a <uses-feature> tag as follows: <uses-feature android:glEsVersion =" 0x00010001" />.
  • If the application requires OpenGL ES 2.0, then you should declare a <uses-feature> tag as follows: <uses-feature android:glEsVersion =" 0x00020000" />.

Only one OpenGL ES version should be listed in the Android Manifest file. Applications that can function using different versions of OpenGL ES by checking for the supported graphics libraries at runtime should specify the lowest version supported by their application. It’s also safe to assume that if a platform supports a newer version of OpenGL ES, say 2.0, then it also supports all older versions (such as 1.1 and 1.0).

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Android Topics