Texture Element Array support?

Started by neoQuistis, August 05, 2008, 20:59:06

Previous topic - Next topic

neoQuistis

Hi!

I'm currently working on a COLLADA loader for lwjgl that has VBO support.  Everything was moving swimmingly until I try to index my UV coordinates.  It seems that it reads in the uvs, but the mapping is ignored.  Does anyone have any suggestions?

Here is what it looks like :

//create an integer array to store all vertexbuffer handles
        //each mesh has its own vertex buffer
        vbHandles = new int[meshCount];
        nbHandles = new int[meshCount];
        uvbHandles = new int[meshCount];
       
        //there are as many index buffers as there are polygons in a mesh
        //bind vertexData to handles
        ibHandles = new int[meshCount][];
        normalBufferHandles = new int[meshCount][];       
        textureBufferHandles = new int[meshCount][];
       
        for(int i = 0; i < meshCount; i++){           
            //meshes.get(i).textureImage = new GLImage("/textures/flower.png");
            //meshes.get(i).textureHandle = GLApp.makeTexture(meshes.get(i).textureImage);
            meshes.get(i).initEffects();
            //Give the VertexBuffers of each mesh a handle
            vbHandles = createVBOID();
            nbHandles = createVBOID();
            uvbHandles = createVBOID();
           
            bufferData(vbHandles, meshes.get(i).vertexBuffer);
            bufferData(nbHandles, meshes.get(i).normalBuffer);
            bufferData(uvbHandles, meshes.get(i).textureBuffer);
           
            //now for the index buffer...
            ibHandles = new int[meshes.get(i).meshPolygons.size()];
            //and the normal index buffer
            normalBufferHandles = new int[meshes.get(i).meshPolygons.size()];
            //and the texture index buffer
            textureBufferHandles = new int[meshes.get(i).meshPolygons.size()];
           
            for(int j = 0; j < meshes.get(i).meshPolygons.size(); j++){
                ibHandles[j] = createVBOID();
                bufferElementData(ibHandles[j],
                        meshes.get(i).meshPolygons.get(j).indexBuffer);
                normalBufferHandles[j] = createVBOID();
                bufferElementData(normalBufferHandles[j],
                        meshes.get(i).meshPolygons.get(j).normalBuffer);
                textureBufferHandles[j] = createVBOID();
                bufferElementData(textureBufferHandles[j],
                        meshes.get(i).meshPolygons.get(j).textureBuffer);
               
            }


Here is the code for when I draw.  Note that the vertex and index VBO's work exactly like they should.  It's just the UV's that are screwy.


for(int i = 0; i <  meshCount; i++){
           
            for(int j = 0; j < meshes.get(i).meshPolygons.size(); j++){
                //Bind teh normals

                GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
                ARBVertexBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, nbHandles);
                ARBVertexBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
                        normalBufferHandles[j]);
                GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0);
               
                //Bind teh textures
                GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
                ARBVertexBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, uvbHandles);
                ARBVertexBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
                        textureBufferHandles[j]);
                GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
               
                //Bind teh vertex indices
                GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
                ARBVertexBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, vbHandles);
                ARBVertexBufferObject.glBindBufferARB(
                        ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
                        ibHandles[j]);
                GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);



Any suggestions would be greatly appreciated.  Thank you!

theprism

Check out the JMonkeyEngine source, it has a collada importer