Code example for GL10

Methods: glColorPointer, glDisable, glDisableClientState, glDrawArrays, glEnableClientState, glLineWidth, glPopMatrix, glPushMatrix, glRotatef, glTranslatef

0
            initTextures(gl);
        } 
    } 
 
    public void draw(GL10 gl) {
        gl.glPushMatrix();
 
 
        // Translations 
        gl.glTranslatef(mCentX, mCentY, mCentZ);
 
        // Rotations 
        gl.glRotatef(mRotX, 1.0f, 0.0f, 0.0f);
        gl.glRotatef(mRotY, 0.0f, 1.0f, 0.0f);
        gl.glRotatef(mRotZ, 0.0f, 0.0f, 1.0f);
 
        /* ------------ 
            DRAW MODEL 
           ------------ */ 
        if(mEnableModel) {
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
 
            // Select between a solid color, one texture, or two textures 
            switch(mTexSet) {
                case 0: 
                    /* ----------------------------------- 
                        Draw model with solid color. 
                        Disabled when setTexture() is called. 
                        Run setModelColor( new float[]{r,g,b,a} ) to set color. 
                       ----------------------------------- */ 
 
                    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
                    gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer);
                    break; 
                case 1: 
                    /* ----------------------------------- 
                        Draw model with a single texture 
                        Enabled when calling setTexture( int mTexture ) 
                            First run: 
                            gl.glGenTextures(1, mTexture, 0); 
                            gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture); 
                            GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mTexBitmap, 0); 
                        Run setTextureBuffer() 
                       ----------------------------------- */ 
 
                    // Texture 1 
                    gl.glClientActiveTexture(GL10.GL_TEXTURE0);
                    gl.glActiveTexture(GL10.GL_TEXTURE0);
                    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
                    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture[0]);
                    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
                    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexCoordBuffer1);
                    gl.glEnable(GL10.GL_TEXTURE_2D);
                    break; 
                case 2: 
                    /* ----------------------------------- 
                        Draw model with a two textures 
                        Enabled when calling setTexture( int, int ) 
                            First run: 
                            gl.glGenTextures(1, mTexture, 0); 
                            gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture); 
                            GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, mTexBitmap, 0); 
                        Run setTextureBuffer() 
                       ----------------------------------- */ 
 
                    // Texture 1 
                    gl.glClientActiveTexture(GL10.GL_TEXTURE0);
                    gl.glActiveTexture(GL10.GL_TEXTURE0);
                    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
                    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture[0]);
                    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
                    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexCoordBuffer1);
                    gl.glEnable(GL10.GL_TEXTURE_2D);
 
                    // Texture 2 
                    gl.glClientActiveTexture(GL10.GL_TEXTURE1);
                    gl.glActiveTexture(GL10.GL_TEXTURE1);
                    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
                    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture[1]);
                    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_DECAL);
                    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexCoordBuffer2);
                    gl.glEnable(GL10.GL_TEXTURE_2D);
 
                    // Revert to avoid conflicts with other draws 
                    gl.glActiveTexture(GL10.GL_TEXTURE0);
                    break; 
            } 
 
            gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
            gl.glDrawArrays(GL10.GL_TRIANGLES, 0, mNumVertices);
 
 
            gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
            gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
            gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
            gl.glDisable(GL10.GL_TEXTURE_2D);
        } 
 
 
        /* --------------- 
            DRAW OUTLINES 
 
            Requires the following subroutines be called: 
                enableOutlines() 
                setOutlineIndicies() 
           --------------- */ 
        if(mEnableOutline) {
            gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
 
            gl.glColorPointer(4, GL10.GL_FLOAT, 0, mOutlineColorBuffer);
            gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mOutlineBuffer);
            gl.glLineWidth(2f);
            gl.glDrawArrays(GL10.GL_LINES, 0, mNumOutlineVertices);
 
            gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
            gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        } 
 
        gl.glPopMatrix();
    } 
 
 
    /* ------- 
        MODEL