Graphics Programs Reference
In-Depth Information
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
_surfaceView = new GLSurfaceView(this);
_surfaceView.setEGLContextClientVersion(2);
_surfaceView.setRenderer(new GLES20Renderer());
setContentView(_surfaceView
);
}
}
Note We have been calling the rendering surface different
names— EGL window, OpenGL surface, OpenGL surface view,
OpenGL view, and GL surface. Do not get confused; they are all the
same.
Setting up the Renderer
Although the GLSurfaceView class can automate many steps, it cannot directly
render graphics on the rendering surface. This requires a Renderer object that does
the actual rendering. We specify the renderer using the setRender-
er(GLSurfaceView.Rendererrenderer) method. Abstract methods of the
GLSurfaceView.Renderer interface ( an-
droid.opengl.GLSurfaceView.Renderer ) can be easily implemented
within an anonymous inner type. However, for all ES 2.0 applications in the source
code, we created a separate Renderer class— GLES20Renderer —similar to the
Renderer class from the GL SURFACE application ( Listing 3-3 ).
Listing
3-3. GL SURFACE/src/com/apress/android/glsurface/GLES20Render-
er.java
public class GLES20Renderer implements Renderer {
public void onSurfaceCreated(GL10 gl, EGLConfig
 
 
Search WWH ::




Custom Search