Initializing OpenGL

Our next step is to go ahead and initialize OpenGL by using a special class called GLSurfaceView. GLSurfaceView takes care of the grittier aspects of OpenGL initialization, such as configuring the display and rendering on a background thread. This rendering is done on a special area of the display, called a surface; this is also sometimes referred to as a viewport.

The GLSurfaceView class also makes it easy to handle the standard Android activity life cycle. In Android, activities can be created and destroyed, and they are also paused and resumed when the user switches to another activity and later returns. In accordance with this life cycle, we need to release OpenGL’s resources when our activity is paused. GLSurfaceView ...

Get OpenGL ES 2 for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.