title: How to generate a plane using GL_TRIANGLES?
body: <p>Is there an algorithm that could be used to generate a plane using the GL_TRIANGLES primitive type?</p>
  
  <p>Here's my current function:</p>
  
  <pre><code>Mesh* Mesh::CreateMeshPlane(vec2 bottomleft, ivec2 numvertices, vec2 worldsize){
  
  int numVerts = numvertices.x * numvertices.y;
  
  float xStep = worldsize.x / (numvertices.x - 1);
  float yStep = worldsize.y / (numvertices.y - 1);
  
  VertexFormat* verts = new VertexFormat[numVerts];
  
  for (int y = 0; y &lt; numvertices.y; y++)
  {
      for (int x = 0; x &lt; numvertices.x; x++)
      {           
          verts[x + (y * numvertices.x)].pos.x = bottomleft.x + (xStep * x);
          verts[x + (y * numvertices.x)].pos.y = bottomleft.y + (yStep * y);
          verts[x + (y * numvertices.x)].pos.z = 0;
      }
  }
  
  Mesh* pMesh = new Mesh();
  pMesh-&gt;Init(verts, numVerts, indices, 6, GL_STATIC_DRAW);
  
  glPointSize(10.0f);
  pMesh-&gt;m_PrimitiveType = GL_POINTS;
  
  delete[] verts;
  
  return pMesh;}
  </code></pre>
  
  <p>I'm just unsure how to implement indices into the for loop to be able to know which points to draw.</p>
  
  <p>What I think I need to know:</p>
  
  <p>Each square will be made up of 2 triangles, each square requiring 6 indices</p>
  
  <p>Currently I'm drawing from the bottom left</p>
  
  <p>I need to know how many squares I'll have from the numbers passed in</p>