ziglibs / zlm

Zig linear mathemathics
MIT License
171 stars 26 forks source link

Column major matrices #22

Open glyh opened 3 months ago

glyh commented 3 months ago

OpenGL uses column major matrics so in order to combo well with OpenGL I suppose it would be nice to have a column major version of matrices?

ikskuh commented 3 months ago

The matrixes should work out of the box as-is with OpenGL. Did you encounter any problems?

glyh commented 3 months ago

We're using row major matrices AFAIK, so computation does not work seemlessly with openGL.

For example, there's an old demo of someone using zlm to replcate learnopengl tutorial's lesson on transformation.

Here's the code.

Pay attention to this line:

https://github.com/Flecart/zig-learnopengl/blob/2bd30f3286a99c825023bcec2199dba770b8315a/src/chapter-5/5.1.zig#L195

You see the order of multiplication is incorrect. But exchanging the order yields the wrong result.