std::vector<float> vertices ={
-1.0f, 1.0f, 0.0f, // pos0
1.0f, 1.0f, 0.0f, // pos1
-1.0f, -1.0f, 0.0f, // pos2
1.0f, -1.0f, 0.0f, // pos3
0.0f, 0.0f, -1.0f, // norm0
0.0f, 0.0f, -1.0f, // norm1
0.0f, 0.0f, -1.0f, // norm2
0.0f, 0.0f, -1.0f, // norm3
};
const size_t componentSize = sizeof(decltype(vertices)::value_type); // 4
const size_t stride = 3 * componentSize; // 12
const size_t count = 4; // ?8
AccessorDesc descs[2] =
{
{ TYPE_VEC3, COMPONENT_FLOAT, false, { -1.0f, -1.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, 0 },
{ TYPE_VEC3, COMPONENT_FLOAT, false, { 0.0f, 0.0f, -1.0f },{ 0.0f, 0.0f, -1.0f }, 48},
};
bufferBuilder.AddBufferView(BufferViewTarget::ARRAY_BUFFER);
bufferBuilder.AddAccessors(vertices.data(), count, stride, descs, ArrayCount(descs), nullptr);
This code doesn't seem to work. Setting count to 8 is not correct either as then the accessors count is wrong.
Thank you for your help!
The
BufferBuilder::AddAccessorsAPI seems to rely on data being an interleaved buffer. I was wondering if it is possible to write also non-interleaved buffers with the same API or other APIs?Something along these lines:
This code doesn't seem to work. Setting
countto 8 is not correct either as then the accessors count is wrong.Thank you for your help!