I create an interleaved vertex array in c++:
struct vertex
{
GLfloat position[3];
GLbyte normal[3];
};
std::vector< vertex > vertices;
// fill in vertices...
I copy the array to a gl buffer:
GLuint vertsBuffer;
glBindBuffer (GL_ARRAY_BUFFER, vertsBuffer);
glBufferData (GL_ARRAY_BUFFER, vertices.size () * sizeof (vertex), vertices.data (), GL_STATIC_DRAW);
Is it possible to use glNormalPointer with interleaved data like this, for example?
glBindBuffer (GL_ARRAY_BUFFER, vertsBuffer);
glEnableClientState (GL_NORMAL_ARRAY);
glNormalPointer (GL_BYTE, sizeof (vertex), (GLvoid*) offsetof (vertex, normal));
Or do I have to use glVertexAttribPointer instead?
That should work fine if you use the legacy
gl_NormalGLSL built-in (Section 7.3, page 49).glVertexAttribPointer()is more forward-compatible though.