GLSLmath provides C++ math operations as defined by GLSL. For example, it provides methods to easily setup viewing transformations and perspective projections.

GLSLmath has been inspired by the glm and slmath libraries, which aim to mimic GLSL, but in contrast to those GLSLmath does not focus on a complete conforming implementation of GLSL. It rather aims to provide a convenient single header file that implements the most commonly used subset of GLSL so that it is easy to use for rapid prototyping and GLSL teaching purposes.


  • GLSLmath consists of a single C++ header file.
  • It contains vector and matrix classes and linear algebra operators that allow computer graphics developers to write math operations in C++ just like one is used to it from GLSL.
  • Complete set of linear algebra operations including support for homogeneous coordinates and quaternions.
  • It contains methods for intersection testing of geometric primitives like lines, triangles and ellipsoids.
  • Easy to use, so it is ideal for rapid prototyping or GLSL teaching purposes.
  • Regression-tested to be bugfree.

The source code is hosted at

Check it out with the following svn command:

  svn co glslmath

The full API documentation is available in the README:

Here is an example use case: