I'm doing a exercise form the Frank Luna book. It ask to draw a LineStrip that looks like the red line in the picture. I'm using


I'm getting the line that is yellow,blue and black and it is looping. How can I make it look like the red line?

enter image description here

My vertex that has the points:

 Vertex vertices[] =
    { XMFLOAT3(-5.0f, 2.0f, 0.0f) },
    { XMFLOAT3(-4.0f, -2.0f, 0.0f)    },
    { XMFLOAT3(-3.0f, 2.0f,0.0f)      },
    { XMFLOAT3(-2.0f, -2.0f, 0.0f)  },
    { XMFLOAT3(-1.0f, 2.0f, 0.0f) },
    { XMFLOAT3(0.0f, -2.0f, 0.0f)  }

 My indices code is:

UINT indices[] = {


Looks like the index count you pass to a draw call could be wrong, that would easily cause buffer overflow, which could lead to "looping".

Also, if your vertex data consists only of a position vector, how come the vertices are colored and the position is wrong?

Either way, there are serious memory usage issues with your code that have nothing to do with the API or the book. I can only suggest you to read more carefully.


Seems I forgot to update DrawIndexed to the right number of indices.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.