Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
nalgebra-glm: Features to match GLM_FORCE_DEPTH_ZERO_TO_ONE and GLM_FORCE_LEFT_HANDED #505
The C++ GLM library has some preprocessor macros to change the default handedness and depth range conventions. This is immensely helpful when using GLM for DirectX or Vulkan which use different NDC coordinate systems and hence require different projection matrices and handedness conventions to be used.
Unfortunately I found this library didn't have any matching construct yet, and hadn't implemented the functions for creating projection matrices for those other conventions.
What I have done is 1:1 port of the projection matrix generation code from the matching GLM functions (
Care was taken to ensure that existing code should not be broken by the changes made. The default features enabled in the Cargo.toml ensure that nalgebra-glm will still produce the same results from the modified functions prior to my changes, and that the matrices generated by the new code match those created by the underlying nalgebra library (enforced by tests).
This should be a non-breaking change.
The added compile options are documented on nalgebra-glm's main page as well as on the functions which behavior they alter (where it explains what behavior it changes).
What I have added:
That's a good point. In that case it would definitely cause problems, although this solution is the only way that I can think of that would allow configuring it with conditional compilation. I'd say then it would probably just be better to cherry pick all the function implementations I added and reset the modified functions back to use their default implementation to avoid misusing cargo features
I just went through and fixed all of the changes requested
I probably should've realized I was just making an identity matrix and used that, but I was porting behavior of one of GLM's mat4 constructors and didn't put two and two together at the time
All the docs referencing the compile features have been removed as they are no longer needed and all the functions I touched have had their docs updated to specify the handedness and depth range for the matrix/quaternion they produce.
It's currently set up to lean towards nalgebra/OpenGL conventions wherever possible (