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.