09/03/2010 GLM FAQ

As part of GLM 0.9 development, I am rewriting the manual which include a FAQ. This is what I currently get, if you have more ideas don't hesitate to submit!

1. Why GLM follows GLSL specification and conventions?

Following GLSL conventions is a really strict policy of GLM. GLM has been designed following the idea that everyone does its own math library with his own conventions. The idea is that brilliant developers (the OpenGL ARB) worked together and agreed to make GLSL. Following GLSL conventions is a way to find consensus. Moreover, basically when a developer knows GLSL, he knows GLM.

2. Why vec4(x) * y doesn't build?

GLM follows GLSL semantic conventions and features. Indeed, a vector by a scalar product is supported. However, GLSL defines for example a vector of float by a float scalar but doesn’t support for example a vector of float by a double scalar. Value types must match.

  • vec4 v1;
  • vec4 v2;
  • dvec4 v3;
  • float s1;
  • double s2;
  • ...
  • v2 = v1 * s1; // OK
  • v2 = v1 * s2; // ERROR
  • v3 = v3 * s2; // OK
  • v2 = v1 * 2.0f; // OK
  • v2 = v1 * 2.0; // ERROR
  • v2 = v1 * 2; // ERROR

3.3. Would it be possible to add my feature?

YES. Every feature request could be added by submitting it here: https://sourceforge.net/apps/trac/glf/newticket

These requests would mainly take the form of extensions and if you provide an implementation, the feature will be added automatically in GLM release.

3.4. Does GLM run GLSL program?

No, GLM is a C++ implementation of a subset of GLSL.

3.5. Does a GLSL compiler build GLM codes?

Not directly but it can be easy to port. However, the difference between a shader and C++ program at software design level will probably make this idea unlikely or impossible.

3.6. Should I use GTX extensions?

GTX extensions are qualified to be experimental extensions. In GLM this means that these extensions might change from version to version without restriction. In practice, it doesn’t really change except time to time. GTC extensions are stabled, tested and perfectly reliable in time. Many GTX extensions extend GTC extensions and provide a way to explore features and implementations before becoming stable by a promotion as GTC extensions. This is fairly the way OpenGL features are developed through extensions.

3.7. Would it be possible to change GLM to do glVertex3fv(glm::vec3(0))?

It's possible to implement such thing in C++ with the implementation of the appropriate cast operator. In this example it's likely because it would result as a transparent cast. However, most of the time, it's really unlikely resulting of build with no error and programs running with unexpected behaviors.

GLM_GTX_type_ptr extension provide a safe solution:
  • glm::vec4 v(0);
  • glm::mat4 m(0);
  • glVertex3fv(glm::value_ptr(v));
  • glLoadMatrixfv(glm::value_ptr(m));
Another solution inspired by STL:
  • glm::vec4 v(0);
  • glm::mat4 m(0);
  • glVertex3fv(&v[0]);
  • glLoadMatrixfv(&m[0][0]);

3.8. Where can I ask my questions?

A good place is the OpenGL Toolkits forum on OpenGL.org: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=postlist&Board=10&page=1

3.9. Where can I report a bug?

Just like feature requests: https://sourceforge.net/apps/trac/glf/newticket

3.10. Where can I find the documentation of extensions?

The Doxygen generated documentation includes a complete list of all extensions available. Explore this documentation to get a complete view of all GLM capabilities! http://glm.g-truc.net/html/index.html

OpenGL 3.3 AND OpenGL 4.0 released at GDC 2010! >
< Using sRGB color space with OpenGL
Copyright Christophe Riccio 2002-2016 all rights reserved
Designed for Chrome 9, Firefox 4, Opera 11 and Safari 5