Code sample: Loading a 3-D perspective projection matrix

You can use the GLUtils class to load a 3-D perspective projection matrix.

public void sizeChanged(GL10 gl, int width, int height)
{
    // Update our viewport to reflect the new size
    gl.glViewport(0, 0, width, height);

    // Setup a perspective projection
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    net.rim.device.api.opengles.GLUtils.gluPerspective
        (gl, 45.0f, (float)width/(float)height, 0.15f, 100.0f);
}

Was this information helpful? Send us your comments.