How to make a 2D landscape with opengl?

I want to make a simple 2nd relief with a few changes and height changes:

terrain with le car

I was thinking about just using random numbers to describe the height of a certain vertex, but I don’t see how I can make one grid from this. I am looking for a way to find vertex and index buffers for terrain.
How to do it?

+6
source share
1 answer

You can simply use GL_POLYGON with a list of all the vertices with the first and last vertices under the view.

if you want to use a triangular grid, you will need to create a point directly below each height point (outside the field of view), then the template (for clockwise) will look like this:

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 the calculation of the indices depends on how you store the vertices, but there will be a similar pattern in the array.

+1
source

Source: https://habr.com/ru/post/914761/


All Articles