GitHub - g-truc/glm: OpenGL Mathematics (GLM) (original) (raw)

glm

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 requires a C++ 17 compiler. For older C++ support, GLM 1.0 branch can be used. 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.

#include <glm/vec3.hpp> // glm::vec3 #include <glm/vec4.hpp> // glm::vec4 #include <glm/mat4x4.hpp> // glm::mat4 #include <glm/ext/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale #include <glm/ext/matrix_clip_space.hpp> // glm::perspective #include <glm/ext/scalar_constants.hpp> // glm::pi

glm::mat4 camera(float Translate, glm::vec2 const& Rotate) { glm::mat4 Projection = glm::perspective(glm::pi() * 0.25f, 4.0f / 3.0f, 0.1f, 100.f); glm::mat4 View = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); View = glm::rotate(View, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); View = glm::rotate(View, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); return Projection * View * Model; }

Latest release

Project Health

Service Status
GitHub actions .github/workflows/ci.yml

Build and Install

cd /path/to/glm cmake
-DGLM_BUILD_TESTS=OFF
-DBUILD_SHARED_LIBS=OFF
-B build . cmake --build build -- all cmake --build build -- install

Passing -DBUILD_SHARED_LIBS=ON to build shared library

And then in your CMakeLists.txt:

find_package(glm CONFIG REQUIRED) target_link_libraries(main PRIVATE glm::glm)

If your prefer to use header-only version of GLM

find_package(glm CONFIG REQUIRED) target_link_libraries(main PRIVATE glm::glm-header-only)

Vcpkg

CMake using FetchContent

You can add glm to your CMake project to be built together.

Add to the CMakeLists.txt file:

cmake_minimum_required(VERSION 3.11) # FetchContent is new in version 3.11.

include(FetchContent)

FetchContent_Declare( glm GIT_REPOSITORY https://github.com/g-truc/glm.git GIT_TAG 0af55ccecd98d4e5a8d1fad7de25ba429d60e863 #refs/tags/1.0.1 )

FetchContent_MakeAvailable(glm)

target_link_libraries(main PRIVATE glm::glm)

Release notes

GLM 1.0.3 - 2025-XX-XX

Fixes:

GLM 1.0.2 - 2025-10-15

Features:

Improvements:

Fixes:

Deprecation:

GLM 1.0.1 - 2024-02-26

Features:

Improvements:

Fixes:

GLM 1.0.0 - 2024-01-24

Features:

Improvements:

Fixes:

GLM 0.9.9.8 - 2020-04-13

Features:

Improvements:

Fixes:

GLM 0.9.9.7 - 2020-01-05

Improvements:

Fixes:

GLM 0.9.9.6 - 2019-09-08

Features:

Improvements:

Fixes:

Deprecation:

GLM 0.9.9.5 - 2019-04-01

Fixes:

GLM 0.9.9.4 - 2019-03-19

Features:

Improvements:

Fixes:

GLM 0.9.9.3 - 2018-10-31

Features:

Improvements:

Fixes:

GLM 0.9.9.2 - 2018-09-14

Fixes:

GLM 0.9.9.1 - 2018-09-03

Features:

Improvements:

Fixes:

GLM 0.9.9.0 - 2018-05-22

Features:

Improvements:

Fixes:

Deprecation:


GLM 0.9.8.5 - 2017-08-16

Features:

Fixes:


GLM 0.9.8.4 - 2017-01-22

Fixes:


GLM 0.9.8.3 - 2016-11-12

Improvements:

Fixes:


GLM 0.9.8.2 - 2016-11-01

Improvements:

Fixes:


GLM 0.9.8.1 - 2016-09-25

Improvements:

Fixes:


GLM 0.9.8.0 - 2016-09-11

Features:

Improvements:

Fixes:

Deprecation:


GLM 0.9.7.6 - 2016-07-16

Improvements:

Fixes:


GLM 0.9.7.5 - 2016-05-24

Improvements:

Fixes:


GLM 0.9.7.4 - 2016-03-19

Fixes:


GLM 0.9.7.3 - 2016-02-21

Improvements:

Fixes:


GLM 0.9.7.2 - 2016-01-03

Fixes:


GLM 0.9.7.1 - 2015-09-07

Improvements:

Fixes:


GLM 0.9.7.0 - 2015-08-02

Features:

Improvements:

Fixes:

Deprecation:


GLM 0.9.6.3 - 2015-02-15


GLM 0.9.6.2 - 2015-02-15

Features:

Improvements:

Fixes:


GLM 0.9.6.1 - 2014-12-10

Features:

Improvements:

Fixes:


GLM 0.9.6.0 - 2014-11-30

Features:

Improvements:

Fixes:

Deprecation:


GLM 0.9.5.4 - 2014-06-21


GLM 0.9.5.3 - 2014-04-02


GLM 0.9.5.2 - 2014-02-08


GLM 0.9.5.1 - 2014-01-11


GLM 0.9.5.0 - 2013-12-25


GLM 0.9.4.6 - 2013-09-20


GLM 0.9.4.5 - 2013-08-12


GLM 0.9.4.4 - 2013-05-29


GLM 0.9.4.3 - 2013-03-20


GLM 0.9.4.2 - 2013-02-14


GLM 0.9.4.1 - 2012-12-22


GLM 0.9.4.0 - 2012-11-18


GLM 0.9.3.4 - 2012-06-30


GLM 0.9.3.3 - 2012-05-10


GLM 0.9.3.2 - 2012-03-15


GLM 0.9.3.1 - 2012-01-25


GLM 0.9.3.0 - 2012-01-09


GLM 0.9.3.B - 2011-12-12


GLM 0.9.3.A - 2011-11-11


GLM 0.9.2.7 - 2011-10-24


GLM 0.9.2.6 - 2011-10-01


GLM 0.9.2.5 - 2011-09-20


GLM 0.9.2.4 - 2011-09-03


GLM 0.9.2.3 - 2011-06-08


GLM 0.9.2.2 - 2011-06-02


GLM 0.9.2.1 - 2011-05-24


GLM 0.9.2.0 - 2011-05-09


GLM 0.9.1.3 - 2011-05-07


GLM 0.9.1.2 - 2011-04-15


GLM 0.9.1.1 - 2011-03-17


GLM 0.9.1.0 - 2011-03-03


GLM 0.9.1.B - 2011-02-13


GLM 0.9.0.8 - 2011-02-13


GLM 0.9.1.A - 2011-01-31


GLM 0.9.0.7 - 2011-01-30


GLM 0.9.0.6 - 2010-12-21


GLM 0.9.0.5 - 2010-11-01


GLM 0.9.0.4 - 2010-10-04


GLM 0.9.0.3 - 2010-08-26


GLM 0.9.0.2 - 2010-07-08


GLM 0.9.0.1 - 2010-06-21


GLM 0.9.0.0 - 2010-05-25


GLM 0.9.B.2 - 2010-04-30


GLM 0.9.B.1 - 2010-04-03


GLM 0.9.A.2 - 2010-02-20


GLM 0.9.A.1 - 2010-02-09


GLM 0.8.4.4 final - 2010-01-25


GLM 0.8.4.3 final - 2009-11-16


GLM 0.8.4.2 final - 2009-10-19


GLM 0.8.4.1 final - 2009-10-05


GLM 0.8.4.0 final - 2009-09-16


GLM 0.8.3.5 final - 2009-08-11


GLM 0.8.3.4 final - 2009-08-10


GLM 0.8.3.3 final - 2009-06-25


GLM 0.8.3.2 final - 2009-06-04


GLM 0.8.3.1 final - 2009-05-21


GLM 0.8.3.0 final - 2009-05-06


GLM 0.8.2.3 final - 2009-04-01


GLM 0.8.2.2 final - 2009-02-24


GLM 0.8.2.1 final - 2009-02-13


GLM 0.8.2 final - 2009-01-21


GLM 0.8.1 final - 2008-10-30


GLM 0.8.0 final - 2008-10-23


GLM 0.8.0 beta3 - 2008-10-10


GLM 0.8.0 beta2 - 2008-10-04


GLM 0.8.0 beta1 - 2008-09-26


GLM 0.7.6 final - 2008-08-08


GLM 0.7.5 final - 2008-07-05


GLM 0.7.4 final - 2008-06-01


GLM 0.7.3 final - 2008-05-24


GLM 0.7.2 final - 2008-04-27


GLM 0.7.1 final - 2008-03-24


GLM 0.7.0 final - 2008-03-22


GLM 0.6.4 - 2007-12-10


GLM 0.6.3 - 2007-11-05


GLM 0.6.2 - 2007-10-08


GLM 0.6.1 - 2007-10-07


GLM 0.6.0 : 2007-09-16


GLM 0.5.1 - 2007-02-19


GLM 0.5.0 - 2007-01-06


GLM 0.4.1 - 2006-05-22


GLM 0.4.0 - 2006-05-17


GLM 0.3.2 - 2006-04-21


GLM 0.3.1 - 2006-03-28


GLM 0.3 - 2006-02-19


GLM 0.2 - 2005-05-05


GLM 0.1 - 2005-02-21