Creating a set of TRI STRIPS from a grid of vertexes

Hi all.

I’m a bit further along with my current hobby project but now I’m stuck again.

I have a grid of vertexes in a one dimensional array. The data is written X axis first into the array when the grid is created. I am now trying to fill an index array with indexes into the vertex array so that I can output a set of triangle strips. One strip per length on the x axis. E.g. if I had a grid of 5x4, I would end up with 5 strips.

Heres the code I use to generate the strips.

// create the array of arrays of vertex indexes! PHEW what a mouthful.
GLuint lCount = 0;
GLuint lVert = 0;
for(i = 0; i < m_lYSize; i++)
for(lCount = 0; lCount < m_lXSize * 2; lCount += 2)
// set the vertexes
m_pIndex[i][lCount] = lVert;
m_pIndex[i][lCount + 1] = lVert + m_lYSize;



I am coming up with some errors though. E.g. I get triangles coming from the top of one strip to the bottom of the next…get me…

Can anyone out there see a obvious problem with this?


I asume you then call glDrawElements(GL_TRIANGL_STRIP,lCount…, m_pIndex[i] ) for i from 0 to m_lYSize or similar.

I see it ok. Post your glVertexArray and glDrawElements code.