• Create Account

Direct3D 10 - Index Buffer Texture Problem

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

#1mushroomrealm  Members

133
Like
0Likes
Like

Posted 19 April 2014 - 11:13 PM

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:

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

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.