1. Download our Official Android App: Forums for Android!

Apps Textures are not loaded on the objects who have GLUtils.texImage2D Method calls repeatedly.

Discussion in 'Android Development' started by devang024, Jul 22, 2011.

  1. devang024

    devang024 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Jul 22, 2011

    Jul 22, 2011
    1
    0
    5
    I am new to opengles and android,i am trying to make simple 2D game..IN which different textures will be on the object for animation.

    The images are loaded from "raw" folder and placed in textures[] AND bitmap[] array.

    IT RUNS properly on EMULATOR but gives me black squares at place of objects who has changing textures.

    so,MY QUESTION is what is the fault in this code for the phone(samsung galaxy).
    WHAT is the optimum method for doing animation by changing textures.??

    JUST GIVE me guidence about that...

    Following is the CODE for drawing different textures:

    public void draw(GL10 gl,int index) {
    if(index==0){
    gl.glBindTexture(GL10.GL_TEXTURE_2D,this.textures[0]);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap[0], 0);
    }
    else if(index==1){
    gl.glBindTexture(GL10.GL_TEXTURE_2D, this.textures[1]);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0,bitmap[1], 0);
    }
    else if(index==2){
    gl.glBindTexture(GL10.GL_TEXTURE_2D,this.textures[2]);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0,bitmap[2], 0);
    }
    gl.glFrontFace(GL10.GL_CCW);

    gl.glVertexPointer(3, GL10.GL_FLOAT, 0,vertexBuffer);
    gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,textureBuffer);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length/3);


    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    }
     

    Advertisement

Share This Page

Loading...