I need to create a grid ready for GL_TRIANGLE_STRIP rendering with One drawcall - so i need to degenerate the triangles.
I am almost there but missing last row/column and can't figure out why.
My grid is just a :
- Position ( self explanatory )
- Size ( the x,y size )
- Resolution ( the spacing between each vertex in x,y )
Here is the method used to create verts/indices and return them:
int iCols = vSize.x / vResolution.x; int iRows = vSize.y / vResolution.y; // Create Vertices for(int y = 0; y <= iRows; y ++) { for(int x = 0; x <= iCols; x ++) { float startu = (float)x / (float)vSize.x; float startv = (float)y / (float)vSize.y; tControlVertex.Color = vColor; tControlVertex.Position = CVector3(x * vResolution.x,y * vResolution.y,0); tControlVertex.TexCoord = CVector2(startu, startv - 1.0 ); vMeshVertices.push_back(tControlVertex); } } // Create Indices rIndices.clear(); for (int r = 0; r < iRows - 1; r++) { rIndices.push_back(r*iCols); for (int c = 0; c < iCols; c++) { rIndices.push_back(r*iCols+c); rIndices.push_back((r+1)*iCols+c); } rIndices.push_back((r + 1) * iCols + (iCols - 1)); } And to visualise that, few examples first.
1) Size 512x512 Resolution 64x64, so it should be made of 8 x 8 quads, but i get 7x7 only

2) Size 512x512 Resolution 128x128, so it should be made of 4 x 4 quads, but i get 3x3 only

3) Size 128x128 Resolution 8x8 so it should be made of 16 x 16 quads but i get 15x15 only

So as you can see, i am missing the Last Row and Last Column somewhere. Where am I going wrong?
