Skip to content
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

Add glTF sampler filters and wrap modes enums #258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matthew-rister
Copy link

@matthew-rister matthew-rister commented Nov 15, 2024

Problem

cgltf_sampler defines filter and wrap modes using cgltf_int, which requires referencing the glTF specification to interpret those integers.

Solution

To resolve this, enumerations representing valid glTF sampler filter and wrap modes are introduced. For backward compatibility, these enumerations retain their original integer values to allow implicit conversion to cgltf_int.

Testing

Project tests were run using tests/test_all.py on Windows (MSVC 19.41.34123) and Ubuntu (GCC 13.2) which passed without any errors. Additionally, these changes were validated on a sample Vulkan glTF loading implementation in C++ as demonstrated by this commit.

Notes

  • cgltf_sampler_filter_type was considered, but the convention to prefix enumeration values with their respective type name resulted in excessively verbose names such as cgltf_sampler_filter_type_nearest_mipmap_nearest.
  • cgltf_wrap_mode omits the suffix _type because there is precedent with a similar enum: cgltf_alpha_mode.

Closes #256

cgltf_sampler defines filter and wrap modes using cgltf_int, which
requires referencing the glTF specification to interpret those integers.
To resolve this, enumerations representing valid glTF sampler filter and
wrap modes are introduced. For backward compatibility, these
enumerations retain their original integer values to allow implicit
conversion to cgltf_int.
@zeux
Copy link
Contributor

zeux commented Nov 30, 2024

fwiw I've tested this in gltfpack and it works correctly (no app code changes required). It would probably be more consistent with the rest of the code to omit the _default enum value for wrap mode (and just use _repeat explicitly) but it works either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Consider adding enumerations for glTF sampler filters and wrap modes
2 participants