README: Add chapter about alignment

This commit is contained in:
zorby
2025-01-04 11:48:55 +01:00
parent 7e51ed88e8
commit aae82c1d4a

View File

@@ -39,7 +39,7 @@
<br> <br>
<p align="center"> <p align="center">
Also known as <b>OpenGL Mathematics (glm) for C</b>, <b>cglm</b> provides fast and ergonomic math functions to ease graphics programming. It is community friendly feel free to report any bugs and issues you face. <br> A highly optimized 2D|3D math library. Also known as OpenGL Mathematics (glm) for C. <b>cglm</b> provides fast and ergonomic math functions to ease graphics programming. It is community friendly feel free to report any bugs and issues you face. <br>
<i>If you're using C++, you might want to check out <a href="https://github.com/g-truc/glm">GLM</a></i> <i>If you're using C++, you might want to check out <a href="https://github.com/g-truc/glm">GLM</a></i>
</p> </p>
@@ -96,6 +96,10 @@ vec2 vector;
glmc_vec2_zero(vector); glmc_vec2_zero(vector);
``` ```
### ❗ Alignment
While cglm by default aligns what's necessary, it is possible to disable this by defining `CGLM_ALL_UNALIGNED`. If you're targeting machines with any kind of SIMD support, make sure that all `vec4`, `mat4` and `mat2` arguments you pass to cglm functions are aligned to prevent unexpected crashes, alternatively use the unaligned versions if present.
### Struct API ### Struct API
The struct API works as follows (note the `s` suffix on types, `glms_` prefix on functions and `GLMS_` on constants): The struct API works as follows (note the `s` suffix on types, `glms_` prefix on functions and `GLMS_` on constants):