Skip to content

Is it possible to write not interleaved buffers? #104

Description

@ptc-eparodi

The BufferBuilder::AddAccessors API 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:

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions