Take the 2-minute tour ×

I'm looking for the cheapest way to draw a grid of 3D points in OpenGL (e.g. 256x256x256 --> 16.000.000 points) . Currently I store my vertices inside a VBO and pass it to my vertex shader. Is there a better way of storing all of those values inside a giant 1D array, since they should lie on a regular grid?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I think the best way is to store all values in a vector and use VBO to render them.

The advantage of using vectors is that they have enough space to store as many floats as you want, and it is very easy to manipulate individual points whenever you want. Memory is also not a problem when using vectors.

VBO was also a good choice, since the data is stored on the graphics card and not on your memory card, giving you more performance.

share|improve this answer
Ok, I guess I'll use a vector then and generate a VBO from the data inside. I guess the problem is the generation of that data...is there a better way than using 3 or 4 for-loops to get that data inside the vector? –  Schnigges Jan 9 '13 at 12:41
what do you mean by using 3 or 4 for-loops? Take a look on this post so you have an idea how to store all data in 1D array and then use VBO to render them: stackoverflow.com/questions/14234361/… –  Tiago Salzmann Jan 9 '13 at 12:44
To generate the x-, y-, z- and h- components of all the vertices on the grid, I currently use 4 loops. Yeah, i saw that post earlier and that's exactly what I'll do. The question is whether there might be a better way to generate the values in the vector. –  Schnigges Jan 9 '13 at 12:47
There might be other ways, but the cheapest is this one I showed you (the other post). –  Tiago Salzmann Jan 9 '13 at 14:03
add comment

Your Answer


