The only other method in MyGLSurfaceView is the constructor.
50 public MyGLSurfaceView(Context context) 51 { 52 super(context); 53 // We are using the OpenGL ES 2 API.. 54 setEGLContextClientVersion(2); 55 renderer = new TriangleRenderer(); 56 // Set the Renderer for drawing on the GLSurfaceView 57 setRenderer(renderer); 58 // Render the view only when there is a change in the drawing data 59 setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); 60 }
This constructor is focused on the creation of the renderer. The context passed into the constructor is just the activity.
setEGLContextClientVersion defines the OpenGL version in use for the default EGLContexFactory and EGLConfigChooser. EGL is another API that controls things like graphics contexts and rendering surfaces, but we will not use it directly.
We then create and set our renderer, saving a reference for the onTouchEventMethod.
setRenderMode RENDERMODE_WHEN_DIRTY only rerenders the scene when requestRender is called, as in the onTouchEvent ACTION_MOVE case.