Code example for GL10

Methods: glClearColor, glClearDepthf, glDepthFunc, glEnable, glHint, glShadeModel

0
import android.opengl.GLU; 
 
public class OpenGLRenderer implements Renderer {
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        // Set the background color to black ( rgba ). 
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
        // Enable Smooth Shading, default not really needed. 
        gl.glShadeModel(GL10.GL_SMOOTH);
        // Depth buffer setup. 
        gl.glClearDepthf(1.0f);
        // Enables depth testing. 
        gl.glEnable(GL10.GL_DEPTH_TEST);
        // The type of depth testing to do. 
        gl.glDepthFunc(GL10.GL_LEQUAL);
        // Really nice perspective calculations. 
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    } 
 
    public void onDrawFrame(GL10 gl) {
        // Clears the screen and depth buffer. 
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);