I am trying to use Haskell to procedurally generate a triangulated square terrain of a given width to be given to OpenGL.
The only thing that is actually procedurally generated is the heights, which is not hard at all, I just use a random function to create a [[GLfloat]]
, representing rows of heights.
Then I also have a function, heightsToCoords
that takes the [[GLfloat]]
and returns a [GLfloat]
containing the x, y, and z coords of each vertex.
So if I call heightsToCoords [[0, 1], [1, 0]]
, it will return
[0, 0, 0,
1, 1, 0,
0, 1, 1,
1, 0, 1]
The problem I'm having is getting the data to OpenGL. OpenGL needs each face triangulated (at least with my setup) and all I have is the points, I am not sure how to create the faces.
How could I transform this data from a list of points to a list of faces? Disregard normals and order of vertices.