Why use multiple gl::VboMesh::layouts

Hi all,

Not so much a debugging question as a ‘why does this work this way’ question.

I’m getting some practise in by manually constructing geometry using a VboMesh ( the idea is to eventually create a cornell box).

I was stuck for a while before piecing together a solution from various forum posts, so now more of a question of ‘why’ it works that way…

// why the vector of layouts?
std::vector<gl::VboMesh::Layout> layout = {
    gl::VboMesh::Layout().usage( GL_STATIC_DRAW ).attrib( geom::Attrib::POSITION, 3 ),
    gl::VboMesh::Layout().usage( GL_STATIC_DRAW ).attrib( geom::Attrib::NORMAL, 3),
    gl::VboMesh::Layout().usage( GL_STATIC_DRAW ).attrib( geom::Attrib::TEX_COORD_0, 2 )


gl::VboRef ibo = gl::Vbo::create ( GL_ELEMENT_ARRAY_BUFFER, mIndices, GL_STATIC_DRAW );

mVbo = gl::VboMesh::create( (uint32_t)mPosCoords.size(), GL_TRIANGLES, {layout}, (uint32_t)mIndices.size(), GL_UNSIGNED_INT, ibo);


As the comment at the top states… why do I need to pass a vector of VboMesh::Layouts to avoid getting a missing attribs error that was arising when I was chaining the attribs to a single Layout?


Hey there,

Not sure if you moved past this as it was a while ago, but is it a question of terminology used? Each element in the layout vector represents how an attrib is laid out in memory. Maybe the confusing part is just that the ‘layout’ consists of VboMesh:::Layout objects?

Also not sure what it is you tried that was causing the gl error message.