I am writing an OpenGL program using the GLM OpenGL maths library. I would like to combine vertex positions, normals and texture coordinates into one class like so
class Vertex {
public:
glm::vec4 position;
glm::vec4 normal;
glm::vec2 texcoord;
};
and then use an array of these as my vertex buffer object (VBO). However, when calling glVertexAttribPointer
to map my VBOs I need to give it an offset into this combined Vertex struct for the normal
and texcoord
members.
Had these just been PODs I could have used something like
offsetof(Vertex, position)
but that does not work with glm data types (or at least g++ 4.4.3 bails out).
What is the recommended way to get the offset of the members of Vertex?
(I understand the general reason why I cannot have offsetof
for arbitrary C++ objects, but in this particular case things seem to be well-defined).
at least g++ 4.4.3 bails out
mean? Posting the error would be helpful here. – Paluas