I can't seem to get texture mapping to work properly with vertex arrays.
Example:
I have a sphere with 114 vertices, 224 faces (triangles), and 166 texture coordinates.

I know that the vertex buffer is arranged like {x,y,z,x,y,z,x,y,z...}
and the faces would be
{1st corner, 2nd corner, 3rd corner, 1st corner, 2nd corner, 3rd corner...}
how do I arrange the texture coordinates?
I know it would be like {u,v,u,v,u,v,u,v...}
but do I need a group (u,v) for each corner of the triangle. This is what I am doing now and it does not work.

So just to clarify by vertex buffer has 342 entries, my faces buffer has 672 entries, and my texture buffer has 1344 entries.

glVertexPointer(2,GL_FLOAT,0,verticies);
glTexCoordPointer(2,GL_FLOAT,0,texcoords);
glBegin(GL_QUADS);
while(x<4){
glArrayElement(x);
x++;
}
glEnd();It would nice to have all this in a list then just call the list(note you cannot put the glEnableClientState function in a list though Hope that helps

07-22-2004, 04:22 PM

So I guess that there should be one set of texture coordinates for each vertex in a polygon? Is this right?

Because I tried this and it didn't work for me. Maybe someone has had similar problems.

I don't see any difference between your example and my code. thanks for the example but I still haven't found the solution.

grimoire

07-22-2004, 07:19 PM

post your code so we can see what is wrong. I tested mine and it worked fine.

P.S. If you want to get fancy you can have a stride and have one big array.

I had such problem. But I've solved it. You should write every vertex with its texture coords(UV). So you will 166 vertices with 166 texcoords.
Ex.
for i := 0 to FaceCount - 1 do
for j := 0 to 2 do begin
WriteToSomeBuffer ( Vertex[Face[i][j]].x, y, z);
WriteToSomeBuffer ( TexVert[TexFace[i][j]].u, v);
end;
Then delete all repeating vertices from the buffer and modificate Face[i][j] to the rest vertices.
PS
Sorry for my poor English.

07-23-2004, 02:21 PM

Thanks, that would definitely work. I guess the problem comes into play whenever there are less vertices than texture coords.