Skip to content

3. Extensions

Giuseppe Barbieri edited this page Aug 7, 2017 · 2 revisions

3. Extensions

GLM extends the core GLSL feature set with extensions. These extensions include: quaternion, transformation, spline, matrix inverse, color spaces, etc.

Here a brief list:

3.1 bitfield

Fast bitfield operations on scalar and vector variables.

3.2 color space

Conversion between linear RGB and sRGB color spaces.

3.3 constants

Provide a list of built-in constants, such as PI or PIf

3.4 epsilon

Approximate equality comparisons for floating-point numbers, possibly with a user-defined epsilon.

3.5 functions

Useful functions, such as gauss

3.6 integer

Integer variants of core GLM functions.

3.7 matrix access

Functions to conveniently access the individual rows or columns of a matrix.

3.8 matrix integer

TODO

3.9 matrix inverse

Additional matrix inverse functions.

3.10 matrix transform

Matrix transformation functions that follow the OpenGL fixed-function conventions.

For example, the lookAt function generates a transformation matrix that projects world coordinates into eye coordinates suitable for projection matrices (e.g. perspective, ortho). See the OpenGL compatibility specifications for more information about the layout of these generated matrices.

The matrices generated by this extension use standard OpenGL fixed-function conventions. For example, the lookAt function generates a transform from world space into the specific eye space that the projective matrix functions (perspective, ortho, etc) are designed to expect. The OpenGL compatibility specifications define the particular layout of this eye space.

3.11 noise

Define 2D, 3D and 4D procedural noise functions.

glm.simplex(Vec2(x / 16f, y / 16f))

glm.simplex(Vec3(x / 16f, y / 16f, 0.5f))

glm.simplex(Vec4(x / 16f, y / 16f, 0.5f, 0.5f))

glm.perlin(Vec2(x / 16f, y / 16f))

glm.perlin(Vec3(x / 16.f, y / 16.f, 0.5f))

glm.perlin(Vec4(x / 16f, y / 16f, 0.5f, 0.5f)))

glm.perlin(Vec2(x / 16f, y / 16f), Vec2(2f))

glm.perlin(Vec3(x / 16f, y / 16f, 0.5f), Vec3(2f))

glm.perlin(Vec4(x / 16f, y / 16f, Vec2(0.5f)), vec4(2f))

3.12. packing

Convert scalar and vector types to and from packed formats, saving space at the cost of precision. However, packing a value into a format that it was previously unpacked from is guaranteed to be lossless.

3.13. quaternion

Quaternions and operations upon thereof.

3.14. random

Probability distributions in up to four dimensions.

Vec4(glm.linearRand(Vec2(-1), Vec2(1)), 0, 1)

Vec4(glm.circularRand(1f), 0, 1)

Vec4(glm.sphericalRand(1f), 1)

Vec4(glm.diskRand(1f), 0, 1)

Vec4(glm.ballRand(1f), 1)

Vec4(glm.gaussRand(Vec3(0), Vec3(1)), 1)