Jump to content
  • Advertisement
Sign in to follow this  

Direct3D 10 - Index Buffer Texture Problem

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

If you intended to correct an error in the post then please contact us.

Recommended Posts



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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!