Hello all,
I’m trying to find the correct syntax (or a better method) for passing an array/vector that is a member of a struct I’m using to create a VboMesh. I’m mapping the Here’s the use case:
Simple object:
struct Line {
ci::vec2 mPos;
ci::ColorA mColor;
float mWidth;
}
Create a buffer layout to map data to attributes:
geom::BufferLayout LineBufferLayout;
LineBufferLayout.append(geom::Attrib::POSITION, 2, sizeof(Line), offsetof(Line, mPos));
LineBufferLayout.append(geom::Attrib::COLOR, 4, sizeof(Line), offsetof(Line, mColor));
LineBufferLayout.append(geom::Attrib::CUSTOM_0, 1, sizeof(Line), offsetof(Line, mWidth));
Create VboMesh with that Layout (nevermind the GL_POINTS designation), and declare the custom attribute when creating the batch:
auto vboMesh = gl::VboMesh::create(mLineList.size(), GL_POINTS, { { LineBufferLayout, mVbo } });
mLineBatch = gl::Batch::create(vboMesh, mSharedShader, { { geom::CUSTOM_0, "iLineWidth" } });
This all works great for previous examples of passing in a single vertex for the base object. However, I need Line
to contain a vector of all of the vertices that will be on that line to pass to the VBO so I can access them in the geometry shader:
struct Line {
std::vector<ci::vec2> mVerts;
ci::ColorA mColor;
float mWidth;
}
Does BufferLayout support passing an array of values as an attribute (geom::POSITION or geom::CUSTOM)? I can’t seem to find the right syntax. Do I have to use the lower level mVbo->bufferSubData() methods to do a more custom mapping?