25/12/2013 GLM 0.9.5.0 released

GLM 0.9.5 is a pretty disruptive new branch due to ideas aiming at making GLM more robust. GLM being largely used by now, the purpose of this provisional release is to ensure that it won't be too disruptive for the community when comes the final release.

Replacing half based types by packing functions

First, GLM 0.9.5 removes the hvec* and the hmat* types. Half floats are useful but those types are the wrong abstraction because they let use believe that half floats are native types while they are not. For example, we can perform an addition between two hvec4 but the underlying implementation will simply convert each component to float, do the addition and convert back to half. There is probably better approach to do this addition, there is just none that will be as fast as if that instruction what supported by the CPUs. As a replacement, GLM 0.9.5 provides functions to explicitly perform the conversion from float to half and half to float with the functions packHalf1x16, unpackHalf1x16, packHalf4x16, unpackHalf4x16, included in the new GLM_GTC_packing extension and packHalf2x16, unpackHalf2x16 already available in the GLM 0.9.4 core implementation.

  • #include <glm/glm.hpp>// glm::vec4
  • #include <glm/gtc/packing.hpp>// glm::cross, glm::normalize
  • void func()
  • {
  • glm::uint64 const & PackedHalf4x16 = glm::packHalf4x16(glm::vec4(1.0, 0.5, 0.0, 1.0));
  • glm::uint64 const & PackedUnorm4x16 = glm::packUnorm4x16(glm::vec4(1.0, 0.5, 0.0, 1.0));
  • glm::uint32 const & PackedUnorm3x10_1x2 = glm::packUnorm3x10_1x2(glm::vec4(1.0, 0.5, 0.0, 1.0));
  • glm::uint32 const & PackedU3x10_1x2 = glm::packU3x10_1x2(glm::vec4(1.0, 0.5, 0.0, 1.0));
  • glm::uint32 const & PackedF2x11_1x10 = glm::packF2x11_1x10(glm::vec3(1.0, 0.5, 0.0));
  • }

Faster projects build using forward declaration

The problem with header only library is that they increase the compilation time of a program. One of the reason for not enabling the swizzle operators by default is that it generates a lot of code. A good strategy to avoid running in compilation time issues is to ensure that the code isn't a spaghetti plate, and relying on forward declarations. GLM 0.9.5 provides glm/fwd.hpp with a complete set of GLM types forward declarations.

  • // In a header file using GLM types
  • #include <glm/fwd.hpp>
  • // In a source file using GLM types
  • #include <glm/glm.hpp>

Furthermore, in previous version GLM switched from including <glm/ext.hpp> to include individual extensions. With GLM 0.9.5 we can use individual headers to include only the features we need. For example: <glm/vec3.hpp> for glm::vec3, <glm/mat4x4.hpp> for glm::mat4 or <glm/geometry.hpp> for all the functions of the geometry section of the GLSL specifications.

  • #include <glm/vec3.hpp>// glm::vec3
  • #include <glm/geometry.hpp>// glm::cross, glm::normalize
  • void computeNormal(triangle & Triangle)
  • {
  • glm::vec3 const & a = Triangle.Position[0];
  • glm::vec3 const & b = Triangle.Position[1];
  • glm::vec3 const & c = Triangle.Position[2];
  • Triangle.Normal = glm::normalize(glm::cross(c - a, b - a));
  • }

Updating my simple raytracer from GLM 0.9.4 to GLM 0.9.5, the project can be compiled in less than half the time.

Redefinition of the precision qualifier

GLM 0.9.4 exposes GLSL precision qualifiers by using different native types. For example mediump_float is actually a float type and highp_float is actually a double.

in GLM 0.9.5 the precision qualifier (lowp, mediump and highp) has been redefined and now express computation precision in term of ULPs. As a conscequence for example sizeof(glm::lowp_vec2), sizeof(glm::mediump_vec2) and sizeof(glm::highp_vec2) will always return the same values. However, the effective computation can be different. For example, the implementation of inversesqrt uses fast inverse square root for lowp.

Changelog:
  • Added forward declarations (glm/fwd.hpp) for faster compilations
  • Added per feature headers
  • Minimized GLM internal dependencies
  • Improved Intel Compiler detection
  • Added bitfieldInterleave and _mm_bit_interleave_si128 functions
  • Added GTX_scalar_relational
  • Added GTX_dual_quaternion
  • Added rotation function to GTX_quaternion (#22)
  • Added precision variation of each type
  • Added quaternion comparison functions
  • Fixed GTX_multiple for negative value
  • Removed GTX_ocl_type extension
  • Fixed post increment and decrement operators
  • Fixed perspective with zNear == 0 (#71)
  • Removed l-value swizzle operators
  • Cleaned up compiler detection code for unsupported compilers
  • Replaced C cast by C++ casts
  • Fixed .length() that should return a int and not a size_t
  • Added GLM_FORCE_SIZE_T_LENGTH and glm::length_t
  • Removed unnecessary conversions
  • Optimized packing and unpacking functions
  • Removed the normalization of the up argument of lookAt function (#114)
  • Added low precision specializations of inversesqrt
  • Fixed ldexp and frexp implementations
  • Increased assert coverage
  • Increased static_assert coverage
  • Replaced GLM traits by STL traits when possible
  • Allowed including individual core feature
  • Increased unit tests completness
  • Added creating of a quaternion from two vectors
  • Added C++11 initializer lists
  • Fixed umulExtended and imulExtended implementations for vector types (#76)
  • Fixed CUDA coverage for GTC extensions
  • Added GTX_io extension
  • Improved GLM messages enabled when defining GLM_MESSAGES
  • Hidden matrix _inverse function implementation detail into private section

Enjoy!

  • GLM 0.9.5.0: (ZIP, 4.1 MB) (7Z, 2.7 MB)
  • GLM 0.9.5 manual
  • GLM 0.9.5 api documentation
  • Submit a bug report
  • GLM 0.9.5.1 released >
    < GLI 0.5.0.0 released
    Copyright © Christophe Riccio 2002-2016 all rights reserved
    Designed for Chrome 9, Firefox 4, Opera 11 and Safari 5