# 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.

• 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. – user1430 Feb 14 '14 at 17:25