Code example for GL10

Methods: glLoadIdentity, glMatrixMode, glViewport, gluPerspective

0
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, rectangleBuffer);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
    } 
 
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        gl.glViewport(0, 0, width, height); // Reset The Current Viewport
 
        gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix
        gl.glLoadIdentity(); // Reset The Projection Matrix
         
        //gl.glOrthof(-2.0f, 2.0f, -2.0f, 2.0f, -1.0f, 1.0f); 
 
        // Calculate The Aspect Ratio Of The Window 
        GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
 
        gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix
        gl.glLoadIdentity(); // Reset The Modelview Matrix
    } 
}