0.9.9 0.9.8 0.9.7 0.9.6 0.9.5 0.9.4 0.9.3 0.9.2 0.9.1 0.9.0

OpenGL Mathematics

GLSL + Optional features = OpenGL Mathematics (GLM)

A C++ mathematics library for graphics programming

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 functionalities 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, physic 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:
  • Apple Clang 6.0 and higher
  • GCC 4.7 and higher
  • Intel C++ Composer XE 2013 and higher
  • LLVM 3.4 and higher
  • Visual C++ 2013 and higher
  • CUDA 9.0 and higher (experimental)
  • Any conform C++11 compiler

For more information about GLM, please have a look at the manual and the API reference documentation.

The source code and the documentation, including this manual, are licensed under the Happy Bunny License (Modified MIT) or the MIT License.

Thanks for contributing to the project by submitting issues for bug reports and feature requests. Any feedback is welcome at

Code sample:
  • #include <glm/vec3.hpp> // glm::vec3
  • #include <glm/vec4.hpp> // glm::vec4
  • #include <glm/mat4x4.hpp> // glm::mat4
  • #include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
  • glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
  • {
  • glm::mat4 Projection = glm::perspective(glm::radians(45.0f), 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;
  • }