A single-file C99 library for loading and writing glTF 2.0 assets, used by major graphics engines.
cgltf is a single-file C library for loading and writing glTF 2.0 files, the industry-standard format for 3D models and scenes. It solves the problem of integrating glTF support into C/C++ applications without heavy dependencies or complex build systems. The library parses both JSON and binary glTF formats, providing structured access to meshes, materials, animations, and other 3D asset data.
C/C++ developers working on graphics engines, game engines, or 3D tools that need to import or export glTF assets. It's particularly useful for projects prioritizing minimal dependencies and easy integration.
Developers choose cgltf for its simplicity, zero dependencies, and single-file design, which makes it trivial to drop into any project. It's battle-tested in major engines like Filament, bgfx, and raylib, offering reliable glTF 2.0 support without the overhead of larger libraries.
:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The entire library is contained in cgltf.h and cgltf_write.h, making integration as simple as dropping a file into a project, following the stb-style philosophy for minimal setup.
Uses only standard C headers and includes an embedded JSMN JSON parser, ensuring portability and avoiding build complexity, as highlighted in the README's dependencies section.
Handles core features like meshes, materials, animations, and supports key extensions such as KHR_draco_mesh_compression and KHR_materials_unlit, providing structured access to 3D asset data.
Allows loading from file or memory and writing to file or memory, with helpers like cgltf_load_buffers for convenience, offering adaptability for different project needs.
Widely used in major projects like Filament and bgfx, as noted in the README, indicating robust performance and community trust in real-time applications.
Does not automatically load external buffer or image files; users must read these based on URIs from data structures, adding boilerplate code and complexity, as warned in the loading examples.
Some extensions like KHR_draco_mesh_compression require linking external libraries (e.g., Google's Draco), limiting out-of-the-box functionality and increasing integration effort.
The C-style API can be cumbersome for C++ developers, lacking modern features like exceptions or smart pointers for memory management, which may require additional wrapping code.