I have an application that draws vertex points interleved: (X1,Y1,Z1,X2,Y2,Z2…Xn,Yn,Zn) and it works. For large amounts of data, the setting of these points becomes VERY slow due to the interleve. I would like to set the vertex data without interleving (X1,X2…Xn,Y1,Y2…Yn,Z1,Z2…Zn) and still use glDrawArray and potentially shift to VBOs in near future. Is this possible using glVertexPoint? If not, is there a data structure in OpenGL that will allow this type of memory arrangement or am I on the wrong track entirely?
Just to be sure X1,Y1,Z1 are the x,y,z-coordinates of your first position? That is not what is usually called interleaved vertex data, that term is usually used to describe the data layout if you have multiple vertex attributes (e.g. position, normal, tex coord). In that case you can store all the positions next to each other (Px1,Py1,Pz1, Px2,Py2,Pz2, …) in memory and in a different location all the normals (Nx1,Ny1,Nz1, Nx2,Ny2,Nz2, …) and the same for the tex coords (Tu1,Tv1, Tu2,Tv2, …) that means the data for a single vertex is found in three different locations in memory. Alternatively you can interleave the attributes and store all data that makes up a single vertex next to each other (Px1,Py1,Pz1,Nx1,Ny1,Nz1,Tu1,Tv1, Px2,Py2,Pz2,Nx2,Ny2,Nz2,Tu2,Tv2, …) now all the data that makes up each vertex is packed together, but to go from vertex to vertex you make larger jumps through memory.
Note that in both cases the values that make up a single attribute of a vertex are still next to each other. You seem to want to store the values that make up a single attribute to be stored, but that’s not how the vertex specification APIs are specified and also not how the hardware operates so OpenGL would have to re-arrange it for you, which would be slow. Your performance problem probably comes from using client side data and transferring it to the GPU on each draw, use vertex data stored in buffers, aka VBOs, to only transfer data to the GPU once and keep it there.
Yes, you’re actually not interleaving at all to begin with, which is probably one reason why you’re slow, as interleaving is actually faster with hardware T&L, as the GPU can usually fetch all attributes for a single vertex in one read, it’s more cache-friendly, and if your vertex size is smaller that the GPU’s cache line size it can even pre-fetch following vertices.
You may be influenced by an ancient Intel web page which made the case for non-interleaved vertex data being faster. Yes, it could be in the software T&L days, and Intel only made software T&L parts at that time, so of course they’re going to push something that’s better for their hardware. That’s out-dated information; those days are over.
The way you’re proposing would be much slower as now the GPU can’t read your vertex data sequentially at all.
This was not an attempt to speed up drawing, but the actual loading of dynamic data into my structures. Loading one vertex at a time was taking too much time. I will interleave the color vertex with this to help with drawing, so thanks for the extra info. Still learning OpenGL so every little bit helps.