Vertex Arrays

Hello,

In my current project I render terrain based off height map data, I am using vertex arrays however because all the vertices are in one long array, it “connecting” if you will the right most polys with the left most polys instead of creating individual rows. So the terrain renders properly except that it is trying to render a triangle between the vertices on the oposite side of the map. What am I doing wrong here?

I don’t think I quite understand, can you post the code and possibly a screenshot?

He is filling a vertex-array with a grid, that is:

^ ^ ^
| | |
| | |
| | |
| | | etc etc etc.

Maybe even TRIANGLE_STRIP so the vertex of the top will be turned into a triangle connected to the next triangle starting at the bottom.
If it’s a strip, you can do a couple of things to get rid of this effect:

  1. use glDraw{Elements | Array} more than once, with the correct values
  2. add helper-triangles (quite a bit under the actual terrain) that ‘guide’ the strip to the other side. (might be fastest!)

Hi
If I understand you correctly you want to connect 2 arrays with vertex data, I recommend that you make each row a trianglestrip and use degenerate triangles to connect them. Degenerate triangles are 2 extra vertices that you insert, first one on the same place as the last vertex in the first strip and the second one on the same place as the first vertex in the second strip, hope I made some sence here… :slight_smile: This will cause the triangle that connects the strips to become zero-width and not be visible. Here is a good articel on how to tie 2 trianglestrips together: http://www.gamedev.net/reference/articles/article1871.asp

Good luck //
Gregof

gregof,

Ah, well that makes perfect sense and worked beautifully, thank you so much.