diff --git a/CMakeLists.txt b/CMakeLists.txt index 396e45b..7a6fd85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,9 @@ add_library(${PROJECT_NAME} src/vec2.c src/vec3.c src/vec4.c + src/ivec2.c + src/ivec3.c + src/ivec4.c src/mat2.c src/mat3.c src/mat4.c diff --git a/docs/source/api.rst b/docs/source/api.rst index 67e0fb0..7ffb823 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -34,15 +34,18 @@ Follow the :doc:`build` documentation for this box quat euler - mat4 - mat3 mat2 + mat3 + mat4 + vec2 + vec2-ext vec3 vec3-ext vec4 vec4-ext - vec2 - vec2-ext + ivec2 + ivec3 + ivec4 color plane project diff --git a/docs/source/index.rst b/docs/source/index.rst index a01c96b..34a71c4 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -13,8 +13,6 @@ It is similar to the original **glm** library, except **cglm** is mainly for **cglm** stores matrices as column-major order but in the future row-major is considered to be supported as optional. -Currently only **float** type is supported for most operations. - .. toctree:: :maxdepth: 2 :caption: Getting Started: diff --git a/docs/source/ivec2.rst b/docs/source/ivec2.rst new file mode 100644 index 0000000..c10bc4c --- /dev/null +++ b/docs/source/ivec2.rst @@ -0,0 +1,163 @@ +.. default-domain:: C + +ivec2 +===== + +Header: cglm/ivec2.h + +Table of contents (click to go): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Functions: + +1. :c:func:`glm_ivec2` +#. :c:func:`glm_ivec2_copy` +#. :c:func:`glm_ivec2_zero` +#. :c:func:`glm_ivec2_one` +#. :c:func:`glm_ivec2_add` +#. :c:func:`glm_ivec2_adds` +#. :c:func:`glm_ivec2_sub` +#. :c:func:`glm_ivec2_subs` +#. :c:func:`glm_ivec2_mul` +#. :c:func:`glm_ivec2_scale` +#. :c:func:`glm_ivec2_distance2` +#. :c:func:`glm_ivec2_distance` +#. :c:func:`glm_ivec2_maxv` +#. :c:func:`glm_ivec2_minv` +#. :c:func:`glm_ivec2_clamp` + +Functions documentation +~~~~~~~~~~~~~~~~~~~~~~~ + +.. c:function:: void glm_ivec2(int * v, ivec2 dest) + + init ivec2 using vec3 or vec4 + + Parameters: + | *[in]* **v** vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_copy(ivec2 a, ivec2 dest) + + copy all members of [a] to [dest] + + Parameters: + | *[in]* **a** source vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_zero(ivec2 v) + + set all members of [v] to zero + + Parameters: + | *[out]* **v** vector + +.. c:function:: void glm_ivec2_one(ivec2 v) + + set all members of [v] to one + + Parameters: + | *[out]* **v** vector + +.. c:function:: void glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) + + add vector [a] to vector [b] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_adds(ivec2 v, int s, ivec2 dest) + + add scalar s to vector [v] and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) + + subtract vector [b] from vector [a] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_subs(ivec2 v, int s, ivec2 dest) + + subtract scalar s from vector [v] and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest) + + multiply vector [a] with vector [b] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_scale(ivec2 v, int s, ivec2 dest) + + multiply vector [a] with scalar s and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: int glm_ivec2_distance2(ivec2 a, ivec2 b) + + squared distance between two vectors + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + + Returns: + squared distance (distance * distance) + +.. c:function:: float glm_ivec2_distance(ivec2 a, ivec2 b) + + distance between two vectors + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + + Returns: + distance + +.. c:function:: void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) + + set each member of dest to greater of vector a and b + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) + + set each member of dest to lesser of vector a and b + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) + + clamp each member of [v] between minVal and maxVal (inclusive) + + Parameters: + | *[in, out]* **v** vector + | *[in]* **minVal** minimum value + | *[in]* **maxVal** maximum value diff --git a/docs/source/ivec3.rst b/docs/source/ivec3.rst new file mode 100644 index 0000000..312078a --- /dev/null +++ b/docs/source/ivec3.rst @@ -0,0 +1,163 @@ +.. default-domain:: C + +ivec3 +===== + +Header: cglm/ivec3.h + +Table of contents (click to go): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Functions: + +1. :c:func:`glm_ivec3` +#. :c:func:`glm_ivec3_copy` +#. :c:func:`glm_ivec3_zero` +#. :c:func:`glm_ivec3_one` +#. :c:func:`glm_ivec3_add` +#. :c:func:`glm_ivec3_adds` +#. :c:func:`glm_ivec3_sub` +#. :c:func:`glm_ivec3_subs` +#. :c:func:`glm_ivec3_mul` +#. :c:func:`glm_ivec3_scale` +#. :c:func:`glm_ivec3_distance2` +#. :c:func:`glm_ivec3_distance` +#. :c:func:`glm_ivec3_maxv` +#. :c:func:`glm_ivec3_minv` +#. :c:func:`glm_ivec3_clamp` + +Functions documentation +~~~~~~~~~~~~~~~~~~~~~~~ + +.. c:function:: void glm_ivec3(ivec4 v4, ivec3 dest) + + init ivec3 using ivec4 + + Parameters: + | *[in]* **v** vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_copy(ivec3 a, ivec3 dest) + + copy all members of [a] to [dest] + + Parameters: + | *[in]* **a** source vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_zero(ivec3 v) + + set all members of [v] to zero + + Parameters: + | *[out]* **v** vector + +.. c:function:: void glm_ivec3_one(ivec3 v) + + set all members of [v] to one + + Parameters: + | *[out]* **v** vector + +.. c:function:: void glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) + + add vector [a] to vector [b] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_adds(ivec3 v, int s, ivec3 dest) + + add scalar s to vector [v] and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest) + + subtract vector [b] from vector [a] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_subs(ivec3 v, int s, ivec3 dest) + + subtract scalar s from vector [v] and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest) + + multiply vector [a] with vector [b] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_scale(ivec3 v, int s, ivec3 dest) + + multiply vector [a] with scalar s and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: int glm_ivec3_distance2(ivec3 a, ivec3 b) + + squared distance between two vectors + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + + Returns: + squared distance (distance * distance) + +.. c:function:: float glm_ivec3_distance(ivec3 a, ivec3 b) + + distance between two vectors + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + + Returns: + distance + +.. c:function:: void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) + + set each member of dest to greater of vector a and b + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) + + set each member of dest to lesser of vector a and b + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) + + clamp each member of [v] between minVal and maxVal (inclusive) + + Parameters: + | *[in, out]* **v** vector + | *[in]* **minVal** minimum value + | *[in]* **maxVal** maximum value diff --git a/docs/source/ivec4.rst b/docs/source/ivec4.rst new file mode 100644 index 0000000..a175631 --- /dev/null +++ b/docs/source/ivec4.rst @@ -0,0 +1,163 @@ +.. default-domain:: C + +ivec4 +===== + +Header: cglm/ivec4.h + +Table of contents (click to go): +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Functions: + +1. :c:func:`glm_ivec4` +#. :c:func:`glm_ivec4_copy` +#. :c:func:`glm_ivec4_zero` +#. :c:func:`glm_ivec4_one` +#. :c:func:`glm_ivec4_add` +#. :c:func:`glm_ivec4_adds` +#. :c:func:`glm_ivec4_sub` +#. :c:func:`glm_ivec4_subs` +#. :c:func:`glm_ivec4_mul` +#. :c:func:`glm_ivec4_scale` +#. :c:func:`glm_ivec4_distance2` +#. :c:func:`glm_ivec4_distance` +#. :c:func:`glm_ivec4_maxv` +#. :c:func:`glm_ivec4_minv` +#. :c:func:`glm_ivec4_clamp` + +Functions documentation +~~~~~~~~~~~~~~~~~~~~~~~ + +.. c:function:: void glm_ivec4(ivec3 v3, int last, ivec4 dest) + + init ivec4 using ivec3 + + Parameters: + | *[in]* **v** vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_copy(ivec4 a, ivec4 dest) + + copy all members of [a] to [dest] + + Parameters: + | *[in]* **a** source vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_zero(ivec4 v) + + set all members of [v] to zero + + Parameters: + | *[out]* **v** vector + +.. c:function:: void glm_ivec4_one(ivec4 v) + + set all members of [v] to one + + Parameters: + | *[out]* **v** vector + +.. c:function:: void glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) + + add vector [a] to vector [b] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_adds(ivec4 v, int s, ivec4 dest) + + add scalar s to vector [v] and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest) + + subtract vector [b] from vector [a] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_subs(ivec4 v, int s, ivec4 dest) + + subtract scalar s from vector [v] and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest) + + multiply vector [a] with vector [b] and store result in [dest] + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_scale(ivec4 v, int s, ivec4 dest) + + multiply vector [a] with scalar s and store result in [dest] + + Parameters: + | *[in]* **v** vector + | *[in]* **s** scalar + | *[out]* **dest** destination + +.. c:function:: int glm_ivec4_distance2(ivec4 a, ivec4 b) + + squared distance between two vectors + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + + Returns: + squared distance (distance * distance) + +.. c:function:: float glm_ivec4_distance(ivec4 a, ivec4 b) + + distance between two vectors + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + + Returns: + distance + +.. c:function:: void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) + + set each member of dest to greater of vector a and b + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) + + set each member of dest to lesser of vector a and b + + Parameters: + | *[in]* **a** first vector + | *[in]* **b** second vector + | *[out]* **dest** destination + +.. c:function:: void glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) + + clamp each member of [v] between minVal and maxVal (inclusive) + + Parameters: + | *[in, out]* **v** vector + | *[in]* **minVal** minimum value + | *[in]* **maxVal** maximum value diff --git a/include/cglm/call.h b/include/cglm/call.h index ffb3532..734bd46 100644 --- a/include/cglm/call.h +++ b/include/cglm/call.h @@ -15,6 +15,9 @@ extern "C" { #include "call/vec2.h" #include "call/vec3.h" #include "call/vec4.h" +#include "call/ivec2.h" +#include "call/ivec3.h" +#include "call/ivec4.h" #include "call/mat2.h" #include "call/mat3.h" #include "call/mat4.h" diff --git a/include/cglm/call/ivec2.h b/include/cglm/call/ivec2.h new file mode 100644 index 0000000..d3b8fd2 --- /dev/null +++ b/include/cglm/call/ivec2.h @@ -0,0 +1,79 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#ifndef cglmc_ivec2_h +#define cglmc_ivec2_h +#ifdef __cplusplus +extern "C" { +#endif + +#include "../cglm.h" + +CGLM_EXPORT +void +glmc_ivec2(int * __restrict v, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_copy(ivec2 a, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_zero(ivec2 v); + +CGLM_EXPORT +void +glmc_ivec2_one(ivec2 v); + +CGLM_EXPORT +void +glmc_ivec2_add(ivec2 a, ivec2 b, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_adds(ivec2 v, int s, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_subs(ivec2 v, int s, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_scale(ivec2 v, int s, ivec2 dest); + +CGLM_EXPORT +int +glmc_ivec2_distance2(ivec2 a, ivec2 b); + +CGLM_EXPORT +float +glmc_ivec2_distance(ivec2 a, ivec2 b); + +CGLM_EXPORT +void +glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest); + +CGLM_EXPORT +void +glmc_ivec2_clamp(ivec2 v, int minVal, int maxVal); + +#ifdef __cplusplus +} +#endif +#endif /* cglmc_ivec2_h */ diff --git a/include/cglm/call/ivec3.h b/include/cglm/call/ivec3.h new file mode 100644 index 0000000..3c28811 --- /dev/null +++ b/include/cglm/call/ivec3.h @@ -0,0 +1,79 @@ +/* + * Copyright (c);, Recep Aslantas. + * + * MIT License (MIT);, http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#ifndef cglmc_ivec3_h +#define cglmc_ivec3_h +#ifdef __cplusplus +extern "C" { +#endif + +#include "../cglm.h" + +CGLM_EXPORT +void +glmc_ivec3(ivec4 v4, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_copy(ivec3 a, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_zero(ivec3 v); + +CGLM_EXPORT +void +glmc_ivec3_one(ivec3 v); + +CGLM_EXPORT +void +glmc_ivec3_add(ivec3 a, ivec3 b, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_adds(ivec3 v, int s, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_subs(ivec3 v, int s, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_scale(ivec3 v, int s, ivec3 dest); + +CGLM_EXPORT +int +glmc_ivec3_distance2(ivec3 a, ivec3 b); + +CGLM_EXPORT +float +glmc_ivec3_distance(ivec3 a, ivec3 b); + +CGLM_EXPORT +void +glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest); + +CGLM_EXPORT +void +glmc_ivec3_clamp(ivec3 v, int minVal, int maxVal); + +#ifdef __cplusplus +} +#endif +#endif /* cglmc_ivec3_h */ diff --git a/include/cglm/call/ivec4.h b/include/cglm/call/ivec4.h new file mode 100644 index 0000000..79e11b1 --- /dev/null +++ b/include/cglm/call/ivec4.h @@ -0,0 +1,79 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#ifndef cglmc_ivec4_h +#define cglmc_ivec4_h +#ifdef __cplusplus +extern "C" { +#endif + +#include "../cglm.h" + +CGLM_EXPORT +void +glmc_ivec4(ivec3 v3, int last, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_copy(ivec4 a, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_zero(ivec4 v); + +CGLM_EXPORT +void +glmc_ivec4_one(ivec4 v); + +CGLM_EXPORT +void +glmc_ivec4_add(ivec4 a, ivec4 b, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_adds(ivec4 v, int s, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_subs(ivec4 v, int s, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_scale(ivec4 v, int s, ivec4 dest); + +CGLM_EXPORT +int +glmc_ivec4_distance2(ivec4 a, ivec4 b); + +CGLM_EXPORT +float +glmc_ivec4_distance(ivec4 a, ivec4 b); + +CGLM_EXPORT +void +glmc_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest); + +CGLM_EXPORT +void +glmc_ivec4_clamp(ivec4 v, int minVal, int maxVal); + +#ifdef __cplusplus +} +#endif +#endif /* cglmc_ivec4_h */ diff --git a/include/cglm/cglm.h b/include/cglm/cglm.h index 5ff3421..1828cb4 100644 --- a/include/cglm/cglm.h +++ b/include/cglm/cglm.h @@ -12,6 +12,9 @@ #include "vec2.h" #include "vec3.h" #include "vec4.h" +#include "ivec2.h" +#include "ivec3.h" +#include "ivec4.h" #include "mat4.h" #include "mat3.h" #include "mat2.h" diff --git a/include/cglm/ivec2.h b/include/cglm/ivec2.h new file mode 100644 index 0000000..c1209a9 --- /dev/null +++ b/include/cglm/ivec2.h @@ -0,0 +1,242 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +/* +FUNCTIONS: + CGLM_INLINE void glm_ivec2(int * __restrict v, ivec2 dest) + CGLM_INLINE void glm_ivec2_copy(ivec2 a, ivec2 dest) + CGLM_INLINE void glm_ivec2_zero(ivec2 v) + CGLM_INLINE void glm_ivec2_one(ivec2 v) + CGLM_INLINE void glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) + CGLM_INLINE void glm_ivec2_adds(ivec2 v, int s, ivec2 dest) + CGLM_INLINE void glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) + CGLM_INLINE void glm_ivec2_subs(ivec2 v, int s, ivec2 dest) + CGLM_INLINE void glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest) + CGLM_INLINE void glm_ivec2_scale(ivec2 v, int s, ivec2 dest) + CGLM_INLINE int glm_ivec2_distance2(ivec2 a, ivec2 b) + CGLM_INLINE float glm_ivec2_distance(ivec2 a, ivec2 b) + CGLM_INLINE void glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) + CGLM_INLINE void glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) + CGLM_INLINE void glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) + */ + +#ifndef cglm_ivec2_h +#define cglm_ivec2_h + +#include "common.h" + +/*! + * @brief init ivec2 using vec3 or vec4 + * + * @param[in] v vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2(int * __restrict v, ivec2 dest) { + dest[0] = v[0]; + dest[1] = v[1]; +} + +/*! + * @brief copy all members of [a] to [dest] + * + * @param[in] a source vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_copy(ivec2 a, ivec2 dest) { + dest[0] = a[0]; + dest[1] = a[1]; +} + +/*! + * @brief set all members of [v] to zero + * + * @param[out] v vector + */ +CGLM_INLINE +void +glm_ivec2_zero(ivec2 v) { + v[0] = v[1] = 0; +} + +/*! + * @brief set all members of [v] to one + * + * @param[out] v vector + */ +CGLM_INLINE +void +glm_ivec2_one(ivec2 v) { + v[0] = v[1] = 1; +} + +/*! + * @brief add vector [a] to vector [b] and store result in [dest] + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) { + dest[0] = a[0] + b[0]; + dest[1] = a[1] + b[1]; +} + +/*! + * @brief add scalar s to vector [v] and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_adds(ivec2 v, int s, ivec2 dest) { + dest[0] = v[0] + s; + dest[1] = v[1] + s; +} + +/*! + * @brief subtract vector [b] from vector [a] and store result in [dest] + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) { + dest[0] = a[0] - b[0]; + dest[1] = a[1] - b[1]; +} + +/*! + * @brief subtract scalar s from vector [v] and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_subs(ivec2 v, int s, ivec2 dest) { + dest[0] = v[0] - s; + dest[1] = v[1] - s; +} + +/*! + * @brief multiply vector [a] with vector [b] and store result in [dest] + * + * @param[in] a frist vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest) { + dest[0] = a[0] * b[0]; + dest[1] = a[1] * b[1]; +} + +/*! + * @brief multiply vector [a] with scalar s and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_scale(ivec2 v, int s, ivec2 dest) { + dest[0] = v[0] * s; + dest[1] = v[1] * s; +} + +/*! + * @brief squared distance between two vectors + * + * @param[in] a first vector + * @param[in] b second vector + * @return returns squared distance (distance * distance) + */ +CGLM_INLINE +int +glm_ivec2_distance2(ivec2 a, ivec2 b) { + int xd, yd; + xd = a[0] - b[0]; + yd = a[1] - b[1]; + return xd * xd + yd * yd; +} + +/*! + * @brief distance between two vectors + * + * @param[in] a first vector + * @param[in] b second vector + * @return returns distance + */ +CGLM_INLINE +float +glm_ivec2_distance(ivec2 a, ivec2 b) { + return sqrtf((float)glm_ivec2_distance2(a, b)); +} + +/*! + * @brief set each member of dest to greater of vector a and b + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) { + dest[0] = a[0] > b[0] ? a[0] : b[0]; + dest[1] = a[1] > b[1] ? a[1] : b[1]; +} + +/*! + * @brief set each member of dest to lesser of vector a and b + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) { + dest[0] = a[0] < b[0] ? a[0] : b[0]; + dest[1] = a[1] < b[1] ? a[1] : b[1]; +} + +/*! + * @brief clamp each member of [v] between minVal and maxVal (inclusive) + * + * @param[in, out] v vector + * @param[in] minVal minimum value + * @param[in] maxVal maximum value + */ +CGLM_INLINE +void +glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) { + if (v[0] < minVal) + v[0] = minVal; + else if(v[0] > maxVal) + v[0] = maxVal; + + if (v[1] < minVal) + v[1] = minVal; + else if(v[1] > maxVal) + v[1] = maxVal; +} + +#endif /* cglm_ivec2_h */ diff --git a/include/cglm/ivec3.h b/include/cglm/ivec3.h new file mode 100644 index 0000000..69f27f3 --- /dev/null +++ b/include/cglm/ivec3.h @@ -0,0 +1,258 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +/* +FUNCTIONS: + CGLM_INLINE void glm_ivec3(ivec4 v4, ivec3 dest) + CGLM_INLINE void glm_ivec3_copy(ivec3 a, ivec3 dest) + CGLM_INLINE void glm_ivec3_zero(ivec3 v) + CGLM_INLINE void glm_ivec3_one(ivec3 v) + CGLM_INLINE void glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) + CGLM_INLINE void glm_ivec3_adds(ivec3 v, int s, ivec3 dest) + CGLM_INLINE void glm_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest) + CGLM_INLINE void glm_ivec3_subs(ivec3 v, int s, ivec3 dest) + CGLM_INLINE void glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest) + CGLM_INLINE void glm_ivec3_scale(ivec3 v, int s, ivec3 dest) + CGLM_INLINE int glm_ivec3_distance2(ivec3 a, ivec3 b) + CGLM_INLINE float glm_ivec3_distance(ivec3 a, ivec3 b) + CGLM_INLINE void glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) + CGLM_INLINE void glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) + CGLM_INLINE void glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) + */ + +#ifndef cglm_ivec3_h +#define cglm_ivec3_h + +#include "common.h" + +/*! + * @brief init ivec3 using ivec4 + * + * @param[in] v4 vector4 + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3(ivec4 v4, ivec3 dest) { + dest[0] = v4[0]; + dest[1] = v4[1]; + dest[2] = v4[2]; +} + +/*! + * @brief copy all members of [a] to [dest] + * + * @param[in] a source vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_copy(ivec3 a, ivec3 dest) { + dest[0] = a[0]; + dest[1] = a[1]; + dest[2] = a[2]; +} + +/*! + * @brief set all members of [v] to zero + * + * @param[out] v vector + */ +CGLM_INLINE +void +glm_ivec3_zero(ivec3 v) { + v[0] = v[1] = v[2] = 0; +} + +/*! + * @brief set all members of [v] to one + * + * @param[out] v vector + */ +CGLM_INLINE +void +glm_ivec3_one(ivec3 v) { + v[0] = v[1] = v[2] = 1; +} + +/*! + * @brief add vector [a] to vector [b] and store result in [dest] + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) { + dest[0] = a[0] + b[0]; + dest[1] = a[1] + b[1]; + dest[2] = a[2] + b[2]; +} + +/*! + * @brief add scalar s to vector [v] and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_adds(ivec3 v, int s, ivec3 dest) { + dest[0] = v[0] + s; + dest[1] = v[1] + s; + dest[2] = v[2] + s; +} + +/*! + * @brief subtract vector [b] from vector [a] and store result in [dest] + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest) { + dest[0] = a[0] - b[0]; + dest[1] = a[1] - b[1]; + dest[2] = a[2] - b[2]; +} + +/*! + * @brief subtract scalar s from vector [v] and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_subs(ivec3 v, int s, ivec3 dest) { + dest[0] = v[0] - s; + dest[1] = v[1] - s; + dest[2] = v[2] - s; +} + +/*! + * @brief multiply vector [a] with vector [b] and store result in [dest] + * + * @param[in] a frist vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest) { + dest[0] = a[0] * b[0]; + dest[1] = a[1] * b[1]; + dest[2] = a[2] * b[2]; +} + +/*! + * @brief multiply vector [a] with scalar s and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_scale(ivec3 v, int s, ivec3 dest) { + dest[0] = v[0] * s; + dest[1] = v[1] * s; + dest[2] = v[2] * s; +} + +/*! + * @brief squared distance between two vectors + * + * @param[in] a first vector + * @param[in] b second vector + * @return returns squared distance (distance * distance) + */ +CGLM_INLINE +int +glm_ivec3_distance2(ivec3 a, ivec3 b) { + int xd, yd, zd; + xd = a[0] - b[0]; + yd = a[1] - b[1]; + zd = a[2] - b[2]; + return xd * xd + yd * yd + zd * zd; +} + +/*! + * @brief distance between two vectors + * + * @param[in] a first vector + * @param[in] b second vector + * @return returns distance + */ +CGLM_INLINE +float +glm_ivec3_distance(ivec3 a, ivec3 b) { + return sqrtf((float)glm_ivec3_distance2(a, b)); +} + +/*! + * @brief set each member of dest to greater of vector a and b + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) { + dest[0] = a[0] > b[0] ? a[0] : b[0]; + dest[1] = a[1] > b[1] ? a[1] : b[1]; + dest[2] = a[2] > b[2] ? a[2] : b[2]; +} + +/*! + * @brief set each member of dest to lesser of vector a and b + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) { + dest[0] = a[0] < b[0] ? a[0] : b[0]; + dest[1] = a[1] < b[1] ? a[1] : b[1]; + dest[2] = a[2] < b[2] ? a[2] : b[2]; +} + +/*! + * @brief clamp each member of [v] between minVal and maxVal (inclusive) + * + * @param[in, out] v vector + * @param[in] minVal minimum value + * @param[in] maxVal maximum value + */ +CGLM_INLINE +void +glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) { + if (v[0] < minVal) + v[0] = minVal; + else if(v[0] > maxVal) + v[0] = maxVal; + + if (v[1] < minVal) + v[1] = minVal; + else if(v[1] > maxVal) + v[1] = maxVal; + + if (v[2] < minVal) + v[2] = minVal; + else if(v[2] > maxVal) + v[2] = maxVal; +} + +#endif /* cglm_ivec3_h */ diff --git a/include/cglm/ivec4.h b/include/cglm/ivec4.h new file mode 100644 index 0000000..363ee58 --- /dev/null +++ b/include/cglm/ivec4.h @@ -0,0 +1,275 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +/* +FUNCTIONS: + CGLM_INLINE void glm_ivec4(ivec3 v3, int last, ivec4 dest) + CGLM_INLINE void glm_ivec4_copy(ivec4 a, ivec4 dest) + CGLM_INLINE void glm_ivec4_zero(ivec4 v) + CGLM_INLINE void glm_ivec4_one(ivec4 v) + CGLM_INLINE void glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) + CGLM_INLINE void glm_ivec4_adds(ivec4 v, int s, ivec4 dest) + CGLM_INLINE void glm_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest) + CGLM_INLINE void glm_ivec4_subs(ivec4 v, int s, ivec4 dest) + CGLM_INLINE void glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest) + CGLM_INLINE void glm_ivec4_scale(ivec4 v, int s, ivec4 dest) + CGLM_INLINE int glm_ivec4_distance2(ivec4 a, ivec4 b) + CGLM_INLINE float glm_ivec4_distance(ivec4 a, ivec4 b) + CGLM_INLINE void glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) + CGLM_INLINE void glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) + CGLM_INLINE void glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) + */ + +#ifndef cglm_ivec4_h +#define cglm_ivec4_h + +#include "common.h" + +/*! + * @brief init ivec4 using ivec3 + * + * @param[in] v3 vector3 + * @param[in] last last item + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4(ivec3 v3, int last, ivec4 dest) { + dest[0] = v3[0]; + dest[1] = v3[1]; + dest[2] = v3[2]; + dest[3] = last; +} + +/*! + * @brief copy all members of [a] to [dest] + * + * @param[in] a source vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_copy(ivec4 a, ivec4 dest) { + dest[0] = a[0]; + dest[1] = a[1]; + dest[2] = a[2]; + dest[3] = a[3]; +} + +/*! + * @brief set all members of [v] to zero + * + * @param[out] v vector + */ +CGLM_INLINE +void +glm_ivec4_zero(ivec4 v) { + v[0] = v[1] = v[2] = v[3] = 0; +} + +/*! + * @brief set all members of [v] to one + * + * @param[out] v vector + */ +CGLM_INLINE +void +glm_ivec4_one(ivec4 v) { + v[0] = v[1] = v[2] = v[3] = 1; +} + +/*! + * @brief add vector [a] to vector [b] and store result in [dest] + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) { + dest[0] = a[0] + b[0]; + dest[1] = a[1] + b[1]; + dest[2] = a[2] + b[2]; + dest[3] = a[3] + b[3]; +} + +/*! + * @brief add scalar s to vector [v] and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_adds(ivec4 v, int s, ivec4 dest) { + dest[0] = v[0] + s; + dest[1] = v[1] + s; + dest[2] = v[2] + s; + dest[3] = v[3] + s; +} + +/*! + * @brief subtract vector [b] from vector [a] and store result in [dest] + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest) { + dest[0] = a[0] - b[0]; + dest[1] = a[1] - b[1]; + dest[2] = a[2] - b[2]; + dest[3] = a[3] - b[3]; +} + +/*! + * @brief subtract scalar s from vector [v] and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_subs(ivec4 v, int s, ivec4 dest) { + dest[0] = v[0] - s; + dest[1] = v[1] - s; + dest[2] = v[2] - s; + dest[3] = v[3] - s; +} + +/*! + * @brief multiply vector [a] with vector [b] and store result in [dest] + * + * @param[in] a frist vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest) { + dest[0] = a[0] * b[0]; + dest[1] = a[1] * b[1]; + dest[2] = a[2] * b[2]; + dest[3] = a[3] * b[3]; +} + +/*! + * @brief multiply vector [a] with scalar s and store result in [dest] + * + * @param[in] v vector + * @param[in] s scalar + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_scale(ivec4 v, int s, ivec4 dest) { + dest[0] = v[0] * s; + dest[1] = v[1] * s; + dest[2] = v[2] * s; + dest[3] = v[3] * s; +} + +/*! + * @brief squared distance between two vectors + * + * @param[in] a first vector + * @param[in] b second vector + * @return returns squared distance (distance * distance) + */ +CGLM_INLINE +int +glm_ivec4_distance2(ivec4 a, ivec4 b) { + int xd, yd, zd, wd; + xd = a[0] - b[0]; + yd = a[1] - b[1]; + zd = a[2] - b[2]; + wd = a[3] - b[3]; + return xd * xd + yd * yd + zd * zd + wd * wd; +} + +/*! + * @brief distance between two vectors + * + * @param[in] a first vector + * @param[in] b second vector + * @return returns distance + */ +CGLM_INLINE +float +glm_ivec4_distance(ivec4 a, ivec4 b) { + return sqrtf((float)glm_ivec4_distance2(a, b)); +} + +/*! + * @brief set each member of dest to greater of vector a and b + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) { + dest[0] = a[0] > b[0] ? a[0] : b[0]; + dest[1] = a[1] > b[1] ? a[1] : b[1]; + dest[2] = a[2] > b[2] ? a[2] : b[2]; + dest[3] = a[3] > b[3] ? a[3] : b[3]; +} + +/*! + * @brief set each member of dest to lesser of vector a and b + * + * @param[in] a first vector + * @param[in] b second vector + * @param[out] dest destination + */ +CGLM_INLINE +void +glm_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) { + dest[0] = a[0] < b[0] ? a[0] : b[0]; + dest[1] = a[1] < b[1] ? a[1] : b[1]; + dest[2] = a[2] < b[2] ? a[2] : b[2]; + dest[3] = a[3] < b[3] ? a[3] : b[3]; +} + +/*! + * @brief clamp each member of [v] between minVal and maxVal (inclusive) + * + * @param[in, out] v vector + * @param[in] minVal minimum value + * @param[in] maxVal maximum value + */ +CGLM_INLINE +void +glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) { + if (v[0] < minVal) + v[0] = minVal; + else if(v[0] > maxVal) + v[0] = maxVal; + + if (v[1] < minVal) + v[1] = minVal; + else if(v[1] > maxVal) + v[1] = maxVal; + + if (v[2] < minVal) + v[2] = minVal; + else if(v[2] > maxVal) + v[2] = maxVal; + + if (v[3] < minVal) + v[3] = minVal; + else if(v[3] > maxVal) + v[3] = maxVal; +} + +#endif /* cglm_ivec4_h */ diff --git a/meson.build b/meson.build index e2034ec..8f9cdc4 100644 --- a/meson.build +++ b/meson.build @@ -49,6 +49,9 @@ cglm_src = files( 'src/vec2.c', 'src/vec3.c', 'src/vec4.c', + 'src/ivec2.c', + 'src/ivec3.c', + 'src/ivec4.c', 'src/clipspace/ortho_lh_no.c', 'src/clipspace/ortho_lh_zo.c', 'src/clipspace/ortho_rh_no.c', diff --git a/src/ivec2.c b/src/ivec2.c new file mode 100644 index 0000000..1162c22 --- /dev/null +++ b/src/ivec2.c @@ -0,0 +1,99 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "../include/cglm/cglm.h" +#include "../include/cglm/call.h" + +CGLM_EXPORT +void +glmc_ivec2(int * __restrict v, ivec2 dest) { + glm_ivec2(v, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_copy(ivec2 a, ivec2 dest) { + glm_ivec2_copy(a, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_zero(ivec2 v) { + glm_ivec2_zero(v); +} + +CGLM_EXPORT +void +glmc_ivec2_one(ivec2 v) { + glm_ivec2_one(v); +} + +CGLM_EXPORT +void +glmc_ivec2_add(ivec2 a, ivec2 b, ivec2 dest) { + glm_ivec2_add(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_adds(ivec2 v, int s, ivec2 dest) { + glm_ivec2_adds(v, s, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_sub(ivec2 a, ivec2 b, ivec2 dest) { + glm_ivec2_sub(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_subs(ivec2 v, int s, ivec2 dest) { + glm_ivec2_subs(v, s, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_mul(ivec2 a, ivec2 b, ivec2 dest) { + glm_ivec2_mul(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_scale(ivec2 v, int s, ivec2 dest) { + glm_ivec2_scale(v, s, dest); +} + +CGLM_EXPORT +int +glmc_ivec2_distance2(ivec2 a, ivec2 b) { + return glm_ivec2_distance2(a, b); +} + +CGLM_EXPORT +float +glmc_ivec2_distance(ivec2 a, ivec2 b) { + return glm_ivec2_distance(a, b); +} + +CGLM_EXPORT +void +glmc_ivec2_maxv(ivec2 a, ivec2 b, ivec2 dest) { + glm_ivec2_maxv(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_minv(ivec2 a, ivec2 b, ivec2 dest) { + glm_ivec2_minv(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec2_clamp(ivec2 v, int minVal, int maxVal) { + glm_ivec2_clamp(v, minVal, maxVal); +} diff --git a/src/ivec3.c b/src/ivec3.c new file mode 100644 index 0000000..1e14dd3 --- /dev/null +++ b/src/ivec3.c @@ -0,0 +1,99 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "../include/cglm/cglm.h" +#include "../include/cglm/call.h" + +CGLM_EXPORT +void +glmc_ivec3(ivec4 v4, ivec3 dest) { + glm_ivec3(v4, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_copy(ivec3 a, ivec3 dest) { + glm_ivec3_copy(a, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_zero(ivec3 v) { + glm_ivec3_zero(v); +} + +CGLM_EXPORT +void +glmc_ivec3_one(ivec3 v) { + glm_ivec3_one(v); +} + +CGLM_EXPORT +void +glmc_ivec3_add(ivec3 a, ivec3 b, ivec3 dest) { + glm_ivec3_add(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_adds(ivec3 v, int s, ivec3 dest) { + glm_ivec3_adds(v, s, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_sub(ivec3 a, ivec3 b, ivec3 dest) { + glm_ivec3_sub(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_subs(ivec3 v, int s, ivec3 dest) { + glm_ivec3_subs(v, s, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_mul(ivec3 a, ivec3 b, ivec3 dest) { + glm_ivec3_mul(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_scale(ivec3 v, int s, ivec3 dest) { + glm_ivec3_scale(v, s, dest); +} + +CGLM_EXPORT +int +glmc_ivec3_distance2(ivec3 a, ivec3 b) { + return glm_ivec3_distance2(a, b); +} + +CGLM_EXPORT +float +glmc_ivec3_distance(ivec3 a, ivec3 b) { + return glm_ivec3_distance(a, b); +} + +CGLM_EXPORT +void +glmc_ivec3_maxv(ivec3 a, ivec3 b, ivec3 dest) { + glm_ivec3_maxv(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_minv(ivec3 a, ivec3 b, ivec3 dest) { + glm_ivec3_minv(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec3_clamp(ivec3 v, int minVal, int maxVal) { + glm_ivec3_clamp(v, minVal, maxVal); +} diff --git a/src/ivec4.c b/src/ivec4.c new file mode 100644 index 0000000..ea69042 --- /dev/null +++ b/src/ivec4.c @@ -0,0 +1,99 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "../include/cglm/cglm.h" +#include "../include/cglm/call.h" + +CGLM_EXPORT +void +glmc_ivec4(ivec3 v3, int last, ivec4 dest) { + glm_ivec4(v3, last, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_copy(ivec4 a, ivec4 dest) { + glm_ivec4_copy(a, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_zero(ivec4 v) { + glm_ivec4_zero(v); +} + +CGLM_EXPORT +void +glmc_ivec4_one(ivec4 v) { + glm_ivec4_one(v); +} + +CGLM_EXPORT +void +glmc_ivec4_add(ivec4 a, ivec4 b, ivec4 dest) { + glm_ivec4_add(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_adds(ivec4 v, int s, ivec4 dest) { + glm_ivec4_adds(v, s, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_sub(ivec4 a, ivec4 b, ivec4 dest) { + glm_ivec4_sub(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_subs(ivec4 v, int s, ivec4 dest) { + glm_ivec4_subs(v, s, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_mul(ivec4 a, ivec4 b, ivec4 dest) { + glm_ivec4_mul(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_scale(ivec4 v, int s, ivec4 dest) { + glm_ivec4_scale(v, s, dest); +} + +CGLM_EXPORT +int +glmc_ivec4_distance2(ivec4 a, ivec4 b) { + return glm_ivec4_distance2(a, b); +} + +CGLM_EXPORT +float +glmc_ivec4_distance(ivec4 a, ivec4 b) { + return glm_ivec4_distance(a, b); +} + +CGLM_EXPORT +void +glmc_ivec4_maxv(ivec4 a, ivec4 b, ivec4 dest) { + glm_ivec4_maxv(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_minv(ivec4 a, ivec4 b, ivec4 dest) { + glm_ivec4_minv(a, b, dest); +} + +CGLM_EXPORT +void +glmc_ivec4_clamp(ivec4 v, int minVal, int maxVal) { + glm_ivec4_clamp(v, minVal, maxVal); +} diff --git a/test/src/test_ivec2.h b/test/src/test_ivec2.h new file mode 100644 index 0000000..5374688 --- /dev/null +++ b/test/src/test_ivec2.h @@ -0,0 +1,189 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "test_common.h" + +TEST_IMPL(GLM_PREFIX, ivec2) { + ivec4 v4 = {2, 3, 5, 7}; + ivec3 v3 = {11, 13, 17}; + ivec2 v2; + + GLM(ivec2)(v4, v2); + ASSERT(v2[0] == 2) + ASSERT(v2[1] == 3) + + GLM(ivec2)(v3, v2); + ASSERT(v2[0] == 11) + ASSERT(v2[1] == 13) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_copy) { + ivec2 src = {7, 5}; + ivec2 dst = {99, 99}; + + GLM(ivec2_copy)(src, dst); + ASSERT(dst[0] == 7) + ASSERT(dst[1] == 5) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_zero) { + ivec2 v = {2, 3}; + + GLM(ivec2_zero)(v); + ASSERT(v[0] == 0) + ASSERT(v[1] == 0) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_one) { + ivec2 v = {-2, 9}; + + GLM(ivec2_one)(v); + ASSERT(v[0] == 1) + ASSERT(v[1] == 1) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_add) { + ivec2 a = {14, 3}; + ivec2 b = {-3, 2}; + ivec2 v = {99, 99}; + + GLM(ivec2_add)(a, b, v); + ASSERT(v[0] == 11) + ASSERT(v[1] == 5) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_adds) { + ivec2 a = {-3, 1}; + ivec2 v = {99, 99}; + int s = 2; + + GLM(ivec2_adds)(a, s, v); + ASSERT(v[0] == -1) + ASSERT(v[1] == 3) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_sub) { + ivec2 a = {-2, 9}; + ivec2 b = {3, 2}; + ivec2 v = {99, 99}; + + GLM(ivec2_sub)(a, b, v); + ASSERT(v[0] == -5) + ASSERT(v[1] == 7) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_subs) { + ivec2 a = {5, -2}; + ivec2 v = {99, 99}; + int s = -3; + + GLM(ivec2_subs)(a, s, v); + ASSERT(v[0] == 8) + ASSERT(v[1] == 1) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_mul) { + ivec2 a = {3, 4}; + ivec2 b = {-2, 3}; + ivec2 v = {99, 99}; + + GLM(ivec2_mul)(a, b, v); + ASSERT(v[0] == -6) + ASSERT(v[1] == 12) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_scale) { + ivec2 a = {-9, 2}; + ivec2 v = {99, 99}; + int s = -2; + + GLM(ivec2_scale)(a, s, v); + ASSERT(v[0] == 18) + ASSERT(v[1] == -4) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_distance2) { + ivec2 a = {-1, 3}; + ivec2 b = {5, 4}; + int v; + + v = GLM(ivec2_distance2)(a, b); + ASSERT(v == 37) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_distance) { + ivec2 a = {3, 2}; + ivec2 b = {-2, 5}; + float v; + + v = GLM(ivec2_distance)(a, b); + ASSERT(test_eq(v, 5.8309518948)) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_maxv) { + ivec2 a = {9, -20}; + ivec2 b = {8, -1}; + ivec2 v = {99, 99}; + + GLM(ivec2_maxv)(a, b, v); + ASSERT(v[0] == 9) + ASSERT(v[1] == -1) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_minv) { + ivec2 a = {16, 0}; + ivec2 b = {-15, 10}; + ivec2 v = {99, 99}; + + GLM(ivec2_minv)(a, b, v); + ASSERT(v[0] == -15) + ASSERT(v[1] == 0) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec2_clamp) { + ivec2 v = {3, -1}; + + GLM(ivec2_clamp)(v, -2, 4); + ASSERT(v[0] == 3) + ASSERT(v[1] == -1) + + v[0] = -15; + v[1] = 4; + GLM(ivec2_clamp)(v, -9, 3); + ASSERT(v[0] == -9) + ASSERT(v[1] == 3) + + TEST_SUCCESS +} diff --git a/test/src/test_ivec3.h b/test/src/test_ivec3.h new file mode 100644 index 0000000..dfa8794 --- /dev/null +++ b/test/src/test_ivec3.h @@ -0,0 +1,199 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "test_common.h" + +TEST_IMPL(GLM_PREFIX, ivec3) { + ivec4 v4 = {2, 3, 5, 7}; + ivec3 v3 = {99, 99, 99}; + + GLM(ivec3)(v4, v3); + ASSERT(v3[0] == 2) + ASSERT(v3[1] == 3) + ASSERT(v3[2] == 5) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_copy) { + ivec3 src = {7, 5, 2}; + ivec3 dst = {99, 99, 99}; + + GLM(ivec3_copy)(src, dst); + ASSERT(dst[0] == 7) + ASSERT(dst[1] == 5) + ASSERT(dst[2] == 2) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_zero) { + ivec3 v = {2, 3, 5}; + + GLM(ivec3_zero)(v); + ASSERT(v[0] == 0) + ASSERT(v[1] == 0) + ASSERT(v[2] == 0) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_one) { + ivec3 v = {-2, 9, 12}; + + GLM(ivec3_one)(v); + ASSERT(v[0] == 1) + ASSERT(v[1] == 1) + ASSERT(v[2] == 1) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_add) { + ivec3 a = {14, 3, 2}; + ivec3 b = {-3, 2, 1}; + ivec3 v = {99, 99, 99}; + + GLM(ivec3_add)(a, b, v); + ASSERT(v[0] == 11) + ASSERT(v[1] == 5) + ASSERT(v[2] == 3) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_adds) { + ivec3 a = {-3, 1, 4}; + ivec3 v = {99, 99, 99}; + int s = 2; + + GLM(ivec3_adds)(a, s, v); + ASSERT(v[0] == -1) + ASSERT(v[1] == 3) + ASSERT(v[2] == 6) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_sub) { + ivec3 a = {-2, 9, 1}; + ivec3 b = {3, 2, -1}; + ivec3 v = {99, 99, 99}; + + GLM(ivec3_sub)(a, b, v); + ASSERT(v[0] == -5) + ASSERT(v[1] == 7) + ASSERT(v[2] == 2) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_subs) { + ivec3 a = {5, -2, 6}; + ivec3 v = {99, 99, 99}; + int s = -3; + + GLM(ivec3_subs)(a, s, v); + ASSERT(v[0] == 8) + ASSERT(v[1] == 1) + ASSERT(v[2] == 9) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_mul) { + ivec3 a = {3, 4, 5}; + ivec3 b = {-2, 3, 1}; + ivec3 v = {99, 99, 99}; + + GLM(ivec3_mul)(a, b, v); + ASSERT(v[0] == -6) + ASSERT(v[1] == 12) + ASSERT(v[2] == 5) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_scale) { + ivec3 a = {-9, 2, 3}; + ivec3 v = {99, 99, 99}; + int s = -2; + + GLM(ivec3_scale)(a, s, v); + ASSERT(v[0] == 18) + ASSERT(v[1] == -4) + ASSERT(v[2] == -6) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_distance2) { + ivec3 a = {-1, 3, 0}; + ivec3 b = {5, 4, 2}; + int v; + + v = GLM(ivec3_distance2)(a, b); + ASSERT(v == 41) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_distance) { + ivec3 a = {3, 2, 4}; + ivec3 b = {-2, 5, 2}; + float v; + + v = GLM(ivec3_distance)(a, b); + ASSERT(test_eq(v, 6.1644140029)) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_maxv) { + ivec3 a = {9, -20, 5}; + ivec3 b = {8, -1, 2}; + ivec3 v = {99, 99, 99}; + + GLM(ivec3_maxv)(a, b, v); + ASSERT(v[0] == 9) + ASSERT(v[1] == -1) + ASSERT(v[2] == 5) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_minv) { + ivec3 a = {16, 0, 4}; + ivec3 b = {-15, 10, 8}; + ivec3 v = {99, 99, 99}; + + GLM(ivec3_minv)(a, b, v); + ASSERT(v[0] == -15) + ASSERT(v[1] == 0) + ASSERT(v[2] == 4) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec3_clamp) { + ivec3 v = {3, -1, 10}; + + GLM(ivec3_clamp)(v, -2, 4); + ASSERT(v[0] == 3) + ASSERT(v[1] == -1) + ASSERT(v[2] == 4) + + v[0] = -15; + v[1] = 4; + v[2] = 1; + GLM(ivec3_clamp)(v, -9, 3); + ASSERT(v[0] == -9) + ASSERT(v[1] == 3) + ASSERT(v[2] == 1) + + TEST_SUCCESS +} diff --git a/test/src/test_ivec4.h b/test/src/test_ivec4.h new file mode 100644 index 0000000..dd2d606 --- /dev/null +++ b/test/src/test_ivec4.h @@ -0,0 +1,214 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "test_common.h" + +TEST_IMPL(GLM_PREFIX, ivec4) { + ivec3 v3 = {2, 3, 5}; + ivec4 v4; + + GLM(ivec4)(v3, 7, v4); + ASSERT(test_eq(v4[0], 2)) + ASSERT(test_eq(v4[1], 3)) + ASSERT(test_eq(v4[2], 5)) + ASSERT(test_eq(v4[3], 7)) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_copy) { + ivec4 src = {7, 5, 2, 11}; + ivec4 dst = {99, 99, 99, 99}; + + GLM(ivec4_copy)(src, dst); + ASSERT(dst[0] == 7) + ASSERT(dst[1] == 5) + ASSERT(dst[2] == 2) + ASSERT(dst[3] == 11) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_zero) { + ivec4 v = {2, 3, 5, 7}; + + GLM(ivec4_zero)(v); + ASSERT(v[0] == 0) + ASSERT(v[1] == 0) + ASSERT(v[2] == 0) + ASSERT(v[3] == 0) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_one) { + ivec4 v = {-2, 9, 12, 7}; + + GLM(ivec4_one)(v); + ASSERT(v[0] == 1) + ASSERT(v[1] == 1) + ASSERT(v[2] == 1) + ASSERT(v[3] == 1) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_add) { + ivec4 a = {14, 3, 2, -4}; + ivec4 b = {-3, 2, 1, -1}; + ivec4 v = {99, 99, 99, 99}; + + GLM(ivec4_add)(a, b, v); + ASSERT(v[0] == 11) + ASSERT(v[1] == 5) + ASSERT(v[2] == 3) + ASSERT(v[3] == -5) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_adds) { + ivec4 a = {-3, 1, 4, 2}; + ivec4 v = {99, 99, 99, 99}; + int s = -2; + + GLM(ivec4_adds)(a, s, v); + ASSERT(v[0] == -5) + ASSERT(v[1] == -1) + ASSERT(v[2] == 2) + ASSERT(v[3] == 0) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_sub) { + ivec4 a = {-2, 9, 1, 5}; + ivec4 b = {3, 2, -1, 2}; + ivec4 v = {99, 99, 99, 99}; + + GLM(ivec4_sub)(a, b, v); + ASSERT(v[0] == -5) + ASSERT(v[1] == 7) + ASSERT(v[2] == 2) + ASSERT(v[3] == 3) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_subs) { + ivec4 a = {5, -2, 6, 1}; + ivec4 v = {99, 99, 99, 99}; + int s = 2; + + GLM(ivec4_subs)(a, s, v); + ASSERT(v[0] == 3) + ASSERT(v[1] == -4) + ASSERT(v[2] == 4) + ASSERT(v[3] == -1) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_mul) { + ivec4 a = {3, 4, 5, -3}; + ivec4 b = {-2, 3, 1, 2}; + ivec4 v = {99, 99, 99, 99}; + + GLM(ivec4_mul)(a, b, v); + ASSERT(v[0] == -6) + ASSERT(v[1] == 12) + ASSERT(v[2] == 5) + ASSERT(v[3] == -6) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_scale) { + ivec4 a = {-9, 2, 3, 0}; + ivec4 v = {99, 99, 99, 99}; + int s = -2; + + GLM(ivec4_scale)(a, s, v); + ASSERT(v[0] == 18) + ASSERT(v[1] == -4) + ASSERT(v[2] == -6) + ASSERT(v[3] == 0) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_distance2) { + ivec4 a = {-1, 3, 0, 4}; + ivec4 b = {5, 4, 2, 6}; + int v; + + v = GLM(ivec4_distance2)(a, b); + ASSERT(v == 45) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_distance) { + ivec4 a = {3, 2, 4, -1}; + ivec4 b = {-2, 5, 2, 4}; + float v; + + v = GLM(ivec4_distance)(a, b); + ASSERT(test_eq(v, 7.9372539331)) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_maxv) { + ivec4 a = {9, -20, 5, -3}; + ivec4 b = {8, -1, 2, 2}; + ivec4 v = {99, 99, 99, 99}; + + GLM(ivec4_maxv)(a, b, v); + ASSERT(v[0] == 9) + ASSERT(v[1] == -1) + ASSERT(v[2] == 5) + ASSERT(v[3] == 2) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_minv) { + ivec4 a = {16, 0, 4, 5}; + ivec4 b = {-15, 10, 8, 2}; + ivec4 v = {99, 99, 99, 99}; + + GLM(ivec4_minv)(a, b, v); + ASSERT(v[0] == -15) + ASSERT(v[1] == 0) + ASSERT(v[2] == 4) + ASSERT(v[3] == 2) + + TEST_SUCCESS +} + +TEST_IMPL(GLM_PREFIX, ivec4_clamp) { + ivec4 v = {3, -1, 10, -100}; + + GLM(ivec4_clamp)(v, -2, 4); + ASSERT(v[0] == 3) + ASSERT(v[1] == -1) + ASSERT(v[2] == 4) + ASSERT(v[3] == -2) + + v[0] = -15; + v[1] = 4; + v[2] = 1; + v[3] = 0; + GLM(ivec4_clamp)(v, -9, 3); + ASSERT(v[0] == -9) + ASSERT(v[1] == 3) + ASSERT(v[2] == 1) + ASSERT(v[3] == 0) + + TEST_SUCCESS +} diff --git a/test/src/tests.c b/test/src/tests.c index 1cfc378..1505e32 100644 --- a/test/src/tests.c +++ b/test/src/tests.c @@ -15,6 +15,9 @@ #include "test_vec2.h" #include "test_vec3.h" #include "test_vec4.h" +#include "test_ivec2.h" +#include "test_ivec3.h" +#include "test_ivec4.h" #include "test_mat2.h" #include "test_mat3.h" #include "test_mat4.h" @@ -39,6 +42,9 @@ #include "test_vec2.h" #include "test_vec3.h" #include "test_vec4.h" +#include "test_ivec2.h" +#include "test_ivec3.h" +#include "test_ivec4.h" #include "test_mat2.h" #include "test_mat3.h" #include "test_mat4.h" diff --git a/test/tests.h b/test/tests.h index 6801298..361b485 100644 --- a/test/tests.h +++ b/test/tests.h @@ -340,9 +340,7 @@ TEST_DECLARE(glmc_quat_from_vecs) /* bezier */ TEST_DECLARE(bezier) - -/* Macros */ - +/* vec2 */ TEST_DECLARE(MACRO_GLM_VEC2_ONE_INIT) TEST_DECLARE(MACRO_GLM_VEC2_ZERO_INIT) TEST_DECLARE(MACRO_GLM_VEC2_ONE) @@ -385,7 +383,6 @@ TEST_DECLARE(glm_vec2_lerp) TEST_DECLARE(glm_vec2_complex_mul) TEST_DECLARE(glm_vec2_complex_div) - TEST_DECLARE(glmc_vec2) TEST_DECLARE(glmc_vec2_copy) TEST_DECLARE(glmc_vec2_zero) @@ -588,7 +585,6 @@ TEST_DECLARE(glmc_vec3_hadd) TEST_DECLARE(glmc_vec3_sqrt) /* vec4 */ - TEST_DECLARE(MACRO_GLM_VEC4_ONE_INIT) TEST_DECLARE(MACRO_GLM_VEC4_ZERO_INIT) TEST_DECLARE(MACRO_GLM_VEC4_ONE) @@ -734,8 +730,106 @@ TEST_DECLARE(glmc_vec4_fract) TEST_DECLARE(glmc_vec4_hadd) TEST_DECLARE(glmc_vec4_sqrt) -/* structs */ +/* ivec2 */ +TEST_DECLARE(glm_ivec2) +TEST_DECLARE(glm_ivec2_copy) +TEST_DECLARE(glm_ivec2_zero) +TEST_DECLARE(glm_ivec2_one) +TEST_DECLARE(glm_ivec2_add) +TEST_DECLARE(glm_ivec2_adds) +TEST_DECLARE(glm_ivec2_sub) +TEST_DECLARE(glm_ivec2_subs) +TEST_DECLARE(glm_ivec2_mul) +TEST_DECLARE(glm_ivec2_scale) +TEST_DECLARE(glm_ivec2_distance2) +TEST_DECLARE(glm_ivec2_distance) +TEST_DECLARE(glm_ivec2_maxv) +TEST_DECLARE(glm_ivec2_minv) +TEST_DECLARE(glm_ivec2_clamp) +TEST_DECLARE(glmc_ivec2) +TEST_DECLARE(glmc_ivec2_copy) +TEST_DECLARE(glmc_ivec2_zero) +TEST_DECLARE(glmc_ivec2_one) +TEST_DECLARE(glmc_ivec2_add) +TEST_DECLARE(glmc_ivec2_adds) +TEST_DECLARE(glmc_ivec2_sub) +TEST_DECLARE(glmc_ivec2_subs) +TEST_DECLARE(glmc_ivec2_mul) +TEST_DECLARE(glmc_ivec2_scale) +TEST_DECLARE(glmc_ivec2_distance2) +TEST_DECLARE(glmc_ivec2_distance) +TEST_DECLARE(glmc_ivec2_maxv) +TEST_DECLARE(glmc_ivec2_minv) +TEST_DECLARE(glmc_ivec2_clamp) + +/* ivec3 */ +TEST_DECLARE(glm_ivec3) +TEST_DECLARE(glm_ivec3_copy) +TEST_DECLARE(glm_ivec3_zero) +TEST_DECLARE(glm_ivec3_one) +TEST_DECLARE(glm_ivec3_add) +TEST_DECLARE(glm_ivec3_adds) +TEST_DECLARE(glm_ivec3_sub) +TEST_DECLARE(glm_ivec3_subs) +TEST_DECLARE(glm_ivec3_mul) +TEST_DECLARE(glm_ivec3_scale) +TEST_DECLARE(glm_ivec3_distance2) +TEST_DECLARE(glm_ivec3_distance) +TEST_DECLARE(glm_ivec3_maxv) +TEST_DECLARE(glm_ivec3_minv) +TEST_DECLARE(glm_ivec3_clamp) + +TEST_DECLARE(glmc_ivec3) +TEST_DECLARE(glmc_ivec3_copy) +TEST_DECLARE(glmc_ivec3_zero) +TEST_DECLARE(glmc_ivec3_one) +TEST_DECLARE(glmc_ivec3_add) +TEST_DECLARE(glmc_ivec3_adds) +TEST_DECLARE(glmc_ivec3_sub) +TEST_DECLARE(glmc_ivec3_subs) +TEST_DECLARE(glmc_ivec3_mul) +TEST_DECLARE(glmc_ivec3_scale) +TEST_DECLARE(glmc_ivec3_distance2) +TEST_DECLARE(glmc_ivec3_distance) +TEST_DECLARE(glmc_ivec3_maxv) +TEST_DECLARE(glmc_ivec3_minv) +TEST_DECLARE(glmc_ivec3_clamp) + +/* ivec4 */ +TEST_DECLARE(glm_ivec4) +TEST_DECLARE(glm_ivec4_copy) +TEST_DECLARE(glm_ivec4_zero) +TEST_DECLARE(glm_ivec4_one) +TEST_DECLARE(glm_ivec4_add) +TEST_DECLARE(glm_ivec4_adds) +TEST_DECLARE(glm_ivec4_sub) +TEST_DECLARE(glm_ivec4_subs) +TEST_DECLARE(glm_ivec4_mul) +TEST_DECLARE(glm_ivec4_scale) +TEST_DECLARE(glm_ivec4_distance2) +TEST_DECLARE(glm_ivec4_distance) +TEST_DECLARE(glm_ivec4_maxv) +TEST_DECLARE(glm_ivec4_minv) +TEST_DECLARE(glm_ivec4_clamp) + +TEST_DECLARE(glmc_ivec4) +TEST_DECLARE(glmc_ivec4_copy) +TEST_DECLARE(glmc_ivec4_zero) +TEST_DECLARE(glmc_ivec4_one) +TEST_DECLARE(glmc_ivec4_add) +TEST_DECLARE(glmc_ivec4_adds) +TEST_DECLARE(glmc_ivec4_sub) +TEST_DECLARE(glmc_ivec4_subs) +TEST_DECLARE(glmc_ivec4_mul) +TEST_DECLARE(glmc_ivec4_scale) +TEST_DECLARE(glmc_ivec4_distance2) +TEST_DECLARE(glmc_ivec4_distance) +TEST_DECLARE(glmc_ivec4_maxv) +TEST_DECLARE(glmc_ivec4_minv) +TEST_DECLARE(glmc_ivec4_clamp) + +/* structs */ TEST_DECLARE(mat3s_identity_init) TEST_DECLARE(mat3s_zero_init) TEST_DECLARE(mat4s_identity_init) @@ -1075,8 +1169,6 @@ TEST_LIST { TEST_ENTRY(bezier) /* vec2 */ - /* Macros */ - TEST_ENTRY(MACRO_GLM_VEC2_ONE_INIT) TEST_ENTRY(MACRO_GLM_VEC2_ZERO_INIT) TEST_ENTRY(MACRO_GLM_VEC2_ONE) @@ -1157,8 +1249,6 @@ TEST_LIST { TEST_ENTRY(glmc_vec2_complex_div) /* vec3 */ - /* Macros */ - TEST_ENTRY(MACRO_GLM_VEC3_ONE_INIT) TEST_ENTRY(MACRO_GLM_VEC3_ZERO_INIT) TEST_ENTRY(MACRO_GLM_VEC3_ONE) @@ -1322,8 +1412,6 @@ TEST_LIST { TEST_ENTRY(glmc_vec3_sqrt) /* vec4 */ - /* Macros */ - TEST_ENTRY(MACRO_GLM_VEC4_ONE_INIT) TEST_ENTRY(MACRO_GLM_VEC4_ZERO_INIT) TEST_ENTRY(MACRO_GLM_VEC4_ONE) @@ -1469,6 +1557,105 @@ TEST_LIST { TEST_ENTRY(glmc_vec4_hadd) TEST_ENTRY(glmc_vec4_sqrt) + /* ivec2 */ + TEST_ENTRY(glm_ivec2) + TEST_ENTRY(glm_ivec2_copy) + TEST_ENTRY(glm_ivec2_zero) + TEST_ENTRY(glm_ivec2_one) + TEST_ENTRY(glm_ivec2_add) + TEST_ENTRY(glm_ivec2_adds) + TEST_ENTRY(glm_ivec2_sub) + TEST_ENTRY(glm_ivec2_subs) + TEST_ENTRY(glm_ivec2_mul) + TEST_ENTRY(glm_ivec2_scale) + TEST_ENTRY(glm_ivec2_distance2) + TEST_ENTRY(glm_ivec2_distance) + TEST_ENTRY(glm_ivec2_maxv) + TEST_ENTRY(glm_ivec2_minv) + TEST_ENTRY(glm_ivec2_clamp) + + TEST_ENTRY(glmc_ivec2) + TEST_ENTRY(glmc_ivec2_copy) + TEST_ENTRY(glmc_ivec2_zero) + TEST_ENTRY(glmc_ivec2_one) + TEST_ENTRY(glmc_ivec2_add) + TEST_ENTRY(glmc_ivec2_adds) + TEST_ENTRY(glmc_ivec2_sub) + TEST_ENTRY(glmc_ivec2_subs) + TEST_ENTRY(glmc_ivec2_mul) + TEST_ENTRY(glmc_ivec2_scale) + TEST_ENTRY(glmc_ivec2_distance2) + TEST_ENTRY(glmc_ivec2_distance) + TEST_ENTRY(glmc_ivec2_maxv) + TEST_ENTRY(glmc_ivec2_minv) + TEST_ENTRY(glmc_ivec2_clamp) + + /* ivec3 */ + TEST_ENTRY(glm_ivec3) + TEST_ENTRY(glm_ivec3_copy) + TEST_ENTRY(glm_ivec3_zero) + TEST_ENTRY(glm_ivec3_one) + TEST_ENTRY(glm_ivec3_add) + TEST_ENTRY(glm_ivec3_adds) + TEST_ENTRY(glm_ivec3_sub) + TEST_ENTRY(glm_ivec3_subs) + TEST_ENTRY(glm_ivec3_mul) + TEST_ENTRY(glm_ivec3_scale) + TEST_ENTRY(glm_ivec3_distance2) + TEST_ENTRY(glm_ivec3_distance) + TEST_ENTRY(glm_ivec3_maxv) + TEST_ENTRY(glm_ivec3_minv) + TEST_ENTRY(glm_ivec3_clamp) + + TEST_ENTRY(glmc_ivec3) + TEST_ENTRY(glmc_ivec3_copy) + TEST_ENTRY(glmc_ivec3_zero) + TEST_ENTRY(glmc_ivec3_one) + TEST_ENTRY(glmc_ivec3_add) + TEST_ENTRY(glmc_ivec3_adds) + TEST_ENTRY(glmc_ivec3_sub) + TEST_ENTRY(glmc_ivec3_subs) + TEST_ENTRY(glmc_ivec3_mul) + TEST_ENTRY(glmc_ivec3_scale) + TEST_ENTRY(glmc_ivec3_distance2) + TEST_ENTRY(glmc_ivec3_distance) + TEST_ENTRY(glmc_ivec3_maxv) + TEST_ENTRY(glmc_ivec3_minv) + TEST_ENTRY(glmc_ivec3_clamp) + + /* ivec4 */ + TEST_ENTRY(glm_ivec4) + TEST_ENTRY(glm_ivec4_copy) + TEST_ENTRY(glm_ivec4_zero) + TEST_ENTRY(glm_ivec4_one) + TEST_ENTRY(glm_ivec4_add) + TEST_ENTRY(glm_ivec4_adds) + TEST_ENTRY(glm_ivec4_sub) + TEST_ENTRY(glm_ivec4_subs) + TEST_ENTRY(glm_ivec4_mul) + TEST_ENTRY(glm_ivec4_scale) + TEST_ENTRY(glm_ivec4_distance2) + TEST_ENTRY(glm_ivec4_distance) + TEST_ENTRY(glm_ivec4_maxv) + TEST_ENTRY(glm_ivec4_minv) + TEST_ENTRY(glm_ivec4_clamp) + + TEST_ENTRY(glmc_ivec4) + TEST_ENTRY(glmc_ivec4_copy) + TEST_ENTRY(glmc_ivec4_zero) + TEST_ENTRY(glmc_ivec4_one) + TEST_ENTRY(glmc_ivec4_add) + TEST_ENTRY(glmc_ivec4_adds) + TEST_ENTRY(glmc_ivec4_sub) + TEST_ENTRY(glmc_ivec4_subs) + TEST_ENTRY(glmc_ivec4_mul) + TEST_ENTRY(glmc_ivec4_scale) + TEST_ENTRY(glmc_ivec4_distance2) + TEST_ENTRY(glmc_ivec4_distance) + TEST_ENTRY(glmc_ivec4_maxv) + TEST_ENTRY(glmc_ivec4_minv) + TEST_ENTRY(glmc_ivec4_clamp) + /* structs */ TEST_ENTRY(mat3s_identity_init) TEST_ENTRY(mat3s_zero_init)