build texture transform matrix helper

This commit is contained in:
Recep Aslantas
2025-04-05 13:32:47 +03:00
parent ebc65782f8
commit 5fde20d65c
13 changed files with 191 additions and 1 deletions

View File

@@ -31,6 +31,7 @@
CGLM_INLINE void glm_mat3_swap_row(mat3 mat, int row1, int row2);
CGLM_INLINE float glm_mat3_rmc(vec3 r, mat3 m, vec3 c);
CGLM_INLINE void glm_mat3_make(float * restrict src, mat3 dest);
CGLM_INLINE void glm_mat4_textrans(float sx, float sy, float rot, float tx, float ty, mat4 dest);
*/
#ifndef cglm_mat3_h
@@ -448,4 +449,32 @@ glm_mat3_make(const float * __restrict src, mat3 dest) {
dest[2][2] = src[8];
}
/*!
* @brief Create mat3 matrix from texture transform parameters
*
* @param[in] sx scale x
* @param[in] sy scale y
* @param[in] rot rotation in radians CCW/RH
* @param[in] tx translate x
* @param[in] ty translate y
* @param[out] dest texture transform matrix
*/
CGLM_INLINE
void
glm_mat3_textrans(float sx, float sy, float rot, float tx, float ty, mat3 dest) {
float c, s;
c = cosf(rot);
s = sinf(rot);
glm_mat3_identity(dest);
dest[0][0] = c * sx;
dest[0][1] = -s * sy;
dest[1][0] = s * sx;
dest[1][1] = c * sy;
dest[2][0] = tx;
dest[2][1] = ty;
}
#endif /* cglm_mat3_h */