Cglm Versions Save

📽 Highly Optimized 2D / 3D Graphics Math (glm) for C

v0.9.4

3 weeks ago

🐞bug fixes

Non-Square matrices are fixed ( many thanks to @EasyIP2023 ). Also now SSE can work without SSE2 which may not available on 32bit devices e.g. i686. Some fast math issues also fixed. Func param name conflicts with a macro, again! Now fixed.

In this release lot of critic bugs are fixed. Feel free to report any bugs, we are here for them 🐛

🛠️ Bugfixes and Improvements:

Known or Possible Issues for Next Versions:

❤️ Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.9.3

1 month ago

🎓 ray, struct and ci

Now we have some missing functionalities:

📌 ray sphere intersection, reflect, refract, face forward 📌 additional CI via GitHub Actions ( many thanks to @waywardmonkeys ) 📌 struct API for ivec2, ivec3, and ivec4 ( many thanks to @tarhses ) 📌 struct API improvements ( many thanks to @duarm, @waywardmonkeys ) 📌 add new functions for ivec2 and ivec3 ( many thanks to @vitassuper )

  • glm_ray_sphere(origin, dir, s, &t1, &t2)) -> bool ray sphere intersection
  • glm_ray_at(orig, dir, t, &point) point by parameter
  • glm_vec3_faceforward(N, I, Nref, dest)
  • glm_vec[2|3|4]_reflect(I, N, &dest) reflect
  • glm_vec[2|3|4]_refract(I, N, eta, &dest) refract

glm_ray_sphere():

  • t1 > 0, t2 > 0: ray intersects the sphere at t1 and t2 both ahead of the origin
  • t1 < 0, t2 > 0: ray starts inside the sphere, exits at t2
  • t1 < 0, t2 < 0: no intersection ahead of the ray
  • the caller can check if the intersection points (t1 and t2) fall within a specific range (for example, tmin < t1, t2 < tmax) to determine if the intersections are within a desired segment of the ray

and many others improvements and bug fixes, thanks to those who help to make the library more robust and better than before.

🛠️ Bugfixes and Improvements:

Known or Possible Issues for Next Versions:

❤️ Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.9.2

3 months ago

🎓 aabb2d and euler to quat

Now we have some missing functionalities:

📌 aabb2d ( many thanks to @duarm ) 📌 euler to quat functionality ( many thanks to @telephone001 ) 📌 new subtraction family of vector functions ( many thanks to @BeeverFeever )

and many others improvements and bugfixes, thanks to @v1993, @myfreeer, @gottfriedleibniz and others to make the library more robust and better than before.

🛠️ Bugfixes and Improvements:

Known or Possible Issues for Next Versions:

❤️ Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.9.1

8 months ago

🎓 New Matrix Types

📌 Now we have mat2x3, mat2x4, mat3x2, mat3x4, mat4x2 and mat4x3 types and its functions ( many thanks to @EasyIP2023 )

Each one has its own header e.g mat3x4.h, including one of them:

  • cglm/cglm.h
  • cglm/call.h
  • cglm/struct.h

will include all matrix headers. Feel free to share any bugs found to fix them.


🛠️ Bugfixes and Improvements:

Known or Possible Issues for Next Versions:

❤️ Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.9.0

11 months ago

🚀 WASM 123 SIMD Support

Now we have WASM 128 SIMD support ( many thanks to @myfreeer ).

Compiling

Currently the tests can be cross-compiled to wasi using clang and wasi-sdk with cmake arguments below:

-DCMAKE_C_FLAGS="-msimd128"
-DCMAKE_TOOLCHAIN_FILE=/path/to/wasi-sdk-19.0/share/cmake/wasi-sdk.cmake
-DWASI_SDK_PREFIX=/path/to/wasi-sdk-19.0
-DCGLM_USE_TEST=ON

Where /path/to/wasi-sdk-19.0/ is the path to extracted wasi sdk.

🚀 Struct API Namespace Configuration

Now we can omit or change namespace of struct api which was ( and still as default ) glms_. We can omit the namespace completely to use like mat4_mul(mat4_mul(m1, m2), m3) ... or option to use like mat4s_mul(mat4s_mul(m1, m2), m3)...

This makes things more flexible & readable for struct api.

now we can omit glms_ like:

/* previous / default */
return glms_vec3_normalized(glms_vec3_cross(a, b));

/* this must be defined before cglm inc especially common.h */
#define CGLM_OMIT_NS_FROM_STRUCT_API /* or define at compiler settings */

/* new!! */
return vec3_normalized(vec3_cross(a, b));

/* if CGLM_STRUCT_API_NAME_SUFFIX is defined as `s`  */
return vec3s_normalized(vec3s_cross(a, b));

new options:

  • CGLM_OMIT_NS_FROM_STRUCT_API, omits CGLM_STRUCT_API_NS (glms_) namespace completely if there is sub namespace e.g mat4_, vec4_ ... DEFAULT is not defined
  • CGLM_STRUCT_API_NS: define name space for struct api, DEFAULT is glms
  • CGLM_STRUCT_API_NAME_SUFFIX: define name suffix, DEFAULT is empty e.g defining it as #define CGLM_STRUCT_API_NAME_SUFFIX s will add s suffix to mat4_mul -> mat4s_mul

🛠️ Bugfixes and Improvements:

❤️ Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.8.9

1 year ago

Bugfixes and Improvements:

Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.8.8

1 year ago

New features:

Bugfixes and Improvements:

Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.8.7

1 year ago

Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.8.6

1 year ago

Now we have post transform functions which is similar to existing transform function but with different multiplication order.

New Features


new affine functions:

  • CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis): rotates existing transform around itself by with axis. this helps to rotate object around itself without moving manually or providing a pivot for glm_rotate_at() to rotate around itself

Current implementations apply transforms to vector first, but sometimes we may need to apply rotations as last transform, cglm introduces post-transform operations e.g. apply rotation/translate last instead of first to vector.

Post transform function have similar names with existing ones with ed suffix:

  • CGLM_INLINE void glm_translated_to(mat4 m, vec3 v, mat4 dest)
  • CGLM_INLINE void glm_translated(mat4 m, vec3 v)
  • CGLM_INLINE void glm_translated_x(mat4 m, float to)
  • CGLM_INLINE void glm_translated_y(mat4 m, float to)
  • CGLM_INLINE void glm_translated_z(mat4 m, float to)
  • CGLM_INLINE void glm_rotated_x(mat4 m, float angle, mat4 dest)
  • CGLM_INLINE void glm_rotated_y(mat4 m, float angle, mat4 dest)
  • CGLM_INLINE void glm_rotated_z(mat4 m, float angle, mat4 dest)
  • CGLM_INLINE void glm_rotated(mat4 m, float angle, vec3 axis)
  • CGLM_INLINE void glm_rotated_at(mat4 m, vec3 pivot, float angle, vec3 axis)
  • CGLM_INLINE void glm_spinned(mat4 m, float angle, vec3 axis)

new project functions:

  • CGLM_INLINE float glm_project_z(vec3 pos, mat4 m) - map object's z coordinate to window coordinates
  • CGLM_INLINE float glm_project_z_no(vec3 pos, mat4 m)
  • CGLM_INLINE float glm_project_z_zo(vec3 pos, mat4 m)

new ivec functions ( thanks to @Chris-F5 ):

void  glm_ivec2(int * __restrict v, ivec2 dest);
void  glm_ivec2_copy(ivec2 a, ivec2 dest);
void  glm_ivec2_zero(ivec2 v);
void  glm_ivec2_one(ivec2 v);
void  glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest);
void  glm_ivec2_adds(ivec2 v, int s, ivec2 dest);
void  glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest);
void  glm_ivec2_subs(ivec2 v, int s, ivec2 dest);
void  glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest);
void  glm_ivec2_scale(ivec2 v, int s, ivec2 dest);
int   glm_ivec2_distance2(ivec2 a, ivec2 b);
float glm_ivec2_distance(ivec2 a, ivec2 b);
void  glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest);
void  glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest);
void  glm_ivec2_clamp(ivec2 v, int minVal, int maxVal);

void  glm_ivec3(ivec4 v4, ivec3 dest);
void  glm_ivec3_copy(ivec3 a, ivec3 dest);
void  glm_ivec3_zero(ivec3 v);
void  glm_ivec3_one(ivec3 v);
void  glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest);
void  glm_ivec3_adds(ivec3 v, int s, ivec3 dest);
void  glm_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest);
void  glm_ivec3_subs(ivec3 v, int s, ivec3 dest);
void  glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest);
void  glm_ivec3_scale(ivec3 v, int s, ivec3 dest);
int   glm_ivec3_distance2(ivec3 a, ivec3 b);
float glm_ivec3_distance(ivec3 a, ivec3 b);
void  glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest);
void  glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest);
void  glm_ivec3_clamp(ivec3 v, int minVal, int maxVal);

void  glm_ivec4(ivec3 v3, int last, ivec4 dest);
void  glm_ivec4_copy(ivec4 a, ivec4 dest);
void  glm_ivec4_zero(ivec4 v);
void  glm_ivec4_one(ivec4 v);
void  glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest);
void  glm_ivec4_adds(ivec4 v, int s, ivec4 dest);
void  glm_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest);
void  glm_ivec4_subs(ivec4 v, int s, ivec4 dest);
void  glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest);
void  glm_ivec4_scale(ivec4 v, int s, ivec4 dest);
int   glm_ivec4_distance2(ivec4 a, ivec4 b);
float glm_ivec4_distance(ivec4 a, ivec4 b);
void  glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest);
void  glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest);
void  glm_ivec4_clamp(ivec4 v, int minVal, int maxVal);

Bugfixes and Improvements:

Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://github.com/sponsors/recp https://opencollective.com/cglm#backer https://patreon.com/recp

v0.8.5

2 years ago

Bugfixes and Improvements:

Sponsorship: Consider become a sponsor for cglm

Supporting cross platform, multiple OS-es and multiple CPUs requires multiple hardwares to test on it which requires extra financial cost. Also sparing time is another big issue while working at somewhere fulltime... Your company can become a sponsor to help:

https://opencollective.com/cglm#backer