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

Add ResourceWriter::Write overload with a buffer id parameter instead of a buffer view #136

Open
docEdub opened this issue Feb 7, 2024 · 0 comments

Comments

@docEdub
Copy link

docEdub commented Feb 7, 2024

When writing GLB chunk data it would be useful to have an overload of ResourceWriter::Write that allows writing to the magic "binary_glTF" buffer without having to create a temporary buffer view. The overload signature could use a const char* or a const std::string& for the buffer id parameter, e.g. ResourceWriter::Write(const char* bufferId, const std::vector<T>& data).

The only way to do this right now is:

std::vector< uint8_t > data = ...
      
glTF::BufferView tmpBufferView {};
tmpBufferView.bufferId = glTF::GLB_BUFFER_ID;
tmpBufferView.byteOffset = currentByteOffset;
tmpBufferView.byteLength = data.size();
pResourceWriter->Write( tmpBufferView, data );

With the requested ResourceWriter::Write(const char* bufferId, const std::vector<T>& data) overload, the temporary buffer view is not needed:

std::vector< uint8_t > data = ... 
pResourceWriter->Write( glTF::GLB_BUFFER_ID, data );

This should be trivial to implement since ResourceWriter::WriterImpl currently only uses the given buffer view's buffer id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant