GlmNet is a .NET version of the excellent OpenGL Mathematics library (GLM).
Important: I am developing GlmNet as I need it - so there are very few advanced features from GLM ported over yet. Please do feel free to fork the code and add the features as you need them - if you create pull requests I'll merge them into the main branch.
Install it with Nuget:
PM> Install-Package GlmNet
That's all there is to it!
GlmNet attempts to be as syntactically similar to GLM as possible. Examples are:
mat4 projectionMatrix = glm.perspective(rads, (float)Width / (float)Height, 0.1f, 100.0f); mat4 viewMatrix = glm.translate(new mat4(1.0f), new vec3(0.0f, 0.0f, -5.0f)); mat4 modelMatrix = glm.scale(new mat4(1.0f), new vec3(0.5f));
Column Major Matrices
GLM.NET matrices are Column Major. This is because GLM attempts to mimic GLSL as closely as possible.
| a b c | | d e f | = |M| | g h i |
M gives column 0, i.e:
| a | | d | | g |
M or M[1,2] gives column 1, row 2, i.e:
Column major matrices are used in OpenGL, row major in DirectX. Many C++ libraries are row major, be aware that GLM.NET is column major. This means that as OpenGL vectors are typically columns, you multiply in the order matrix * vector:
a = m * v
v * m.
Matrices are NOT initialised to the identity. Use the
All types are based on floats.
Matrix elements are references as multidimensional arrays when you want to change them, e.g:
// Get data from matrices like this: var element = matrix; // ..or this.. var element = matrix[1,2]; // But SET data in a matrix like this: matrix[1,2] = element;
All angles in GlmNet are expected to be in radians - no conversion to or from degrees is ever done.
glm - A copy of the latest version of the OpenGL Mathematics library. source - The sourcecode for GLMNET.
Angle and Trigonometry Functions
GTC Extensions (Stable)
All functions are supported. Angles are always in radians.
- Matrix * Matrix
- Matrix * Vector