Graphics Programs Reference
In-Depth Information
2. Selection of surface configuration for various settings, such as the bit
depth for color components
3. EGL context creation using the configuration in step 2
4. “Make current” of context for use with a rendering surface
5. Addition of context to an EGL window (that is, the rendering surface)
The GLSurfaceView Class
The GLSurfaceView class ( android.opengl.GLSurfaceView ) performs
this automation by managing EGL . Although most of the steps previously listed
are automatic, step 2 requires you to specify the version of OpenGL ES you intend
to use on your rendering surface by calling the setEGLContextClientVer-
sion(int version) method, as shown in Listing 3-1 .
Listing 3-1. GL SURFACE/src/com/apress/android/glsurface/Main.java
_surfaceView.setEGLContextClientVersion(2);
Note There are other setEGL* methods you can use to configure
the EGL context (for example, methods to configure the bit depth
for RGB color components on the rendering surface); however, for
all ES 2.0 applications used in this topic, we have only made one
configuration change by setting the version of OpenGL ES using
setEGLContextClientVersion .
To use this class to render graphics on an EGL window (that is, the rendering
surface), we first create an instance of type GLSurfaceView ( an-
droid.opengl.GLSurfaceView ), as shown in Listing 3-2 . Then, we specify
the version of OpenGL ES, so we can configure the current EGL context to become
OpenGL ES 2.0 compatible.
Listing 3-2. GL SURFACE/src/com/apress/android/glsurface/Main.java
public class Main extends Activity {
private GLSurfaceView _surfaceView;
 
 
 
 
Search WWH ::




Custom Search