# Indexed UV mapping problem [closed]

I am trying to map UV coordinates to indexed vertices with this code. I am using a vertex buffer, texture buffer, and index buffer (note the vertex and texture buffers are indexed in the same order)

glBindTexture(GL_TEXTURE_2D, staticTexture);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glBindBuffer(GL_ARRAY_BUFFER, textureBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, 0);

glBindBuffer(GL_ARRAY_BUFFER, staticVertexBuffer);
glVertexPointer(3, GL_FLOAT, 0, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindTexture(GL_TEXTURE_2D, 0);


but when I run the code I get this (compared to the actual image that is supposed to appear on each face)

My code for setting the indices and uv coords (one face of the cube)

uv.push_back(Vector2(0, 1));
uv.push_back(Vector2(1, 1));
uv.push_back(Vector2(1, 0));
uv.push_back(Vector2(0, 0));
indices.push_back(vertexIndexFromCoordinates(x, y, z));
indices.push_back(vertexIndexFromCoordinates(x, y, z + 1));
indices.push_back(vertexIndexFromCoordinates(x, y + 1, z + 1));
indices.push_back(vertexIndexFromCoordinates(x, y + 1, z));


The only thing I can think of is that the UV's are being mapped by the vertices not the indices.

## closed as off-topic by Josh♦Feb 14 '14 at 17:25

• This question does not appear to be about game development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Shouldn't this be on Stack Overflow? – The Guy with The Hat Feb 14 '14 at 13:21
• This question appears to be off-topic because it is about debugging your code for you. – Josh Feb 14 '14 at 17:25