Dav1dde / gl3n

OpenGL Maths for D (not glm for D).
http://dav1dde.github.com/gl3n/
Other
103 stars 49 forks source link

column major layout for matrices ? #66

Closed extrawurst closed 8 years ago

extrawurst commented 8 years ago

is it supported or possible to implement without a great hassle? it is the layout that bgfx uses natively right now: https://github.com/bkaradzic/bgfx/issues/517

Dav1dde commented 8 years ago

This is the important line: https://github.com/Dav1dde/gl3n/blob/master/gl3n/linalg.d#L761

    /// Holds the matrix $(RED row-major) in memory.
    mt[cols][rows] matrix; // In C it would be mt[rows][cols], D does it like this: (mt[foo])[bar]
    alias matrix this;

I don't want to support row major and column major layouts, it already is too confusing for some people that gl3n actually uses row-major, also every access is hardcoded to row major.

You can maybe create a fake type which is column major in memory, but has the index-accesses overloaded to row major.

I don't know if you can trick mt[cols][rows] into a custom type instead of this 2 dimensional array, so you probably need to use a fork of gl3n :(.