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

@@ -327,4 +327,26 @@ TEST_IMPL(GLM_PREFIX, mat3_make) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, mat3_textrans) {
mat3 m, expected;
float sx = 2.0f, sy = 3.0f, rot = GLM_PI_4f;
float tx = 10.0f, ty = 20.0f;
GLM(mat3_textrans)(sx, sy, rot, tx, ty, m);
ASSERT(test_eq(m[0][0], cosf(rot) * sx))
ASSERT(test_eq(m[0][1],-sinf(rot) * sy))
ASSERT(test_eq(m[1][0], sinf(rot) * sx))
ASSERT(test_eq(m[1][1], cosf(rot) * sy))
ASSERT(test_eq(m[2][0], tx))
ASSERT(test_eq(m[2][1], ty))
GLM(mat3_textrans)(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, m);
GLM(mat3_identity)(expected);
ASSERTIFY(test_assert_mat3_eq(m, expected))
TEST_SUCCESS
}
#undef A_MATRIX

View File

@@ -504,5 +504,27 @@ TEST_IMPL(GLM_PREFIX, mat4_make) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, mat4_textrans) {
mat4 m, expected;
float sx = 2.0f, sy = 3.0f, rot = GLM_PI_4f;
float tx = 10.0f, ty = 20.0f;
GLM(mat4_textrans)(sx, sy, rot, tx, ty, m);
ASSERT(test_eq(m[0][0], cosf(rot) * sx))
ASSERT(test_eq(m[0][1],-sinf(rot) * sy))
ASSERT(test_eq(m[1][0], sinf(rot) * sx))
ASSERT(test_eq(m[1][1], cosf(rot) * sy))
ASSERT(test_eq(m[3][0], tx))
ASSERT(test_eq(m[3][1], ty))
GLM(mat4_textrans)(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, m);
GLM(mat4_identity)(expected);
ASSERTIFY(test_assert_mat4_eq(m, expected))
TEST_SUCCESS
}
#undef A_MATRIX
#undef A_MATRIX3

View File

@@ -136,6 +136,7 @@ TEST_DECLARE(glm_mat4_swap_col)
TEST_DECLARE(glm_mat4_swap_row)
TEST_DECLARE(glm_mat4_rmc)
TEST_DECLARE(glm_mat4_make)
TEST_DECLARE(glm_mat4_textrans)
TEST_DECLARE(glmc_mat4_ucopy)
TEST_DECLARE(glmc_mat4_copy)
@@ -218,6 +219,7 @@ TEST_DECLARE(glm_mat3_swap_col)
TEST_DECLARE(glm_mat3_swap_row)
TEST_DECLARE(glm_mat3_rmc)
TEST_DECLARE(glm_mat3_make)
TEST_DECLARE(glm_mat3_textrans)
TEST_DECLARE(glmc_mat3_copy)
TEST_DECLARE(glmc_mat3_identity)
@@ -1355,7 +1357,8 @@ TEST_LIST {
TEST_ENTRY(glm_mat4_swap_row)
TEST_ENTRY(glm_mat4_rmc)
TEST_ENTRY(glm_mat4_make)
TEST_ENTRY(glm_mat4_textrans)
TEST_ENTRY(glmc_mat4_ucopy)
TEST_ENTRY(glmc_mat4_copy)
TEST_ENTRY(glmc_mat4_identity)
@@ -1437,6 +1440,7 @@ TEST_LIST {
TEST_ENTRY(glm_mat3_swap_row)
TEST_ENTRY(glm_mat3_rmc)
TEST_ENTRY(glm_mat3_make)
TEST_ENTRY(glm_mat3_textrans)
TEST_ENTRY(glmc_mat3_copy)
TEST_ENTRY(glmc_mat3_identity)