Code example for GL10

Methods: glLoadIdentity, glMatrixMode, glViewport, gluPerspective

0
 
    } 
 
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        // Sets the current view port to the new size. 
        gl.glViewport(0, 0, width, height);
        // Select the projection matrix 
        gl.glMatrixMode(GL10.GL_PROJECTION);
        // Reset the projection matrix 
        gl.glLoadIdentity();
        // Calculate the aspect ratio of the window 
        GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
        // Select the modelview matrix 
        gl.glMatrixMode(GL10.GL_MODELVIEW);
        // Reset the modelview matrix 
        gl.glLoadIdentity();
    } 
 
    private void drawShape(GL10 gl) {
        gl.glTranslatef(0, 0, -200);
        gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, nf, GL10.GL_UNSIGNED_SHORT, faces_buffer);