Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I was doing a VBO and able to load all the data of OBJ file but now I have problem adding texture to it. what i did is that I use the slick library to get the texture file and bind it to the VBO texture but the result is not what I was looking for.

BTW i am using sculptris for the texture and OBJ file

This picture is the result of my VBO: Incorrect result

This picture is what should be the result: Original model

Here is my code for adding texture:

public static void initializeVBOHasTexture(){
    m = null;
    try {
        m = ObjectLoader.loadModelHasTexture("res/bunnytexture.obj");
    } catch (IOException e) {
        Cube3D.closeWindow();
        e.printStackTrace();
    }

    int[] VBO = ObjectLoader.createVBOHasTexture(vboVertexHandle, vboNormalHandle,vboTextureHandle, m);
    vboVertexHandle = VBO[0];
    vboTextureHandle = VBO[1];
    vboNormalHandle = VBO[2];
    //texture
    //glDisable(GL_DEPTH_TEST);
    //glDisable(GL_BLEND);
    //glDisable(GL_SCISSOR_TEST);
    //glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    //glTexParameteri(GL_TEXTURE_2D,GL11.GL_TEXTURE_WRAP_S,GL_CLAMP);
    //glTexParameteri(GL_TEXTURE_2D,GL11.GL_TEXTURE_WRAP_T,GL_CLAMP);
    Texture texture = ObjectLoader.loadTexture("res/New Folder/rabbit.png");
    glEnableClientState(GL_VERTEX_ARRAY);
    glBindBuffer(GL_ARRAY_BUFFER,vboVertexHandle);
    glVertexPointer(3,GL_FLOAT,0,0);

    glBindBuffer(GL_ARRAY_BUFFER,vboTextureHandle);
    GL11.glTexCoordPointer(2, GL_FLOAT,0, 0);
    glEnable(GL11.GL_TEXTURE_2D);
    texture.bind();
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glEnableClientState(GL_NORMAL_ARRAY);
    glBindBuffer(GL_ARRAY_BUFFER,vboNormalHandle);
    glNormalPointer(GL_FLOAT,0,0);  
}

public void drawVertexTextureNormalArrays(){
    if(render){
        glTranslatef(x,y,z);
        glEnable(GL11.GL_TEXTURE_2D);
        GL11.glColor3f(1, 1,1);
        glEnable(GL_LIGHTING);
        glDrawArrays(GL_TRIANGLES,0,m.faces.size()*3);
    }
}

Am doing the right way of amplifying the texture or there is another way of doing it the right way?

Here is the texMap picture: Texture image

share|improve this question
    
Here is the texMap picture img818.imageshack.us/img818/9319/hi0.png –  rodolfo navalon Jun 17 '13 at 20:54
    
You are passing vboTextureHandle as the third parameter to createVBOHasTexture(), but reading it from the second slot from the returned array. Is this intentional? –  msell Jun 18 '13 at 4:54
    
Be sure to duplicate the vertices that share the same texture coordinates when you are parsing the OBJ file. –  c0d3rguy Jun 18 '13 at 14:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.