-
Notifications
You must be signed in to change notification settings - Fork 136
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
[Feature Request] Consider adding enumerations for glTF sampler filters and wrap modes #256
Comments
Makes sense to me, it's the only case in the current API where integers are used instead of enums. Mind contributing a PR? |
Gladly! Before I proceed, I would just like to confirm that you’re in alignment with the proposed approach of assigning glTF filter / wrap modes as enumeration values to maintain backward compatibility with implementations that previously relied on |
Hmm yeah I see. It's... probably fine? Any change to enum would require code that assigns these to change (but I'd expect this to be less frequent, as it only impacts cgltf_write). Using sequential enum values would silently break code like this: https://github.com/google/filament/blob/main/libs/gltfio/src/GltfEnums.h#L27-L75 ... whereas using enum with GL values would keep the code above working, and any issues would manifest as compile time errors, which feels safer. Ideally this probably should have used sequential enums to begin with, but right now changing this to non-sequential enums is the safest change. If this becomes a problem maybe these can be renumbered down the line (which would not break any users who migrate to using enum values). |
Similar code from gltfpack: https://github.com/zeux/meshoptimizer/blob/master/gltf/write.cpp#L794-L820 -- this will also work without any changes if an enum with non-sequential values is introduced. Minor note: cgltf_filter_type should also have an entry
|
Thanks for your patience with getting this out. Here is the PR with the proposed changes. |
cgltf_sampler
defines sampler filter and wrap modes usingcgltf_int
. This is unfortunate because it requires referring to the glTF specification to understand what values are allowed for each property in addition to hardcoding those values into a glTF loading implementation. A better user experience would be to represent those values using a dedicatedenum
similar to othercgltf
enumerations such ascgltf_primitive_type
andcgltf_attribute_type
. A fix for this should be relatively straightforward and would look something likeThe text was updated successfully, but these errors were encountered: