cglm is a C library for 2D and 3D graphics mathematics that provides highly optimized implementations of vector and matrix operations commonly needed in graphics programming.
The library solves the problem of performing graphics math efficiently in C by offering SIMD-optimized implementations across multiple instruction sets including SSE, AVX, and NEON. It provides three distinct API styles to suit different programming preferences: a header-only mode using the glm_ prefix, a struct API that takes parameters by copy and returns results rather than using pointers, and a linked mode for those who prefer traditional function calls. The tool is allocation-free and can be used entirely as a header-only library by including a single header file, or built and linked against using supported build systems.
Developers should choose this tool if they are writing graphics applications in C and need fast, ergonomic math functions without memory allocation overhead. It suits projects ranging from OpenGL applications to any graphics-heavy C code where performance matters. The library explicitly notes that C++ developers should consider the original GLM library instead. The struct API is particularly useful for developers who prefer functional programming patterns where variables can be marked const, while the header-only approach minimizes build complexity. Alignment of SIMD types is important to understand; the library handles necessary alignment by default but provides an unaligned mode for cases where alignment cannot be guaranteed.
The project maintains comprehensive documentation embedded in header files and available through external documentation. Build support spans multiple platforms and build systems with detailed platform-specific instructions provided. The codebase includes continuous integration testing and code quality monitoring through multiple tracking systems.