OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.
GLM provides classes and functions designed and implemented with the same naming conventions and functionality than GLSL so that anyone who knows GLSL, can use GLM as well in C++.
This project isn't limited to GLSL features. An extension system, based on the GLSL extension conventions, provides extended capabilities: matrix transformations, quaternions, data packing, random numbers, noise, etc...
This library works perfectly with OpenGL but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (raytracing / rasterisation), image processing, physics simulations and any development context that requires a simple and convenient mathematics library.
GLM is written in C++98 but can take advantage of C++11 when supported by the compiler. It is a platform independent library with no dependence and it officially supports the following compilers:
For more information about GLM, please have a look at the manual and the API reference documentation.
The source code and the documentation are licensed under either the Happy Bunny License (Modified MIT) or the MIT License.
Thanks for contributing to the project by submitting pull requests.
Project Health
Release notes
Features:
- Added GLM_EXT_scalar_reciprocal with tests
- Added GLM_EXT_vector_reciprocal with tests
- Added
glm::iround and glm::uround to GLM_EXT_scalar_common and GLM_EXT_vector_common
- Added GLM_EXT_matrix_integer with tests
- Added Github Actions
Improvements:
- Added
constexpr qualifier for cross product #1040
- Added
constexpr qualifier for dot product #1040
Fixes:
- Fixed incorrect assertion for
glm::min and glm::max #1009
- Fixed quaternion orientation in
glm::decompose #1012
- Fixed singularity in quaternion to euler angle roll conversion #1019
- Fixed
quat glm::pow handling of small magnitude quaternions #1022
- Fixed
glm::fastNormalize build error #1033
- Fixed
glm::isMultiple build error #1034
- Fixed
glm::adjugate calculation #1035
- Fixed
glm::angle discards the sign of result for angles in range (2pi-1, 2pi) #1038
- Removed ban on using
glm::string_cast with CUDA host code #1041
Features:
- Added GLM_EXT_vector_intX and GLM_EXT_vector_uintX extensions
- Added GLM_EXT_matrix_intX and GLM_EXT_matrix_uintX extensions
Improvements:
- Added
glm::clamp, glm::repeat, glm::mirrorClamp and glm::mirrorRepeat function to GLM_EXT_scalar_commond and GLM_EXT_vector_commond extensions with tests
Fixes:
- Fixed unnecessary warnings from
matrix_projection.inl #995
- Fixed quaternion
glm::slerp overload which interpolates with extra spins #996
- Fixed for
glm::length using arch64 #992
- Fixed singularity check for
glm::quatLookAt #770
Improvements:
- Improved Neon support with more functions optimized #950
- Added CMake GLM interface #963
- Added
glm::fma implementation based on std::fma #969
- Added missing quat constexpr #955
- Added
GLM_FORCE_QUAT_DATA_WXYZ to store quat data as w,x,y,z instead of x,y,z,w #983
Fixes:
- Fixed equal ULP variation when using negative sign #965
- Fixed for intersection ray/plane and added related tests #953
- Fixed ARM 64bit detection #949
- Fixed GLM_EXT_matrix_clip_space warnings #980
- Fixed Wimplicit-int-float-conversion warnings with clang 10+ #986
- Fixed GLM_EXT_matrix_clip_space
perspectiveFov
Features:
- Added Neon support #945
- Added SYCL support #914
- Added GLM_EXT_scalar_integer extension with power of two and multiple scalar functions
- Added GLM_EXT_vector_integer extension with power of two and multiple vector functions
Improvements:
- Added Visual C++ 2019 detection
- Added Visual C++ 2017 15.8 and 15.9 detection
- Added missing genType check for
glm::bitCount and glm::bitfieldReverse #893
Fixes:
- Fixed for g++6 where -std=c++1z sets __cplusplus to 201500 instead of 201402 #921
- Fixed hash hashes qua instead of tquat #919
- Fixed
.natvis as structs renamed #915
- Fixed
glm::ldexp and glm::frexp declaration #895
- Fixed missing const to quaternion conversion operators #890
- Fixed GLM_EXT_scalar_ulp and GLM_EXT_vector_ulp API coding style
- Fixed quaternion componant order:
w, {x, y, z} #916
- Fixed
GLM_HAS_CXX11_STL broken on Clang with Linux #926
- Fixed Clang or GCC build due to wrong
GLM_HAS_IF_CONSTEXPR definition #907
- Fixed CUDA 9 build #910
Deprecation:
- Removed CMake install and uninstall scripts
Fixes:
- Fixed build errors when defining
GLM_ENABLE_EXPERIMENTAL #884 #883
- Fixed
if constexpr warning #887
- Fixed missing declarations for
glm::frexp and glm::ldexp #886
Features:
- Added
glm::mix implementation for matrices in *GLM_EXT_matrix_common/ #842
- Added CMake
BUILD_SHARED_LIBS and BUILD_STATIC_LIBS build options #871
Improvements:
- Added GLM_FORCE_INTRINSICS to enable SIMD instruction code path. By default, it's disabled allowing constexpr support by default. #865
- Optimized inverseTransform #867
Fixes:
- Fixed in
glm::mat4x3 conversion #829
- Fixed
constexpr issue on GCC #832 #865
- Fixed
glm::mix implementation to improve GLSL conformance #866
- Fixed
glm::int8 being defined as unsigned char with some compiler #839
- Fixed
glm::vec1 include #856
- Ignore
.vscode #848
Features:
- Added
glm::equal and glm::notEqual overload with max ULPs parameters for scalar numbers #121
- Added
GLM_FORCE_SILENT_WARNINGS to silent GLM warnings when using language extensions but using W4 or Wpedantic warnings #814 #775
- Added adjugate functions to
GLM_GTX_matrix_operation #151
- Added
GLM_FORCE_ALIGNED_GENTYPES to enable aligned types and SIMD instruction are not enabled. This disable constexpr #816
Improvements:
- Added constant time ULP distance between float #121
- Added
GLM_FORCE_SILENT_WARNINGS to suppress GLM warnings #822
Fixes:
- Fixed
glm::simplex noise build with double #734
- Fixed
glm::bitfieldInsert according to GLSL spec #818
- Fixed
glm::refract for negative 'k' #808
Fixes:
- Fixed
GLM_FORCE_CXX** section in the manual
- Fixed default initialization with vector and quaternion types using
GLM_FORCE_CTOR_INIT #812
Features:
- Added
bitfieldDeinterleave to GLM_GTC_bitfield
- Added missing
glm::equal and glm::notEqual with epsilon for quaternion types to GLM_GTC_quaternion
- Added GLM_EXT_matrix_relational:
glm::equal and glm::notEqual with epsilon for matrix types
- Added missing aligned matrix types to GLM_GTC_type_aligned
- Added C++17 detection
- Added Visual C++ language standard version detection
- Added PDF manual build from markdown
Improvements:
- Added a section to the manual for contributing to GLM
- Refactor manual, lists all configuration defines
- Added missing
glm::vec1 based constructors
- Redesigned constexpr support which excludes both SIMD and
constexpr #783
- Added detection of Visual C++ 2017 toolsets
- Added identity functions #765
- Splitted headers into EXT extensions to improve compilation time #670
- Added separated performance tests
- Clarified refract valid range of the indices of refraction, between -1 and 1 inclusively #806
Fixes:
- Fixed SIMD detection on Clang and GCC
- Fixed build problems due to
std::printf and std::clock_t #778
- Fixed int mod
- Anonymous unions require C++ language extensions
- Fixed
glm::ortho #790
- Fixed Visual C++ 2013 warnings in vector relational code #782
- Fixed ICC build errors with constexpr #704
- Fixed defaulted operator= and constructors #791
- Fixed invalid conversion from int scalar with vec4 constructor when using SSE instruction
- Fixed infinite loop in random functions when using negative radius values using an assert #739
Features:
- Added RGBM encoding in GLM_GTC_packing #420
- Added GLM_GTX_color_encoding extension
- Added GLM_GTX_vec_swizzle, faster compile time swizzling then swizzle operator #558
- Added GLM_GTX_exterior_product with a
vec2 glm::cross implementation #621
- Added GLM_GTX_matrix_factorisation to factor matrices in various forms #654
- Added
GLM_ENABLE_EXPERIMENTAL to enable experimental features.
- Added packing functions for integer vectors #639
- Added conan packaging configuration #643 #641
- Added
glm::quatLookAt to GLM_GTX_quaternion #659
- Added
glm::fmin, glm::fmax and glm::fclamp to GLM_GTX_extended_min_max #372
- Added GLM_EXT_vector_relational: extend
glm::equal and glm::notEqual to take an epsilon argument
- Added GLM_EXT_vector_relational:
glm::openBounded and glm::closeBounded
- Added GLM_EXT_vec1:
*vec1 types
- Added GLM_GTX_texture:
levels function
- Added spearate functions to use both nagative one and zero near clip plans #680
- Added
GLM_FORCE_SINGLE_ONLY to use GLM on platforms that don't support double #627
- Added GLM_GTX_easing for interpolation functions #761
Improvements:
- No more default initialization of vector, matrix and quaternion types
- Added lowp variant of GTC_color_space convertLinearToSRGB #419
- Replaced the manual by a markdown version #458
- Improved API documentation #668
- Optimized GTC_packing implementation
- Optimized GTC_noise functions
- Optimized GTC_color_space HSV to RGB conversions
- Optimised GTX_color_space_YCoCg YCoCgR conversions
- Optimized GTX_matrix_interpolation axisAngle function
- Added FAQ 12: Windows headers cause build errors... #557
- Removed GCC shadow warnings #595
- Added error for including of different versions of GLM #619
- Added GLM_FORCE_IGNORE_VERSION to ignore error caused by including different version of GLM #619
- Reduced warnings when using very strict compilation flags #646
- length() member functions are constexpr #657
- Added support of -Weverything with Clang #646
- Improved exponential function test coverage
- Enabled