I want to make a simple 2d terrain with just a few bumps and height changes:
I thought about just using random numbers to describe the height of a certain vertex, but I don't see how I can make one mesh from this. I'm looking for a way to find the vertex and indices buffers for the terrain.
How do I do this?
You could just use GL_POLYGON with a list of all the vertices with the first and last vertice below the view.
if you want to use a triangle mesh you'll have to create a point directly below each height point(out of view) then the pattern(for clockwise ordering) would be:
for (number of height points-1)
//vertices
vertice below height;
height vertice;
next_height vertice;
next height vertice;
vertice below next height;
vertice below height;
then working out the indices depends on how you store the vertices, but there will be a similar pattern in the array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With