-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
Separate text parsing from binary parsing #177
Comments
Please describe the issue in detail. What is your problem? |
I think I understand: @UX3D-schmithuesen wish there could be a way to either skip or defer image and binary buffer loading. Currently the behavior of the library is; when you call on of the TinyGLTF::LoadX() functions,
I think Benjamin has a use-case where he wants to use only the result of the parsing of the JSON, and doesn't actually need to load to memory either the binary buffers or the textures. At least not from the get go. That's actually an interesting idea. What you could do at the moment is, for the images, you can stub their loading out by providing your own image loader callback. You can do that by providing a function pointer to @syoyo What is you thought about adding a "deferred loading" feature to tinygltf. Something as simple as having |
That is correct, but maybe I just didn't pay enough attention – if I define |
We may better to clean-up PR is always welcome. |
I would really like this feature to be implemented in one way or another. I want to load images asynchronously via iocp/io_uring, and that means that providing a function that makes images/buffers immediately available is simply impossible. Maybe make the loader functions return a ternary value, "success", "failure" or "deferred", and then add a simple interface to the model class for providing the deferred file data? P.S. Reimplementing image parsing is not my intention here, so I would still like tinygltf to use it's default image loading library after I provide the raw file bytes. These concerns should definitely be separate. |
@Mrkol We implemented delayed image loading feature in our private project by using Line 655 in e7f1ff5
and providing FS callback function like this: // Delayed loading of image files since compressed image like jpeg/png takes
// some amount time in decoding. Just add raw image data into queues, then after
// parsing glTF, we'll try to actually decode images in parallel.
static bool DelayedLoadImageData(tinygltf::Image *out, std::string *err,
std::string *warn, int req_width,
int req_height, const unsigned char *bytes,
int bsize, void *arg) {
(void)err;
(void)arg;
if (bsize < 1) {
if (warn) {
(*warn) += "Invalid byte length.\n";
}
return false;
}
out->width = req_width;
out->height = req_height;
out->component = 1; // This will be determined after decoding image data.
out->image.resize(size_t(bsize));
memcpy(out->image.data(), bytes, size_t(bsize));
out->as_is = true;
return true;
}
...
tinygltf::TinyGLTF gltf;
gltf.SetImageLoader(DelayedLoadImageData, nullptr); Then, after parsing a glTF scene, scan
|
@syoyo This is a nice feature, but it only covers deferred image parsing, not file loading. I want to be able to use custom low level (async) IO with the library, which the current interface doesn't really support. Basically separating the file loading into 2 steps: request to load a file, notification that a file was successfully loaded. This is orthogonal to png/jpg parsing. |
It shouldn't be necessary to load the image files and separate binary buffer when loading the glTF asset – most actions and inspections don't require that data and we only want to load it if and when it is needed.
The text was updated successfully, but these errors were encountered: