Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to write not interleaved buffers? #104

Open
ptc-eparodi opened this issue Oct 26, 2022 · 1 comment
Open

Is it possible to write not interleaved buffers? #104

ptc-eparodi opened this issue Oct 26, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ptc-eparodi
Copy link

ptc-eparodi commented Oct 26, 2022

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!

@bghgary
Copy link
Contributor

bghgary commented Nov 2, 2022

Sorry for the slow response. If you are capable, please debug the code and contribute a fix. Thanks!

@bghgary bghgary closed this as completed Nov 2, 2022
@bghgary bghgary reopened this Nov 2, 2022
@bghgary bghgary added enhancement New feature or request help wanted Extra attention is needed triaged labels Dec 7, 2023
@thomlucc thomlucc removed the triaged label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants