spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability
https://fastgltf.readthedocs.io/v0.8.x/
MIT License
303 stars 44 forks source link

is EXT_meshopt_compression supported? #19

Closed tigrazone closed 1 year ago

tigrazone commented 1 year ago

I try to open with examples/gl_viewer file https://github.com/gkjohnson/3d-demo-data/tree/main/models/interior-scene/scene.gltf and viewer failed with error code Failed to parse glTF: 2 Failed to parse glTF I searched for this error in source code and understand it is an Error::MissingExtensions(2). I find in src/fastgltf.cpp line SET_ERROR_RETURN_ERROR(Error::MissingExtensions)

and before it added printf("extension: %s\n", std::string(extensionString).c_str()); and now error message is Loading c:\msys64\home\user\from-git\3d-demo-data\models\interior-scene\scene.gltf extension: EXT_meshopt_compression Failed to parse glTF: 2 Failed to parse glTF

i.e EXT_meshopt_compression not supported? Maybe I need to set some config flags?

spnda commented 1 year ago

Please read the README thoroughly. Yes, the extension is fully supported by the fastgltf parser. For using extensions, please look at this constructor of the Parser object: https://github.com/spnda/fastgltf/blob/41f1793d848297fa6aa480402a9ec7e68a96a712/src/fastgltf_parser.hpp#L405 You can OR together all Extensions you want to load to indicate that you do support them. If not, fastgltf assumes you don't support the Extensions and fails with the error code 2 (MissingExtensions): https://github.com/spnda/fastgltf/blob/41f1793d848297fa6aa480402a9ec7e68a96a712/src/fastgltf_parser.hpp#L66-L68

And as the gl_viewer doesn't list those extensions in the constructor, it does not support it. I simply didn't want to make the example any more complex than it needs to be by adding another library. The gl_viewer is meant to show a very basic example of how to use most of the features fastgltf provides.