On the GL side, I'd use drawElements
, which needs a list of points and a list of indices as inputs. So the question becomes how to generate a list of indices into your list of points.
Keeping in mind the original XZ grid, the idea is to draw two triangles for each cell of the grid. So we need 6 indices per grid cell. In Haskell, we can write something like:
concat [[x + width * (y+1), 1 + x + width*y, x + width * y,
x + width* (y+1), 1 + x + width * (y+1), 1 + x + width*y]
| y <- [0..height-1], x <- [0..width-1]]