Code example for GLSurfaceView

Methods: setEGLContextClientVersionsetRenderer

0
 */ 
public class GLES20Activity extends Activity {
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mGLSurfaceView = new GLSurfaceView(this);
        if (detectOpenGLES20()) { 
            // Tell the surface view we want to create an OpenGL ES 2.0-compatible 
            // context, and set an OpenGL ES 2.0-compatible renderer. 
            mGLSurfaceView.setEGLContextClientVersion(2);
            mGLSurfaceView.setRenderer(new GLES20TriangleRenderer(this));
        } else { 
            // Set an OpenGL ES 1.x-compatible renderer. In a real application 
            // this renderer might approximate the same output as the 2.0 renderer. 
            mGLSurfaceView.setRenderer(new TriangleRenderer(this));
        } 
        setContentView(mGLSurfaceView);
    } 
 
    private boolean detectOpenGLES20() {