# Direct3D 10 - Index Buffer Texture Problem

This topic is 1738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

Having trouble with the index buffer not drawing the texture of the second triangle of a quad properly. The problem only occurs when the quad is set up using four vertices instead of six even though the index doesn't reference the last two vertices. The code below works fine but when I comment out the last two vertices, and change the array size and buffer description byte width to 4 the texture of the bottom triangle mirros the top triangle.

Here's the image I'm trying to draw:

[attachment=20957:ident.bmp]

And here's what draws if I try to remove the extra vertices:

[attachment=20958:ident2.bmp]

This is the code I'm using to set up the vertex and index buffers.

Vertex vertices[6];
unsigned long indices[6] = {0, 2, 1, 1, 3, 0};

//bottom left
vertices[0].position = D3DXVECTOR3(this->x, this->y, 0.0f);
vertices[0].texture = D3DXVECTOR2(0.0f, 1.0f);

//top right
vertices[1].position = D3DXVECTOR3(this->x + this->w, this->y + this->h, 0.0f);
vertices[1].texture = D3DXVECTOR2(1.0f, 0.0f);

//top left
vertices[2].position = D3DXVECTOR3(this->x, this->y + this->h, 0.0f);
vertices[2].texture = D3DXVECTOR2(0.0f, 0.0f);

//bottom right
vertices[3].position = D3DXVECTOR3(this->x + this->w, this->y, 0.0f);
vertices[3].texture = D3DXVECTOR2(1.0f, 1.0f);

//bottom left
vertices[4].position = D3DXVECTOR3(this->x, this->y, 0.0f);
vertices[4].texture = D3DXVECTOR2(0.0f, 1.0f);

//top right
vertices[5].position = D3DXVECTOR3(this->x + this->w, this->y + this->h, 0.0f);
vertices[5].texture = D3DXVECTOR2(1.0f, 0.0f);


What is it I'm missing that's causing this problem? Any help would be appreciated.

Thank you.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 9
• 40
• ### Forum Statistics

• Total Topics
634130
• Total Posts
3015704
×