syoyo / tinygltf

Header only C++11 tiny glTF 2.0 library
MIT License
2.03k stars 410 forks source link

Buffer allocation callback function #184

Open harokyang opened 5 years ago

harokyang commented 5 years ago

After parsing a gltf file, all the buffers are already allocated in host memory

If we can provide a callback function to handle buffer memory allocation while loading then it is possible to load binary data directly into staging buffer and save one memory copying on host side very helpful with large size scene

harokyang commented 5 years ago

Or at least provide a method to set custom allocator for std::vector data in tinygltf::Buffer

syoyo commented 5 years ago

There are some situation for reading Buffer data: From base64 encoded string, from URI, from external bin file, from embedded bin section in .glb.

At this time, it would be difficult to provide unified callback function for Buffer allocation.

What is your actual usecase(e.g. want to read large .bin file)?

harokyang commented 5 years ago

I'm doing some real time rendering/video streaming Large scene and dynamic loading may involved

I'm currently experimenting on adding a new constructor for Model class to pass a custom std::allcoator

syoyo commented 5 years ago

I see. Could you please send a PR? > I'm currently experimenting on adding a new constructor for Model class to pass a custom std::allcoator

harokyang commented 5 years ago

It's on my company's project I have to reimplement it in a different way before submit to fork on github to avoid copyright issue It may take some time