vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
467 stars 75 forks source link

Callback Image loader #73

Closed EricBeetsOfficial-Opuscope closed 3 years ago

EricBeetsOfficial-Opuscope commented 3 years ago

Hi !

I was wondering if it exists a way to have a callback when an image is loading (with the path as an argument). Obviously, I tried to use ReadSettings.ImageReader callback, but it's called once the uri is checked, so in case of wrong path (with an extra folder name or a folder name missing for example), then, it's too late to try to find the texture file on disk.

Thanks in advance, and thanks for the great work !

Eric

vpenades commented 3 years ago

@EricBeetsOfficial-Opuscope , I've been rethinking my answer:

If I understand correctly, you want to control from where the textures are loaded. For that you should create a ReaderContext with a FileReader callback, you can see an example of using the ReaderContext in the ZIP loader context which uses the callback to load the files from a zip file.

The ImageReader callback has a completely different purpose; it's designed to load the textures into the GPU as they're being loaded one by one. I've just renamed it to ImageDecodeCallback which is less misleading.

EricBeetsOfficial-Opuscope commented 3 years ago

Hi Vicente,

Perfect, it works ! It was exactly that I need ! Thank you for your help !

Eric