Compare commits

..

24 Commits

Author SHA1 Message Date
Recep Aslantas
c51040cd41 Merge pull request #276 from recp/cmake-fix-buildtype
cmake: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory
2023-01-27 21:01:54 +03:00
Recep Aslantas
9fc3a20d0f cmake: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory 2023-01-26 11:07:08 +03:00
Recep Aslantas
7f1c062696 Merge pull request #274 from duarm/master
Adding initialization macros for ivec types
2023-01-17 21:07:32 +03:00
duarm
e70571e9e0 ivec initialization macros docs, fixing vec2 macro docs 2023-01-15 20:52:18 -03:00
duarm
007ee48b58 adding initialization macros for ivec types 2023-01-15 20:47:40 -03:00
Recep Aslantas
38771599c7 Merge pull request #273 from JulianSchoenbaechler/fix-Wdouble-promotion
Make implicit double promotion/casting explicit (fixes #228)
2022-12-31 21:18:40 +03:00
Julian Schönbächler
bfd87acfc4 Make double promotion in printf args explicit
Also use f-suffix on epsilon definitions for float comparisons.
2022-12-29 13:00:15 +01:00
Recep Aslantas
a38622e1d6 Merge pull request #272 from Artturin/revert259
Revert "fix: simplified pkgconfig generation"
2022-12-19 20:07:37 +03:00
Artturin
9c7012bb39 Revert "fix: simplified pkgconfig generation"
This reverts commit c7393f75c3.
2022-12-19 00:22:55 +02:00
Recep Aslantas
71367b67cf now working on v0.8.9 2022-12-14 14:12:29 +03:00
Recep Aslantas
3894ea32fb Merge pull request #270 from suicvne/cglm-pc-fix-cmake
Switch CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR for cmake.pc
2022-12-13 20:17:03 +03:00
Michael Santiago
a430408ec4 Switch CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR for cmake.pc install target 2022-12-13 10:59:54 -05:00
Recep Aslantas
3815e18fea bring the fix https://github.com/recp/cglm/pull/269 outside Emscripten 2022-12-12 00:37:07 +03:00
Recep Aslantas
8b5eaa5301 Merge pull request #269 from KivApple/master
Fix missing abs declaration on Emscripten
2022-12-09 14:54:37 +03:00
Ivan Kolesikov
6037618942 Fix missing abs declaration on Emscripten 2022-12-09 00:24:53 +01:00
Recep Aslantas
c6d198d780 Merge pull request #268 from bl4ckb0ne/test-clamp-fix
test_clamp: use glm_eq for floating point comparison
2022-12-07 23:17:13 +03:00
Simon Zeni
d001593f9c test_clamp: use glm_eq for floating point comparison
Fixes #266
2022-12-07 15:06:45 -05:00
Recep Aslantas
ac9461778c possible fix for https://github.com/recp/cglm/issues/266 2022-12-07 12:57:26 +03:00
Recep Aslantas
0b3d227568 Merge branch 'master' of https://github.com/recp/cglm 2022-12-07 12:55:57 +03:00
Recep Aslantas
78236d24a1 now working on v0.8.8 2022-12-07 12:55:51 +03:00
Recep Aslantas
b41858f184 Merge pull request #265 from duarm/abs-functions
New abs functions for vec2, ivec2, ivec3, ivec4
2022-11-20 12:16:49 +03:00
duarm
60bf21ba43 add missing table of contents 2022-11-19 17:48:32 -03:00
duarm
2386cdcc19 docs 2022-11-19 17:46:08 -03:00
duarm
a0f01c5ed1 new abs functions for vec2, ivec2, ivec3, ivec4 2022-11-18 14:28:39 -03:00
33 changed files with 360 additions and 65 deletions

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8.2)
project(cglm
VERSION 0.8.7
VERSION 0.8.9
HOMEPAGE_URL https://github.com/recp/cglm
DESCRIPTION "OpenGL Mathematics (glm) for C"
LANGUAGES C
@@ -41,7 +41,9 @@ else()
add_compile_options(-Wall -Werror -O3)
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
@@ -157,7 +159,21 @@ install(EXPORT ${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
set(PACKAGE_NAME ${PROJECT_NAME})
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
if (IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(libdir "${CMAKE_INSTALL_LIBDIR}")
else()
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()
set(PACKAGE_VERSION "${PROJECT_VERSION}")
configure_file(cglm.pc.in cglm.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/cglm.pc
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cglm.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

View File

@@ -1,11 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix="${prefix}"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include"
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: @PROJECT_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Name: @PACKAGE_NAME@
Description: OpenGL Mathematics (glm) for C
URL: https://github.com/recp/cglm
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lcglm @LIBS@

View File

@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
# Description
s.name = "cglm"
s.version = "0.8.4"
s.version = "0.8.8"
s.summary = "📽 Highly Optimized Graphics Math (glm) for C"
s.description = <<-DESC
cglm is math library for graphics programming for C. See the documentation or README for all features.

View File

@@ -7,7 +7,7 @@
#*****************************************************************************
AC_PREREQ([2.69])
AC_INIT([cglm], [0.8.7], [info@recp.me])
AC_INIT([cglm], [0.8.9], [info@recp.me])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects serial-tests])
# Don't use the default cflags (-O2 -g), we set ours manually in Makefile.am.

View File

@@ -62,9 +62,9 @@ author = u'Recep Aslantas'
# built documents.
#
# The short X.Y version.
version = u'0.8.7'
version = u'0.8.9'
# The full version, including alpha/beta/rc tags.
release = u'0.8.7'
release = u'0.8.9'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@@ -8,6 +8,13 @@ Header: cglm/ivec2.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_IVEC2_ONE_INIT
#. GLM_IVEC2_ZERO_INIT
#. GLM_IVEC2_ONE
#. GLM_IVEC2_ZERO
Functions:
1. :c:func:`glm_ivec2`
@@ -25,6 +32,7 @@ Functions:
#. :c:func:`glm_ivec2_maxv`
#. :c:func:`glm_ivec2_minv`
#. :c:func:`glm_ivec2_clamp`
#. :c:func:`glm_ivec2_abs`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -161,3 +169,11 @@ Functions documentation
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_ivec2_abs(ivec2 v, ivec2 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector

View File

@@ -8,6 +8,13 @@ Header: cglm/ivec3.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_IVEC3_ONE_INIT
#. GLM_IVEC3_ZERO_INIT
#. GLM_IVEC3_ONE
#. GLM_IVEC3_ZERO
Functions:
1. :c:func:`glm_ivec3`
@@ -25,6 +32,7 @@ Functions:
#. :c:func:`glm_ivec3_maxv`
#. :c:func:`glm_ivec3_minv`
#. :c:func:`glm_ivec3_clamp`
#. :c:func:`glm_ivec2_abs`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -161,3 +169,11 @@ Functions documentation
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_ivec3_abs(ivec3 v, ivec3 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector

View File

@@ -8,6 +8,13 @@ Header: cglm/ivec4.h
Table of contents (click to go):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macros:
1. GLM_IVEC4_ONE_INIT
#. GLM_IVEC4_ZERO_INIT
#. GLM_IVEC4_ONE
#. GLM_IVEC4_ZERO
Functions:
1. :c:func:`glm_ivec4`
@@ -25,6 +32,7 @@ Functions:
#. :c:func:`glm_ivec4_maxv`
#. :c:func:`glm_ivec4_minv`
#. :c:func:`glm_ivec4_clamp`
#. :c:func:`glm_ivec4_abs`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -161,3 +169,11 @@ Functions documentation
| *[in, out]* **v** vector
| *[in]* **minVal** minimum value
| *[in]* **maxVal** maximum value
.. c:function:: void glm_ivec4_abs(ivec4 v, ivec4 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector

View File

@@ -26,6 +26,7 @@ Functions:
#. :c:func:`glm_vec2_isinf`
#. :c:func:`glm_vec2_isvalid`
#. :c:func:`glm_vec2_sign`
#. :c:func:`glm_vec2_abs`
#. :c:func:`glm_vec2_sqrt`
Functions documentation
@@ -125,6 +126,14 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** sign vector (only keeps signs as -1, 0, -1)
.. c:function:: void glm_vec2_abs(vec2 v, vec2 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec2_sqrt(vec2 v, vec2 dest)
square root of each vector item

View File

@@ -10,10 +10,10 @@ Table of contents (click to go):
Macros:
1. GLM_vec2_ONE_INIT
#. GLM_vec2_ZERO_INIT
#. GLM_vec2_ONE
#. GLM_vec2_ZERO
1. GLM_VEC2_ONE_INIT
#. GLM_VEC2_ZERO_INIT
#. GLM_VEC2_ONE
#. GLM_VEC2_ZERO
Functions:

View File

@@ -27,6 +27,7 @@ Functions:
#. :c:func:`glm_vec3_isinf`
#. :c:func:`glm_vec3_isvalid`
#. :c:func:`glm_vec3_sign`
#. :c:func:`glm_vec3_abs`
#. :c:func:`glm_vec3_sqrt`
Functions documentation
@@ -134,6 +135,14 @@ Functions documentation
| *[in]* **v** vector
| *[out]* **dest** sign vector (only keeps signs as -1, 0, -1)
.. c:function:: void glm_vec3_abs(vec3 v, vec3 dest)
absolute value of each vector item
Parameters:
| *[in]* **v** vector
| *[out]* **dest** destination vector
.. c:function:: void glm_vec3_sqrt(vec3 v, vec3 dest)
square root of each vector item

View File

@@ -73,6 +73,10 @@ CGLM_EXPORT
void
glmc_ivec2_clamp(ivec2 v, int minVal, int maxVal);
CGLM_EXPORT
void
glmc_ivec2_abs(ivec2 v, ivec2 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -73,6 +73,10 @@ CGLM_EXPORT
void
glmc_ivec3_clamp(ivec3 v, int minVal, int maxVal);
CGLM_EXPORT
void
glmc_ivec3_abs(ivec3 v, ivec3 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -73,6 +73,10 @@ CGLM_EXPORT
void
glmc_ivec4_clamp(ivec4 v, int minVal, int maxVal);
CGLM_EXPORT
void
glmc_ivec4_abs(ivec4 v, ivec4 dest);
#ifdef __cplusplus
}
#endif

View File

@@ -145,6 +145,10 @@ CGLM_EXPORT
void
glmc_vec2_clamp(vec2 v, float minval, float maxval);
CGLM_EXPORT
void
glmc_vec2_abs(vec2 v, vec2 dest);
CGLM_EXPORT
void
glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest);

View File

@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <stdbool.h>
@@ -44,7 +45,7 @@
#ifndef CGLM_USE_DEFAULT_EPSILON
# ifndef GLM_FLT_EPSILON
# define GLM_FLT_EPSILON 1e-5
# define GLM_FLT_EPSILON 1e-5f
# endif
#else
# define GLM_FLT_EPSILON FLT_EPSILON

View File

@@ -49,7 +49,7 @@
#endif
#ifndef CGLM_PRINT_MAX_TO_SHORT
# define CGLM_PRINT_MAX_TO_SHORT 1e5
# define CGLM_PRINT_MAX_TO_SHORT 1e5f
#endif
#ifndef CGLM_PRINT_COLOR
@@ -77,9 +77,9 @@ glm_mat4_print(mat4 matrix,
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++) {
if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT)
cwi = sprintf(buff, "% .*f", CGLM_PRINT_PRECISION, matrix[i][j]);
cwi = sprintf(buff, "% .*f", CGLM_PRINT_PRECISION, (double)matrix[i][j]);
else
cwi = sprintf(buff, "% g", matrix[i][j]);
cwi = sprintf(buff, "% g", (double)matrix[i][j]);
cw[i] = GLM_MAX(cw[i], cwi);
}
}
@@ -89,9 +89,9 @@ glm_mat4_print(mat4 matrix,
for (j = 0; j < n; j++)
if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, matrix[j][i]);
fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, (double)matrix[j][i]);
else
fprintf(ostream, " % *g", cw[j], matrix[j][i]);
fprintf(ostream, " % *g", cw[j], (double)matrix[j][i]);
fprintf(ostream, " |\n");
}
@@ -120,9 +120,9 @@ glm_mat3_print(mat3 matrix,
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++) {
if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT)
cwi = sprintf(buff, "% .*f", CGLM_PRINT_PRECISION, matrix[i][j]);
cwi = sprintf(buff, "% .*f", CGLM_PRINT_PRECISION, (double)matrix[i][j]);
else
cwi = sprintf(buff, "% g", matrix[i][j]);
cwi = sprintf(buff, "% g", (double)matrix[i][j]);
cw[i] = GLM_MAX(cw[i], cwi);
}
}
@@ -132,9 +132,9 @@ glm_mat3_print(mat3 matrix,
for (j = 0; j < n; j++)
if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, matrix[j][i]);
fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, (double)matrix[j][i]);
else
fprintf(ostream, " % *g", cw[j], matrix[j][i]);
fprintf(ostream, " % *g", cw[j], (double)matrix[j][i]);
fprintf(ostream, " |\n");
}
@@ -162,9 +162,9 @@ glm_mat2_print(mat2 matrix,
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++) {
if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT)
cwi = sprintf(buff, "% .*f", CGLM_PRINT_PRECISION, matrix[i][j]);
cwi = sprintf(buff, "% .*f", CGLM_PRINT_PRECISION, (double)matrix[i][j]);
else
cwi = sprintf(buff, "% g", matrix[i][j]);
cwi = sprintf(buff, "% g", (double)matrix[i][j]);
cw[i] = GLM_MAX(cw[i], cwi);
}
}
@@ -174,9 +174,9 @@ glm_mat2_print(mat2 matrix,
for (j = 0; j < n; j++)
if (matrix[i][j] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, matrix[j][i]);
fprintf(ostream, " % *.*f", cw[j], CGLM_PRINT_PRECISION, (double)matrix[j][i]);
else
fprintf(ostream, " % *g", cw[j], matrix[j][i]);
fprintf(ostream, " % *g", cw[j], (double)matrix[j][i]);
fprintf(ostream, " |\n");
}
@@ -199,9 +199,9 @@ glm_vec4_print(vec4 vec,
for (i = 0; i < m; i++) {
if (vec[i] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, vec[i]);
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]);
else
fprintf(ostream, " % g", vec[i]);
fprintf(ostream, " % g", (double)vec[i]);
}
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
@@ -221,9 +221,9 @@ glm_vec3_print(vec3 vec,
for (i = 0; i < m; i++) {
if (vec[i] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, vec[i]);
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]);
else
fprintf(ostream, " % g", vec[i]);
fprintf(ostream, " % g", (double)vec[i]);
}
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
@@ -261,9 +261,9 @@ glm_vec2_print(vec2 vec,
for (i = 0; i < m; i++) {
if (vec[i] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, vec[i]);
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]);
else
fprintf(ostream, " % g", vec[i]);
fprintf(ostream, " % g", (double)vec[i]);
}
fprintf(ostream, " )" CGLM_PRINT_COLOR_RESET "\n\n");
@@ -283,9 +283,9 @@ glm_versor_print(versor vec,
for (i = 0; i < m; i++) {
if (vec[i] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, vec[i]);
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)vec[i]);
else
fprintf(ostream, " % g", vec[i]);
fprintf(ostream, " % g", (double)vec[i]);
}
@@ -310,9 +310,9 @@ glm_aabb_print(vec3 bbox[2],
for (j = 0; j < m; j++) {
if (bbox[i][j] < CGLM_PRINT_MAX_TO_SHORT)
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, bbox[i][j]);
fprintf(ostream, " % .*f", CGLM_PRINT_PRECISION, (double)bbox[i][j]);
else
fprintf(ostream, " % g", bbox[i][j]);
fprintf(ostream, " % g", (double)bbox[i][j]);
}
fprintf(ostream, " )\n");

View File

@@ -6,7 +6,13 @@
*/
/*
FUNCTIONS:
Macros:
GLM_IVEC2_ONE_INIT
GLM_IVEC2_ZERO_INIT
GLM_IVEC2_ONE
GLM_IVEC2_ZERO
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)
@@ -22,6 +28,7 @@ FUNCTIONS:
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)
CGLM_INLINE void glm_ivec2_abs(ivec2 v, ivec2 dest)
*/
#ifndef cglm_ivec2_h
@@ -29,6 +36,12 @@ FUNCTIONS:
#include "common.h"
#define GLM_IVEC2_ONE_INIT {1, 1}
#define GLM_IVEC2_ZERO_INIT {0, 0}
#define GLM_IVEC2_ONE ((ivec2)GLM_IVEC2_ONE_INIT)
#define GLM_IVEC2_ZERO ((ivec2)GLM_IVEC2_ZERO_INIT)
/*!
* @brief init ivec2 using vec3 or vec4
*
@@ -239,4 +252,17 @@ glm_ivec2_clamp(ivec2 v, int minVal, int maxVal) {
v[1] = maxVal;
}
/*!
* @brief absolute value of v
*
* @param[in] v vector
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_ivec2_abs(ivec2 v, ivec2 dest) {
dest[0] = abs(v[0]);
dest[1] = abs(v[1]);
}
#endif /* cglm_ivec2_h */

View File

@@ -6,7 +6,13 @@
*/
/*
FUNCTIONS:
Macros:
GLM_IVEC3_ONE_INIT
GLM_IVEC3_ZERO_INIT
GLM_IVEC3_ONE
GLM_IVEC3_ZERO
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)
@@ -22,6 +28,7 @@ FUNCTIONS:
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)
CGLM_INLINE void glm_ivec3_abs(ivec3 v, ivec3 dest)
*/
#ifndef cglm_ivec3_h
@@ -29,6 +36,12 @@ FUNCTIONS:
#include "common.h"
#define GLM_IVEC3_ONE_INIT {1, 1, 1}
#define GLM_IVEC3_ZERO_INIT {0, 0, 0}
#define GLM_IVEC3_ONE ((ivec3)GLM_IVEC3_ONE_INIT)
#define GLM_IVEC3_ZERO ((ivec3)GLM_IVEC3_ZERO_INIT)
/*!
* @brief init ivec3 using ivec4
*
@@ -255,4 +268,18 @@ glm_ivec3_clamp(ivec3 v, int minVal, int maxVal) {
v[2] = maxVal;
}
/*!
* @brief absolute value of v
*
* @param[in] v vector
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_ivec3_abs(ivec3 v, ivec3 dest) {
dest[0] = abs(v[0]);
dest[1] = abs(v[1]);
dest[2] = abs(v[2]);
}
#endif /* cglm_ivec3_h */

View File

@@ -6,7 +6,13 @@
*/
/*
FUNCTIONS:
Macros:
GLM_IVEC4_ONE_INIT
GLM_IVEC4_ZERO_INIT
GLM_IVEC4_ONE
GLM_IVEC4_ZERO
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)
@@ -22,6 +28,7 @@ FUNCTIONS:
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)
CGLM_INLINE void glm_ivec4_abs(ivec4 v, ivec4 dest)
*/
#ifndef cglm_ivec4_h
@@ -29,6 +36,12 @@ FUNCTIONS:
#include "common.h"
#define GLM_IVEC4_ONE_INIT {1, 1, 1, 1}
#define GLM_IVEC4_ZERO_INIT {0, 0, 0, 0}
#define GLM_IVEC4_ONE ((ivec4)GLM_IVEC4_ONE_INIT)
#define GLM_IVEC4_ZERO ((ivec4)GLM_IVEC4_ZERO_INIT)
/*!
* @brief init ivec4 using ivec3
*
@@ -272,4 +285,19 @@ glm_ivec4_clamp(ivec4 v, int minVal, int maxVal) {
v[3] = maxVal;
}
/*!
* @brief absolute value of v
*
* @param[in] v vector
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_ivec4_abs(ivec4 v, ivec4 dest) {
dest[0] = abs(v[0]);
dest[1] = abs(v[1]);
dest[2] = abs(v[2]);
dest[3] = abs(v[3]);
}
#endif /* cglm_ivec4_h */

View File

@@ -19,6 +19,7 @@
CGLM_INLINE bool glm_vec2_isinf(vec2 v);
CGLM_INLINE bool glm_vec2_isvalid(vec2 v);
CGLM_INLINE void glm_vec2_sign(vec2 v, vec2 dest);
CGLM_INLINE void glm_vec2_abs(vec2 v, vec2 dest);
CGLM_INLINE void glm_vec2_sqrt(vec2 v, vec2 dest);
CGLM_INLINE void glm_vec2_complex_mul(vec2 a, vec2 b, vec2 dest)
CGLM_INLINE void glm_vec2_complex_div(vec2 a, vec2 b, vec2 dest)
@@ -176,6 +177,19 @@ glm_vec2_sign(vec2 v, vec2 dest) {
dest[1] = glm_signf(v[1]);
}
/*!
* @brief absolute value of v
*
* @param[in] v vector
* @param[out] dest destination
*/
CGLM_INLINE
void
glm_vec2_abs(vec2 v, vec2 dest) {
dest[0] = fabsf(v[0]);
dest[1] = fabsf(v[1]);
}
/*!
* @brief square root of each vector item
*
@@ -237,5 +251,4 @@ glm_vec2_complex_conjugate(vec2 a, vec2 dest) {
dest[1] = -a[1];
}
#endif /* cglm_vec2_ext_h */

View File

@@ -10,6 +10,6 @@
#define CGLM_VERSION_MAJOR 0
#define CGLM_VERSION_MINOR 8
#define CGLM_VERSION_PATCH 7
#define CGLM_VERSION_PATCH 9
#endif /* cglm_version_h */

View File

@@ -1,5 +1,5 @@
project('cglm', 'c',
version : '0.8.7',
version : '0.8.9',
license : 'mit',
default_options : [
'c_std=c11',

View File

@@ -97,3 +97,10 @@ void
glmc_ivec2_clamp(ivec2 v, int minVal, int maxVal) {
glm_ivec2_clamp(v, minVal, maxVal);
}
CGLM_EXPORT
void
glmc_ivec2_abs(ivec2 v, ivec2 dest) {
glm_ivec2_abs(v, dest);
}

View File

@@ -97,3 +97,10 @@ void
glmc_ivec3_clamp(ivec3 v, int minVal, int maxVal) {
glm_ivec3_clamp(v, minVal, maxVal);
}
CGLM_EXPORT
void
glmc_ivec3_abs(ivec3 v, ivec3 dest) {
glm_ivec3_abs(v, dest);
}

View File

@@ -97,3 +97,10 @@ void
glmc_ivec4_clamp(ivec4 v, int minVal, int maxVal) {
glm_ivec4_clamp(v, minVal, maxVal);
}
CGLM_EXPORT
void
glmc_ivec4_abs(ivec4 v, ivec4 dest) {
glm_ivec4_abs(v, dest);
}

View File

@@ -206,6 +206,12 @@ glmc_vec2_clamp(vec2 v, float minval, float maxval) {
glm_vec2_clamp(v, minval, maxval);
}
CGLM_EXPORT
void
glmc_vec2_abs(vec2 v, vec2 dest) {
glm_vec2_abs(v, dest);
}
CGLM_EXPORT
void
glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest) {

View File

@@ -11,21 +11,21 @@ TEST_IMPL(clamp) {
vec3 v3 = {15.07f, 0.4f, 17.3f};
vec4 v4 = {5.07f, 2.3f, 1.3f, 1.4f};
ASSERT(glm_clamp(1.6f, 0.0f, 1.0f) == 1.0f)
ASSERT(glm_clamp(-1.6f, 0.0f, 1.0f) == 0.0f)
ASSERT(glm_clamp(0.6f, 0.0f, 1.0f) == 0.6f)
ASSERT(glm_eq(glm_clamp(1.6f, 0.0f, 1.0f), 1.0f))
ASSERT(glm_eq(glm_clamp(-1.6f, 0.0f, 1.0f), 0.0f))
ASSERT(glm_eq(glm_clamp(0.6f, 0.0f, 1.0f), 0.6f))
glm_vec3_clamp(v3, 0.0, 1.0);
glm_vec4_clamp(v4, 1.5, 3.0);
ASSERT(v3[0] == 1.0f)
ASSERT(v3[1] == 0.4f)
ASSERT(v3[2] == 1.0f)
ASSERT(glm_eq(v3[0], 1.0f))
ASSERT(glm_eq(v3[1], 0.4f))
ASSERT(glm_eq(v3[2], 1.0f))
ASSERT(v4[0] == 3.0f)
ASSERT(v4[1] == 2.3f)
ASSERT(v4[2] == 1.5f)
ASSERT(v4[3] == 1.5f)
ASSERT(glm_eq(v4[0], 3.0f))
ASSERT(glm_eq(v4[1], 2.3f))
ASSERT(glm_eq(v4[2], 1.5f))
ASSERT(glm_eq(v4[3], 1.5f))
TEST_SUCCESS
}

View File

@@ -187,3 +187,18 @@ TEST_IMPL(GLM_PREFIX, ivec2_clamp) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec2_abs) {
ivec2 v1 = {2, -3}, v2 = {-12, -31};
ivec2 v3, v4;
GLM(ivec2_abs)(v1, v3);
GLM(ivec2_abs)(v2, v4);
ASSERT(v3[0] == 2)
ASSERT(v3[1] == 3)
ASSERT(v4[0] == 12)
ASSERT(v4[1] == 31)
TEST_SUCCESS
}

View File

@@ -197,3 +197,20 @@ TEST_IMPL(GLM_PREFIX, ivec3_clamp) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec3_abs) {
ivec3 v1 = {2, -3, 4}, v2 = {-12, -31, -42};
ivec3 v3, v4;
GLM(ivec3_abs)(v1, v3);
GLM(ivec3_abs)(v2, v4);
ASSERT(v3[0] == 2)
ASSERT(v3[1] == 3)
ASSERT(v3[2] == 4)
ASSERT(v4[0] == 12)
ASSERT(v4[1] == 31)
ASSERT(v4[2] == 42)
TEST_SUCCESS
}

View File

@@ -212,3 +212,22 @@ TEST_IMPL(GLM_PREFIX, ivec4_clamp) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, ivec4_abs) {
ivec4 v1 = {2, -3, 4, -5}, v2 = {-12, -31, -42, -50};
ivec4 v3, v4;
GLM(ivec4_abs)(v1, v3);
GLM(ivec4_abs)(v2, v4);
ASSERT(v3[0] == 2)
ASSERT(v3[1] == 3)
ASSERT(v3[2] == 4)
ASSERT(v3[3] == 5)
ASSERT(v4[0] == 12)
ASSERT(v4[1] == 31)
ASSERT(v4[2] == 42)
ASSERT(v4[3] == 50)
TEST_SUCCESS
}

View File

@@ -579,6 +579,20 @@ TEST_IMPL(GLM_PREFIX, vec2_clamp) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, vec2_abs) {
vec2 v1 = {2, -3}, v2 = {-12, -31};
vec2 v3, v4;
vec2 v5 = {2, 3}, v6 = {12, 31};
GLM(vec2_abs)(v1, v3);
GLM(vec2_abs)(v2, v4);
ASSERTIFY(test_assert_vec2_eq(v3, v5))
ASSERTIFY(test_assert_vec2_eq(v4, v6))
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, vec2_lerp) {
vec2 v1 = {-100.0f, -200.0f};
vec2 v2 = {100.0f, 200.0f};

View File

@@ -379,6 +379,7 @@ TEST_DECLARE(glm_vec2_distance)
TEST_DECLARE(glm_vec2_maxv)
TEST_DECLARE(glm_vec2_minv)
TEST_DECLARE(glm_vec2_clamp)
TEST_DECLARE(glm_vec2_abs)
TEST_DECLARE(glm_vec2_lerp)
TEST_DECLARE(glm_vec2_complex_mul)
TEST_DECLARE(glm_vec2_complex_div)
@@ -416,6 +417,7 @@ TEST_DECLARE(glmc_vec2_distance)
TEST_DECLARE(glmc_vec2_maxv)
TEST_DECLARE(glmc_vec2_minv)
TEST_DECLARE(glmc_vec2_clamp)
TEST_DECLARE(glmc_vec2_abs)
TEST_DECLARE(glmc_vec2_lerp)
TEST_DECLARE(glmc_vec2_complex_mul)
TEST_DECLARE(glmc_vec2_complex_div)
@@ -746,6 +748,7 @@ TEST_DECLARE(glm_ivec2_distance)
TEST_DECLARE(glm_ivec2_maxv)
TEST_DECLARE(glm_ivec2_minv)
TEST_DECLARE(glm_ivec2_clamp)
TEST_DECLARE(glm_ivec2_abs)
TEST_DECLARE(glmc_ivec2)
TEST_DECLARE(glmc_ivec2_copy)
@@ -762,6 +765,7 @@ TEST_DECLARE(glmc_ivec2_distance)
TEST_DECLARE(glmc_ivec2_maxv)
TEST_DECLARE(glmc_ivec2_minv)
TEST_DECLARE(glmc_ivec2_clamp)
TEST_DECLARE(glmc_ivec2_abs)
/* ivec3 */
TEST_DECLARE(glm_ivec3)
@@ -812,6 +816,7 @@ TEST_DECLARE(glm_ivec4_distance)
TEST_DECLARE(glm_ivec4_maxv)
TEST_DECLARE(glm_ivec4_minv)
TEST_DECLARE(glm_ivec4_clamp)
TEST_DECLARE(glm_ivec4_abs)
TEST_DECLARE(glmc_ivec4)
TEST_DECLARE(glmc_ivec4_copy)
@@ -828,6 +833,7 @@ TEST_DECLARE(glmc_ivec4_distance)
TEST_DECLARE(glmc_ivec4_maxv)
TEST_DECLARE(glmc_ivec4_minv)
TEST_DECLARE(glmc_ivec4_clamp)
TEST_DECLARE(glmc_ivec4_abs)
/* structs */
TEST_DECLARE(mat3s_identity_init)
@@ -1244,6 +1250,7 @@ TEST_LIST {
TEST_ENTRY(glmc_vec2_maxv)
TEST_ENTRY(glmc_vec2_minv)
TEST_ENTRY(glmc_vec2_clamp)
TEST_ENTRY(glmc_vec2_abs)
TEST_ENTRY(glmc_vec2_lerp)
TEST_ENTRY(glmc_vec2_complex_mul)
TEST_ENTRY(glmc_vec2_complex_div)
@@ -1573,6 +1580,7 @@ TEST_LIST {
TEST_ENTRY(glm_ivec2_maxv)
TEST_ENTRY(glm_ivec2_minv)
TEST_ENTRY(glm_ivec2_clamp)
TEST_ENTRY(glm_ivec2_abs)
TEST_ENTRY(glmc_ivec2)
TEST_ENTRY(glmc_ivec2_copy)
@@ -1589,6 +1597,7 @@ TEST_LIST {
TEST_ENTRY(glmc_ivec2_maxv)
TEST_ENTRY(glmc_ivec2_minv)
TEST_ENTRY(glmc_ivec2_clamp)
TEST_ENTRY(glmc_ivec2_abs)
/* ivec3 */
TEST_ENTRY(glm_ivec3)
@@ -1655,6 +1664,7 @@ TEST_LIST {
TEST_ENTRY(glmc_ivec4_maxv)
TEST_ENTRY(glmc_ivec4_minv)
TEST_ENTRY(glmc_ivec4_clamp)
TEST_ENTRY(glmc_ivec4_abs)
/* structs */
TEST_ENTRY(mat3s_identity_init)