Code example for GL10

Methods: glActiveTexture, glClear, glDrawElements, glEnable, glEnableClientState, glFrontFace, glLoadIdentity, glMatrixMode, glTexCoordPointer, glTexEnvx

0
    /** 
     * Draw the moving checker-board. 
     */ 
    @Override 
    public void drawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
 
        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
 
        GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
 
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
 
        // apply the checker-board to the shape 
        gl.glActiveTexture(GL10.GL_TEXTURE0);
 
        gl.glTexEnvx(
            GL10.GL_TEXTURE_ENV,
            GL10.GL_TEXTURE_ENV_MODE,
            GL10.GL_MODULATE);
        gl.glTexParameterx(
            GL10.GL_TEXTURE_2D,
            GL10.GL_TEXTURE_WRAP_S,
            GL10.GL_REPEAT);
        gl.glTexParameterx(
            GL10.GL_TEXTURE_2D,
            GL10.GL_TEXTURE_WRAP_T,
            GL10.GL_REPEAT);
 
        // animation 
        int t = (int) (SystemClock.uptimeMillis() % (10 * 1000L));
        gl.glTranslatef(6.0f - (0.0013f * t), 0, 0);
 
        // draw 
        gl.glFrontFace(GL10.GL_CCW);
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuf);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuf);
        gl.glDrawElements(
            GL10.GL_TRIANGLE_STRIP,
            5, 
            GL10.GL_UNSIGNED_SHORT, indexBuf);
    }