This library works perfectly with OpenGL but it also ensures interoperability with third party libraries and SDKs.
It is a good candidate for software rendering (Raytracing / Rasterisation), image processing, physic simulations and any context that requires a simple and convenient mathematics library.
</p><divxmlns="http://www.w3.org/1999/xhtml"><spanclass="list">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 officially supports the following compilers:</span><ul><li><axmlns=""href="http://clang.llvm.org">Clang</a> 2.6 and higher</li><li><axmlns=""href="http://developer.nvidia.com/category/zone/cuda-zone">CUDA</a> 3.0 and higher
</li><li><axmlns=""href="http://gcc.gnu.org/">GCC</a> 3.4 and higher</li><li><axmlns=""href="http://llvm.org/">LLVM</a> 2.3 through GCC 4.2 front-end and higher</li><li><axmlns=""href="http://msdn.microsoft.com/en-us/visualc/default">Visual C++</a> 2005 and higher</li><li>Any conform C++98 or C++11 compiler</li></ul></div><p>
The source code is licenced under the <ahref="./copying.txt">MIT license</a>.
</p>
For more information about GLM, please have a look at the manual and the API reference documentation.
Thanks for contributing to the project by <ahref="https://sourceforge.net/apps/trac/ogl-math/newticket">submitting tickets</a> for bug reports and feature requests. (SF.net account required).
Swizzle operators are a challenging task to implement but thanks to the effort of many contributors, GLM 0.9.3.0 provides finally something interesting even if
not perfect but still a great improvement considering the incompatibilities with some external libraries. GLM 0.9.3 provides two implemetanations, one for C++ 98
compilers and one for C++ 11 compilers providing an implemetnation closer to what GLSL does. Indeed the C++ 98 implementation is compatible with C++ 11 compilers.
</p><imgsrc=""alt=""/><spanxmlns="http://www.w3.org/1999/xhtml"class="code-title">Implementation for C++ 98 compilers:</span><ulxmlns="http://www.w3.org/1999/xhtml"class="code-list"><liclass="code-line"><spanclass="code-line-content"><spanclass="comment">// To declare before including glm.hpp, to use the swizzle operators</span></span></li><liclass="code-line"><spanclass="code-line-content"><spanclass="keyword">#define </span> GLM_SWIZZLE
</span></li></ul><spanxmlns="http://www.w3.org/1999/xhtml"class="code-title">Implementation for C++ 11 compilers:</span><ulxmlns="http://www.w3.org/1999/xhtml"class="code-list"><liclass="code-line"><spanclass="code-line-content"><spanclass="comment">// To declare before including glm.hpp, to use the swizzle operators</span></span></li><liclass="code-line"><spanclass="code-line-content"><spanclass="keyword">#define </span> GLM_SWIZZLE
This revision fixes two problems: First, it adds all matrix products for all possible combinations of none-squared matrices. Thanks to Grant James who has provide the code for that.
Half based vector types have been fixed on GCC 4.4 and below, missing l-value swizzle operations added and a couple of other bugs squeezed down.
</p><p>
Finally, all the Visual C++ /W4 warnings should have been removed. However, for this to happen, it is required to build with the Visual C++ language extension disabled (/Za).
The main improvement of this version comes from the extended number of matrix constructors so that a programmer can used different scalar types for each parameter.
</p><ulxmlns="http://www.w3.org/1999/xhtml"class="code-list"><liclass="code-line"><spanclass="code-line-content"><spanclass="keyword">#include </span><spanclass="string"><glm/glm.hpp></span></span></li><liclass="code-line"><spanclass="code-line-content"/></li><liclass="code-line"><spanclass="code-line-content"><spanclass="comment">// Create an identity matrix</span></span></li><liclass="code-line"><spanclass="code-line-content">
The quaternion implementation has been updated as well, fixing the various slerp implementation flavours (mix, shortMix and fastMix) and providing more completeness: Added interaction with GLM_GTX_epsilon and missing lowp_quat, mediump_quat and highp_quat but also none square matrix equivalents.
</p><p>
Finally, some efforts have been put to remove warnings across all supported compilers.
GLM 0.9.2.1 significantly improves compiler detection which allows CUDA to be automatically recognized when GLM is used inside a CUDA kernel.
By conscequence, <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">GLM_FORCE_CUDA</span> is no longer required to be declared.
</p><p>
It fixed a couple of bugs, including Visual C++ supprot when Visual C++ extensions are disabled and fixed implementations of GLM_GTX_vector_angle and GLM_GTX_rotate_vector extensions.
GLM 0.9.2.0 provides many exciting features which first of all is the CUDA copiler support so that GLM can be used within a CUDA kernel. This is possible only by defining GLM_FORCE_CUDA before including glm/glm.hpp in the CUDA Kernel source code.
New experimental extensions are also available. GLM_GTX_noise is based on the work by Stefan Gustavson and Ashima Arts on <ahref="https://github.com/ashima/webgl-noise">WebGL-noise</a> which adds perlin and simplex noise functions in a pure computational way.
If everything goes well, this extension will be promoted to GLM core as implementation of the GLSL noise functions.
</p><p>
GLM_GTX_ulp provides functions to evaluate the number of ULPs between two floating-point values which gives a way to mesure the accuracy of a function compare to a reference function.
In the future, this extension could be used to update the documentation of function and gives the level of accuracy they provide.
</p><p>
Finally, GLM_GTX_matrix_interpolation is an extension developed by Ghenadii Ursachi to extract axis and angle of a 4 by 4 matrix but also directly interpolate between two matrices.
This extension works only on linear transformed matrices.
</p><p>
Last but not least: with the version 0.9.2, GLM supports <ahref="http://www.cmake.org/cmake/help/ctest-2-8-docs.html">CTest</a> to manage GLM test suite which makes tests much easier to maintain.
The number of tests have significantly increase, even if a lot more tests are necessary.
</p><p>
GLM 0.9.2 is not backward compatible with GLM 0.9.1 with only one point: Quaternion SLERP interpolation!
In GLM 0.9.1 the function 'mix' always interpolate using the short rotation path but it's no longer the case.
The function 'shortMix' has to be called for short path interpolation.
'fastMix' will interpolate two quaternions using a normalized linear quaternion interpolation with non-constant rotation speed.
GLM 0.9.1.1 fixes some bugs, warnings on Clang C++ and clean up a bit the code.
</p><p>
If you have uncounter any issue with GLM 0.9.1.0, please download this revision.
</p><p>
Finally, the work has started for GLM 0.9.2 so if you have requests don't forget to <ahref="https://sourceforge.net/apps/trac/ogl-math/newticket">submit them!</a></p>Download: <ahref="https://sourceforge.net/projects/ogl-math/files/glm-0.9.1.1/glm-0.9.1.1.zip/download">GLM 0.9.1.1 (zip)</a><br/>Download: <ahref="https://sourceforge.net/projects/ogl-math/files/glm-0.9.1.1/glm-0.9.1.1.7z/download">GLM 0.9.1.1 (7z)</a><br/>Link: <ahref="https://sourceforge.net/apps/trac/ogl-math/newticket">Submit a bug report</a><br/></div><br/></div><div><h3>03/03/2011 - GLM 0.9.1.0 final released</h3><div><p>
Finally, GLM 0.9.1 branch is reaching the status of stable with
This new version of GLM is bringing a lot of improvements and maybe too many considering the development time it has required:
API exposing SIMD implementation but also some new, safe and feature complet swizzling functions and a new setup API.
All this is described in the largely updated <ahref="http://glm.g-truc.net/glm-0.9.1.pdf">GLM manual</a>.
</p><p>
With the new setup system, GLM detects automatically the compiler settings to adapt its implementation to the flag set at build time.
It will automatically enable C++0x features, SSE optimizations and the display configuration informations at build-time.
The automatic setup can be overdrive by the GLM user.
</p><p>
The SIMD API maintly focus on vec4 and mat4 implementations that are embodied by the types <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">simdVec4</span> and <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">simdMat4</span>.
The implemention cover most of the common functions, the geometry functions and the matrix functions as described in the GLSL specifications.
Because it is hight inefficient to access individual components of a SIMD register, the <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">simdVec4</span> doesn't allow it.
To reflect this constraint, the <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">simdVec4</span> has to be converted to <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">vec4</span> first which would be effectively handle
by the compiler thank to the function <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">simdCast</span>.
Furthermore, GLM provides some specials functions like simdDot4 that returns a <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">simdVec4</span> instead of a float
with the duplicated dot product value in each components
and ensure that no unnecessary component manipulations are performed (typically <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">__m128</span> to <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">float</span>
and <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">float</span> to <spanxmlns="http://www.w3.org/1999/xhtml"class="codeword">__m128</span>).
This implementation can probably be improve in many ways so don't hesitate to send me some feedbacks.
</p><p>
GLM 0.9.1 is not 100% backward compatible with GLM 0.9.0 but mostly advanced usages should be concerned by this compatibility issues.
It also contains a contribution by Arnaud Masserann, a autoexp.dat file to make GLM looks nicer in Visual Studio debugger.
To take advantage of this file, edit ${VISUALSTUDIO_DIRECTORY}/common7/packages/debugger/autoexp.dat file and add the content of the file util/autoexp.txt
By the way, if you have questions about GLM, a good place for those is the <ahref="http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=postlist&Board=10&page=1">OpenGL.org Toolkits forum</a>.
This version brings to main changed: Stable extensions and a new extension system.
</p><p>
The first stable GLM extensions are: GLM_GTC_double_float and GLM_GTC_half_float for higher and lower vectors and matrices floating point precision. GLM_GTC_matrix_operation provides determinant and inverse matrix calculation. GLM_GTC_matrix_transform allows to build scale, rotate and translate matrices and GLM_GTC_matrix_projection provides varius functions to build projection matrices. Few stable extensions yet but the number is going to grow with the next release!
</p><p>
Both GLM 0.8.2.x extensions use method are deprecated (but still working) and replace by a new one. If you wnat to use GLM_GTC_half_float just include "glm/gtc/half_float.hpp" and it is going to be included in GLM namespace.
</p><p>
Finally, quite some file have been renamed, using "hpp" instead of ".h". Old file have been deprecated but are still available so that GLM 0.8.3.0 is fully compatible with GLM 0.8.2.x.
GLM 0.8.0 is released. This new version is now based on GLSL 1.30 specification which provided new functions and precision qualifiers.
</p><p>
Beyond this, lot of changes have been done to make GLM easier to use, easier to develop, more reliable, more conform to C++ ISO98 standard and GLSL specifications.
</p><p>
It involves that GLM 0.8.x is not backward compatible with GLM 0.7.x... However, an application port from GLM 0.7.x to GLM 0.8.x isn't a huge work and actually for some, it won’t be work at all.
</p><p>
On GLM core side, based on GLSL features, vector types can't be automatically cast to pointer anymore for code safety purposes. Vector constructors require a single scalar parameter of the exact number of components.
</p><p>
On GLM extension side, the mechanism to use them has changed. The old [__]***GTX way doesn't exist anymore. Have a look on the manual for more information.
</p><p>
Have a look on the manual and the changelog for more information. Don't forget to send your <ahref="./about.html">feedback</a> and enjoy!
This release fixes some bugs and add few features though extensions. The development is now based on <ahref="http://www.cmake.org">CMake</a> to make easier cross platform tests and project management.
This release mainly improves half float vectors support. By default the low precission vectors are based on float numbers not on half numbers
</p><p>
It also provides new setup options. GLM_USE_ONLY_XYZW to disable multiple names to access to a single vector component. GLM_USE_ANONYMOUS_UNION to allow multiple component names on half vectors with Visual C++.
</p><p>
Various bugs and updates of extensions have been done too. Final release is coming...
GLM have been updated to support GLSL 1.30. API documentation had significant improvements to make easier finding of GLSL functions and types.
</p><p>
GLM 0.8.x is NOT backward compatible with GLM 0.7.x. Upgrade to GLM 0.8.x could involve build errors for the following cases: A lot of improvements have been made to increase the conformance with GLSL specification. Lot of GLSL 1.30 features were already exposed in extensions that have been deleted. The extension syntaxe based on ARB convension is no long used.
</p><p>
Due to the number of changes GLM 0.8.0 is release as beta first. The final release is schedule for october.
GLM 0.7.6 provides a better C++ conformance so that you can build GLM with –pedantic G++ parameter or without Visual Studio extensions. To make GLM more reliable, BOOST_STATIC_ASSERT are used according developer wishes.
GLM 0.7.5 is available and introduces a new build messsage system to get information of GLM build configuration with Visual Studio. This mechanism is documented in section 6 of GLM manual. Also, GLM can be built with GCC pedantic options.
GLM 0.7.4 introduces a new system to manage external dependencies.
</p><p>
It allows developing extension using external dependencies like GLEW, Boost, etc. without making required those dependencies for GLM programmer that doesn't need those external dependent extensions.
</p><p>
The mechanism is described into the updated manual.
GLM 0.7.2 is released. The documentation have been completed again and several issues handle with precompiler options.
</p><p>
#define GLM_SWIZZLE GLM_SWIZZLE_FUNC allows to use swizzle operators with internal functions. For example, glm::vec3(1, 2, 3).zyx is replaced by glm::vec3(1, 2, 3)._zyx() with this option.
</p><p>
#define GLM_FORCE_NO_HALF allows to include all extensions (#include "glm/glmext.h") without any support of half-precision floating-point numbers.
</p><p>
#define GLM_AUTO_CAST GLM_DISABLE allows to disable automatic cast (eg: glLoadMatrixf(glm::mat4(1.0))) which could involve unfortunate issues in some cases.
</p><p>
More information on these topic are available in GLM manual section 5 "Known issues".
GLM 0.7.0 is available under MIT license. LGPL lisence have been discard due to an issue of use for console development. This release contains a lot better documentation based on Doxygen. Lot of bugs have been fixed and the documentation completed. Thanks to all people that has contributed thought bug reports and ideas to make this version a lot better!
GLM 0.6.0 is available. For this release, work focus on extensions. A new mecanisum allows to integrate GLM extensions as it is actually done for GLSL extension by vendors. Lot of new extensions have been added.
A new sample is available. It's an update of Philip Rideout's Catmull Clark subdivision program that uses GLM. Released with pleasant permission of <ahref="http://prideout.net">Philip Rideout</a>.
This release include GLSL 1.2 new feature in the core implementation. Also, it includes swizzle read and write operators and a custom options system to setup GLM.
</p><p>
It includes some new extensions to extend GLSL features but they remain experimental. The next release should provide the first stable extensions.
</p><p>
The GLM 0.5.0 packages contain some basic samples and some documentation. The ray tracer sample has been updated to GLM 0.5.0. Except for specific cases, especially with extensions, GLM 0.5 is backward compatible.
</p><p>
Now, GLM development is taking advantages of <ahref="http://www.sf.net">SourceForge.net</a> services: a <ahref="https://sourceforge.net/tracker/?group_id=129808&atid=901445">bug tracker system</a> and the development source code is publicly available on <ahref="https://svn.sourceforge.net/svnroot/glf">SF.net SVN server</a>.
A GLM update is available. It simply includes some examples for a sweet start with GLM.
</p><p>
The examples show how to use GLM with OpenGL intermediate mode and OpenGL vertex arrays. Also, they show how to use GLM extensions to replace GLU and OpenGL function witch could slightly increase performances by decreasing the number of OpenGL states changes.
This release introduces first GLSL 1.2 features as planed. Also, various new extensions have been added and updated. Finally, it's not anymore required to include windows.h before glm.h when windows.h is required.
</p><p>
The number of features of GLM, including extensions, start to really increase the compilation time. That's why it's recommended to use precompiled headers.
</p>Download: <ahref="http://prdownloads.sourceforge.net/glf/glm-0.4.0.zip?download">GLM 0.4.0</a><br/></div><br/></div><div><h3>23/04/2006 - Roadmap for the years</h3><div>Groove<p>
Version 0.4 will complete matrices and vectors operators and will add GLSL 1.2 features. First, conversions simplifications will be integrated. Then, 4 per 3 matrices and outer product will be available from extensions. The transpose function is already available from extension.
</p><p>
Version 0.5 will integrate GLSL 1.2 features to GLM core.
</p><p>
Version 0.6 will add swizzle operators in reading and writing. (eg: vec3 v1(1.0, 2.0, 3.0); vec3 v2 = v1.xxx; v1.zyx = v;).
This release corrects two main bugs. First, a bug of the imat4 and mat4 division operators and other correct the vectors components access from texture coordinate way.
A new release of GLM is now available. It improves GLSL data type conversion and construction compliance. Also, It's adds extensions like some to manage double-precision and half-precision float numbers. Finally a Doxygen documentation has been added.
</p><p>
This new release have been tested under Visual C++ 7.1, Visual C++ 8.0, GCC 3.2.3 et GCC 3.4.2.
A new release of GLM is now available. A few bugs have been fixed, the portability of GLSL into C++ has been improved, and new experimental extensions have been implemented, enhancing GLSL features.
</p><p>
Project now supports quaternions, adds new features to handle colors, vectors and matrices. For example, GLM allows base colors changing, vector projected operations, and 2D/3D transforms.
</p><p>
To demo the features of this new version, a sample program is included. It is a simple Ray Tracer supporting reflected and refracted rays, three lights types (point, directionnal and spot), two objects types (sphere, plan), using all of the GLM possibilities.
This is the first public availability of GLM. This library supports part of GLSL specifications : All vectors and matrices types, and all the operators and associated functions.
</p><p>
For now, there isn't detailed documentation, but you can freely have a look on GLSL specifications. Consider any incoherence with GLM as an error. Keep in mind the library is included in the namespace "glm".
</p><p>
This project is multi platform and was successfully tested under Visual C++ 7.1, MinGW 3.4 and GCC 3.4.