Code example for GLSurfaceView

Methods: setEGLContextClientVersionsetRenderer

public class GLES20Activity extends Activity {
    protected void onCreate(Bundle 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.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));
    private boolean detectOpenGLES20() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE