View Full Version : Does Open GL support vertex group referencing?

02-06-2012, 11:50 AM

Does Open GL support vertex group referencing like Direct X does? This is to say if a vertex array group of position coordinates, texture coordinates and normal coordinates is stored in a "struct" array(or equivalent) could Open GL support a an indice list used to locate a vertex group.


struct VertexType
{D3DXVECTOR3 position;
D3DXVECTOR2 texture;
D3DXVECTOR3 normal;

//Vertex group array
VertexType * vertices;

Ilian Dinev
02-06-2012, 12:06 PM
Yes, it's called "interleaved attribute arrays", and you don't need special functions to use them. Just reuse the same VBO (same glBindBuffer call) and supply different offset per attribute, while specifying stride.

02-07-2012, 04:14 AM
The simplest way to do what you have described is to use glInterleavedArrays.
This is now considered legacy/depreciated in OpenGL but if you are using compatibility profile then it's perfectly fine.
The great thing about this is its simplity.
GL_V2F, GL_V3F, GL_C4UB_V2F, GL_C4UB_V3F, GL_C3F_V3F, GL_N3F_V3F, GL_C4F_N3F_V3F, GL_T2F_V3F, GL_T4F_V4F, GL_T2F_C4UB_V3F, GL_T2F_C3F_V3F, GL_T2F_N3F_V3F, GL_T2F_C4F_N3F_V3F, and GL_T4F_C4F_N3F_V4F are accepted as data formats - which gives quite a bit of flexibity.

For your needs GL_T2F_N3F_V3F is the one to go for, so a struct like the following would be required:
float[2] Texture coords;
float[3] Normal;
float[3] Vertex;