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);
mVbo->bufferAttrib<vec3>(geom::Attrib::POSITION,mPosCoords);
mVbo->bufferAttrib<vec3>(geom::Attrib::NORMAL,mNormals);
mVbo->bufferAttrib<vec2>(geom::Attrib::TEX_COORD_0,mTexCoords);
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?
Thanks!