Creating a Renderer Class

Now we’re going to define a Renderer so that we can start clearing the screen. Let’s take a quick overview of the methods defined by the Renderer interface:

onSurfaceCreated(GL10 glUnused, EGLConfig config)

GLSurfaceView calls this when the surface is created. This happens the first time our application is run, and it may also be called when the device wakes up or when the user switches back to our activity. In practice, this means that this method may be called multiple times while our application is running.

onSurfaceChanged(GL10 glUnused, int width, int height)

GLSurfaceView calls this after the surface is created and whenever the size has changed. A size change can occur when switching from portrait to landscape and ...

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.