PDA

View Full Version : Drawing a dynamic 3D mesh: Best way?



tomb18
01-08-2017, 05:45 PM
I need to draw a 3d mesh and there will be up to 200,000 triangles drawn. These triangles have vertices of x,y,z but x and z are always the same. Only the Y changes. This is essentially a height map.
I am looking at ways to render this and so far I have tried the following in terms of complexity:

glDrawArray - very simple. I just put the data in an array. One opengl call for all 200,000 triangles.

glDrawElements using triangles - also fairly simple, the indices are just 0 to 200,000. One opengl call for all 200,000 triangles.

glDrawElements using triangle strips - the complication here is generating the indices. How does one determine where they change?

The Y vertices will be changing every 100ms or so - for this I use buffersubdata.
So what would be the advantages or disadvantages of each? This is all that will be rendered. 200,000 triangles and that's it.
Thanks

Silence
01-08-2017, 10:54 PM
Triangle strip indices are implicit. The order of each vertices in the array makes the strip. See the wiki page (https://en.wikipedia.org/wiki/Triangle_strip) for example.

For the rest, this will depend on what you render. If you only render portions of your big mesh, then indices will help. Then use glDrawElements. If you plan to render all of your mesh each time (which you should not), then use glDrawArrays without using any index array.

tomb18
01-09-2017, 12:11 AM
Hmm, when I tried a simple two row triangle strip I need to pick a vertex from the previous strip to continue rendering...it went something like
1,2,3,4,5,6,7,8,9,10,11,6,13,14,15...
As to rendering all of the mesh each time that is absolutely necessary in my app. I am plotting spectral data from a software defined radio in real time. So all of the heights, which correspond to signals, on the map will change.
Actually, only the first row will change. All the rest of the rows in the mesh will just be shifted in the -z direction by one increment of z (there will be about 100 z values which correspond to time).
This is a good point I guess.
Would it not be possible to just shift the whole spectrum in the z axis and then just add the new data? in front of it? I guess the issue would be that the array keeps getting bigger in that case.