Code example for GL10

Methods: glClear, glDisable, glFinish, glFogf, glLoadIdentity, glRotatef, glScalef, glTranslatef

0
    /** 
     * Here we do our drawing 
     */ 
    public void onDrawFrame(GL10 gl) {
        //Clear Screen And Depth Buffer 
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();                    //Reset The Current Modelview Matrix
 
        //Check if the light flag has been set to enable/disable lighting 
        if(light) {
            gl.glEnable(GL10.GL_LIGHTING);
        } else { 
            gl.glDisable(GL10.GL_LIGHTING);
        } 
 
        //Set Fog Mode ( NEW ) 
        gl.glFogf(GL10.GL_FOG_MODE, fogMode[fogFilter]);
 
        //Drawing 
        gl.glTranslatef(0.0f, 0.0f, z);            //Move z units into the screen
        gl.glScalef(0.8f, 0.8f, 0.8f);             //Scale the Cube to 80 percent, otherwise it would be too large for the screen
 
        //Rotate around the axis based on the rotation matrix (rotation, x, y, z) 
        gl.glRotatef(xrot, 1.0f, 0.0f, 0.0f);    //X
        gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);    //Y
 
        cube.draw(gl, filter);                    //Draw the Cube
 
        gl.glFinish(); // ensuer the previous gl commands complete
        mTester.decreaseCounter();
 
        //Change rotation factors 
        xrot += xspeed;
        yrot += yspeed;