Reputation: 302
I began learning OpenGL, but I don't understand what the last parameter in glVertexAttribPointer
means.
Upvotes: 0
Views: 509
Reputation: 4641
It's a pointer offset into the array you're using. However, it's a byte count that you have to cast to a pointer, which isn't exactly intuitive.
If you're using interleaved attributes, it's the number of bytes from the beginning to the first instance of that attribute.
Example:
VVVNNNTTVVVNNTT
Where Vertex position data, N is the normal vector, and T is the texture corodinate.
The offset for V is 0
(it's at the beginning)
The offset for N is (GLvoid*) (3*sizeof(vertex data type))
The offset for T is (GLvoid*) (3*sizeof(vertex data type) + 3*sizeof(normal data type) )
Furthermore, if you have successive attributes, it would be the starting point for each attribute as well.
Example:
VVVV...VVVNNN...NNNTT...TT
The offset for V is 0
(it's at the beginning)
The offset for N is (GLvoid*) (3*sizeof(vertex data type)*number_of_vertices)
The offset for T is (GLvoid*) (3*sizeof(vertex data type)*number_of_vertices + 3*sizeof(normal data type)*number_of_normals)
Upvotes: 4