GLM 0.9.6 is making great progress and a first stable release should available soon. This post is presenting an overview of some changes.

One of the long term issue with GLM is that some functions were using radians, functions from GLSL and others were using degrees, functions from GLU or legacy OpenGL.

In GLM 0.9.5, we can use GLM_FORCE_RADIANS to force all GLM functions to adopt radians.

In GLM 0.9.5 in degrees:

- #include <glm/mat4.hpp>
- #include <glm/gtc/matrix_tansform.hpp>
- glm::mat4 my_rotateZ(glm::mat4 const & m, float angleInRadians)
- {
- return glm::rotate(m, glm::degrees(angleInRadians), glm::vec3(0.0, 0.0, 1.0));
- }

In GLM 0.9.5 in radians:

- #define GLM_FORCE_RADIANS
- #include <glm/mat4.hpp>
- #include <glm/gtc/matrix_tansform.hpp>
- glm::mat4 my_rotateZ(glm::mat4 const & m, float angleInRadians)
- {
- return glm::rotate(m, angleInRadians, glm::vec3(0.0, 0.0, 1.0));
- }

In GLM 0.9.6 in radians only:

- #include <glm/mat4.hpp>
- #include <glm/gtc/matrix_tansform.hpp>
- glm::mat4 my_rotateZ(glm::mat4 const & m, float angleInRadians)
- {
- return glm::rotate(m, angleInRadians, glm::vec3(0.0, 0.0, 1.0));
- }

In GLM 0.9.6 if you what to use degrees anyway:

- #include <glm/mat4.hpp>
- #include <glm/gtc/matrix_tansform.hpp>
- glm::mat4 my_rotateZ(glm::mat4 const & m, float angleInDegrees)
- {
- return glm::rotate(m, glm::radians(angleInDegrees), glm::vec3(0.0, 0.0, 1.0));
- }

GLM 0.9.5 will show warning messages at compilation each time a function taking degrees is used.

GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.

If you are using a version of GLM older than GLM 0.9.5.1, update to GLM 0.9.5.4 before transitioning to GLM 0.9.6 to get this help in that process.

Finally, here is a list of all the functions that could use degrees in GLM 0.9.5.4 that requires radians in GLM 0.9.6: rotate (matrices and quaternions), perspective, perspectiveFov, infinitePerspective, tweakedInfinitePerspective, roll, pitch, yaw, angle, angleAxis, polar, euclidean, rotateNormalizedAxis, rotateX, rotateY, rotateZ and orientedAngle.

There are a lot of reasons for using template types: Writing new template classes and functions or defining new types. Unfortunately, until GLM 0.9.5, GLM template types were defined into the detail namespace indicating there are implementation details that may changed.

With GLM 0.9.6, template types are accessible from the GLM namespace and guarantee to be stable onward.

Example of template functions, GLM 0.9.5 and 0.9.6 style:

- #include <glm/geometry.hpp>
- #include <glm/exponential.hpp>
- template <typename vecType>
- typename vecType::value_type normalizeDot(vecType const & a, vecType const & b)
- {
- return glm::dot(a, b) * glm::inversesqrt(glm::dot(a, a) * glm::dot(b, b));
- }
- #include <glm/vec4.hpp>
- int main()
- {
- return normalizeDot(glm::vec4(2.0), glm::vec4(2.0)) > 0.0f ? 0 : 1
- }

Example of template functions, alternative GLM 0.9.6 style:

- #include <glm/geometry.hpp>
- #include <glm/exponential.hpp>
- template <typename T, template <typename, glm::precision> class vecType>
- T normalizeDot(vecType<T, P> const & a, vecType<T, P> const & b)
- {
- return glm::dot(a, b) * glm::inversesqrt(glm::dot(a, a) * glm::dot(b, b));
- }
- #include <glm/vec4.hpp>
- int main()
- {
- return normalizeDot(glm::vec4(2.0), glm::vec4(2.0)) > 0.0f ? 0 : 1
- }

Example of typedefs with GLM 0.9.6:

- #include <cstddef>
- #include <glm/vec4.hpp>
- #include <glm/mat4.hpp>
- typedef glm::tvec4<std::size_t> size4;
- typedef glm::tvec4<long double, glm::highp> ldvec4;
- typedef glm::tmat4x4<long double, glm::highp> ldmat4x4;

With GLM 0.9.5, the library started to tackle the issue of compilation time by introducing forward declarations through <glm/fwd.hpp> but also by providing an alternative to the monolithic <glm/glm.hpp> headers with <glm/vec2.hpp>, <glm/mat3x2.hpp> and <glm/common.hpp>, etc.

With GLM 0.9.6, the library took advantage of dropping old compilers to replace preprocessor instantiation of the code by template instantiation. The issue of preprocessor instantiation (among them!) is that all the code is generated even if it is never used resulting in building and compiling much bigger header files.

Furthermore, a lot of code optimizations have been done to provide better performance at run time by leveraging integer bitfield tricks and compiler intrinsics. The test framework has been extended to include performance tests. The total code size of the tests is now 50% of the library code which is still not enough but pretty solid.

GLM 0.9.6 removed support for a lot of old compiler versions. If you are really insisting in using an older compiler, you are welcome to keep using GLM 0.9.5.

Supported compilers by GLM 0.9.6:

- Apple Clang 4.0 and higher
- CUDA 4.0 and higher
- GCC 4.4 and higher
- LLVM 3.0 and higher
- Intel C++ Composer XE 2013 and higher
- Visual Studio 2010 and higher
- Any conform C++98 compiler

Finally, GLM is changing Lisence to adopt the Happy Bunny Lisence.

Features:

- Exposed template vector and matrix types in 'glm' namespace #239, #244
- Added GTX_scalar_multiplication for C++ 11 compiler only #242
- Added GTX_range for C++ 11 compiler only #240
- Added closestPointOnLine function for tvec2 to GTX_closest_point #238
- Added GTC_vec1 extension, *vec1 support to *vec* types
- Updated GTX_associated_min_max with vec1 support
- Added support of precision and integers to linearRand #230
- Added Integer types support to GTX_string_cast #249
- Added vec3 slerp #237
- Added GTX_common with isdenomal #223
- Added GLM_FORCE_SIZE_FUNC to replace .length() by .size() #245
- Added GLM_FORCE_NO_CTOR_INIT
- Added 'uninitialize' to explicitly not initialize a GLM type
- Added GTC_bitfield extension, promoted GTX_bit
- Added GTC_integer extension, promoted GTX_bit and GTX_integer
- Added GTC_round extension, promoted GTX_bit
- Added GLM_FORCE_EXPLICIT_CTOR to require explicit type conversions #269
- Added GTX_type_aligned for aligned vector, matrix and quaternion types

Improvements:

- Rely on C++11 to implement isinf and isnan
- Removed GLM_FORCE_CUDA, Cuda is implicitly detected
- Separated Apple Clang and LLVM compiler detection
- Used pragma once
- Undetected C++ compiler automatically compile with GLM_FORCE_CXX98 and GLM_FORCE_PURE
- Added not function (from GLSL specification) on VC12
- Optimized bitfieldReverse and bitCount functions
- Optimized findLSB and findMSB functions
- Optimized matrix-vector multiple performance with Cuda #257, #258
- Reduced integer type redifinitions #233
- Rewrited of GTX_fast_trigonometry #264 #265
- Made types trivially copyable #263
- Removed iostream in GLM tests
- Used std features within GLM without redeclaring
- Optimized cot function #272
- Optimized sign function #272
- Added explicit cast from quat to mat3 and mat4 #275

Fixes:

- Fixed std::nextafter not supported with C++11 on Android #217
- Fixed missing value_type for dual quaternion
- Fixed return type of dual quaternion length
- Fixed infinite loop in isfinite function with GCC #221
- Fixed Visual Studio 14 compiler warnings
- Fixed implicit conversion from another tvec2 type to another tvec2 #241
- Fixed lack of consistency of quat and dualquat constructors
- Fixed uaddCarray #253
- Fixed float comparison warnings #270

Deprecation:

- Removed degrees for function parameters
- Removed GLM_FORCE_RADIANS, active by default
- Removed VC 2005 / 8 and 2008 / 9 support
- Removed GCC 3.4 to 4.5 support
- Removed LLVM GCC support
- Removed LLVM 2.6 to 2.9 support
- Removed CUDA 3.0 to 4.0 support

Enjoy!