[ADD] template project with correct name
This commit is contained in:
52
lib/glm/test/core/CMakeLists.txt
Normal file
52
lib/glm/test/core/CMakeLists.txt
Normal file
@@ -0,0 +1,52 @@
|
||||
glmCreateTestGTC(core_cpp_constexpr)
|
||||
glmCreateTestGTC(core_cpp_defaulted_ctor)
|
||||
glmCreateTestGTC(core_force_aligned_gentypes)
|
||||
glmCreateTestGTC(core_force_ctor_init)
|
||||
glmCreateTestGTC(core_force_cxx03)
|
||||
glmCreateTestGTC(core_force_cxx98)
|
||||
glmCreateTestGTC(core_force_arch_unknown)
|
||||
glmCreateTestGTC(core_force_compiler_unknown)
|
||||
glmCreateTestGTC(core_force_cxx_unknown)
|
||||
glmCreateTestGTC(core_force_explicit_ctor)
|
||||
glmCreateTestGTC(core_force_inline)
|
||||
glmCreateTestGTC(core_force_platform_unknown)
|
||||
glmCreateTestGTC(core_force_pure)
|
||||
glmCreateTestGTC(core_force_unrestricted_gentype)
|
||||
glmCreateTestGTC(core_force_xyzw_only)
|
||||
glmCreateTestGTC(core_force_quat_wxyz)
|
||||
glmCreateTestGTC(core_type_aligned)
|
||||
glmCreateTestGTC(core_type_cast)
|
||||
glmCreateTestGTC(core_type_ctor)
|
||||
glmCreateTestGTC(core_type_int)
|
||||
glmCreateTestGTC(core_type_length)
|
||||
glmCreateTestGTC(core_type_mat2x2)
|
||||
glmCreateTestGTC(core_type_mat2x3)
|
||||
glmCreateTestGTC(core_type_mat2x4)
|
||||
glmCreateTestGTC(core_type_mat3x2)
|
||||
glmCreateTestGTC(core_type_mat3x3)
|
||||
glmCreateTestGTC(core_type_mat3x4)
|
||||
glmCreateTestGTC(core_type_mat4x2)
|
||||
glmCreateTestGTC(core_type_mat4x3)
|
||||
glmCreateTestGTC(core_type_mat4x4)
|
||||
glmCreateTestGTC(core_type_vec1)
|
||||
glmCreateTestGTC(core_type_vec2)
|
||||
glmCreateTestGTC(core_type_vec3)
|
||||
glmCreateTestGTC(core_type_vec4)
|
||||
glmCreateTestGTC(core_func_common)
|
||||
glmCreateTestGTC(core_func_exponential)
|
||||
glmCreateTestGTC(core_func_geometric)
|
||||
glmCreateTestGTC(core_func_integer)
|
||||
glmCreateTestGTC(core_func_integer_bit_count)
|
||||
glmCreateTestGTC(core_func_integer_find_lsb)
|
||||
glmCreateTestGTC(core_func_integer_find_msb)
|
||||
glmCreateTestGTC(core_func_matrix)
|
||||
glmCreateTestGTC(core_func_noise)
|
||||
glmCreateTestGTC(core_func_packing)
|
||||
glmCreateTestGTC(core_func_trigonometric)
|
||||
glmCreateTestGTC(core_func_vector_relational)
|
||||
glmCreateTestGTC(core_func_swizzle)
|
||||
glmCreateTestGTC(core_setup_force_cxx98)
|
||||
glmCreateTestGTC(core_setup_force_size_t_length)
|
||||
glmCreateTestGTC(core_setup_message)
|
||||
glmCreateTestGTC(core_setup_platform_unknown)
|
||||
glmCreateTestGTC(core_setup_precision)
|
||||
750
lib/glm/test/core/core_cpp_constexpr.cpp
Normal file
750
lib/glm/test/core/core_cpp_constexpr.cpp
Normal file
@@ -0,0 +1,750 @@
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_int1.hpp>
|
||||
#include <glm/ext/vector_bool1.hpp>
|
||||
#include <glm/ext/vector_bool4.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
|
||||
static int test_vec1()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
constexpr glm::bvec1 B(true);
|
||||
constexpr bool A = glm::all(B);
|
||||
static_assert(A, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::bvec1 D(true);
|
||||
constexpr bool C = glm::any(D);
|
||||
static_assert(C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec2 C(true);
|
||||
constexpr glm::bvec2 B(true);
|
||||
static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 O(glm::ivec1(1));
|
||||
static_assert(glm::ivec1(1) == O, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 P(1);
|
||||
static_assert(glm::ivec1(1) == P, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 L(glm::ivec2(1, 2));
|
||||
static_assert(glm::ivec1(1) == L, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 M(glm::ivec3(1, 2, 3));
|
||||
static_assert(glm::ivec1(1) == M, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 N(glm::ivec4(1, 2, 3, 4));
|
||||
static_assert(glm::ivec1(1) == N, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(1);
|
||||
static_assert(A[0] == 1, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec1 A1(true);
|
||||
constexpr glm::bvec1 A2(true);
|
||||
constexpr glm::bvec1 B1(false);
|
||||
constexpr glm::bvec1 B2(false);
|
||||
static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
|
||||
static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(1);
|
||||
constexpr glm::ivec1 B = A + 1;
|
||||
constexpr glm::ivec1 C(3);
|
||||
static_assert(A + B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 D = +A;
|
||||
static_assert(D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(3);
|
||||
constexpr glm::ivec1 B = A - 1;
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A - B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 D = -A;
|
||||
static_assert(-D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(3);
|
||||
constexpr glm::ivec1 B = A * 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B * C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(3);
|
||||
constexpr glm::ivec1 B = A / 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B / C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(3);
|
||||
constexpr glm::ivec1 B = A % 2;
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 D(2);
|
||||
static_assert(A % D == C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(1);
|
||||
constexpr glm::ivec1 B = A & 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A & C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(1);
|
||||
constexpr glm::ivec1 B = A | 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A | C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(1);
|
||||
constexpr glm::ivec1 B = A ^ 0;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(0);
|
||||
static_assert(A == (A ^ C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(1);
|
||||
constexpr glm::ivec1 B = A << 1;
|
||||
static_assert(B == glm::ivec1(2), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == (A << C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(2);
|
||||
constexpr glm::ivec1 B = A >> 1;
|
||||
static_assert(B == glm::ivec1(1), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == A >> C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec1 A(~0);
|
||||
constexpr glm::ivec1 B = ~A;
|
||||
static_assert(A == ~B, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
constexpr glm::bvec2 B(true);
|
||||
constexpr bool A = glm::all(B);
|
||||
static_assert(A, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::bvec2 D(true, false);
|
||||
constexpr bool C = glm::any(D);
|
||||
static_assert(C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec2 C(true);
|
||||
constexpr glm::bvec2 B(true, false);
|
||||
static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 O(glm::ivec1(1));
|
||||
static_assert(glm::ivec2(1) == O, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 A(1);
|
||||
static_assert(glm::ivec2(1) == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 F(glm::ivec1(1), glm::ivec1(2));
|
||||
static_assert(glm::ivec2(1, 2) == F, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 G(1, glm::ivec1(2));
|
||||
static_assert(glm::ivec2(1, 2) == G, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 H(glm::ivec1(1), 2);
|
||||
static_assert(glm::ivec2(1, 2) == H, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 I(1, 2);
|
||||
static_assert(glm::ivec2(1, 2) == I, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 L(glm::ivec2(1, 2));
|
||||
static_assert(glm::ivec2(1, 2) == L, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 M(glm::ivec3(1, 2, 3));
|
||||
static_assert(glm::ivec2(1, 2) == M, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 N(glm::ivec4(1, 2, 3, 4));
|
||||
static_assert(glm::ivec2(1, 2) == N, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(1);
|
||||
static_assert(A[0] == 1, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2(1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2(1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2::length() == 2, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec2 A1(true);
|
||||
constexpr glm::bvec2 A2(true);
|
||||
constexpr glm::bvec2 B1(false);
|
||||
constexpr glm::bvec2 B2(false);
|
||||
static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
|
||||
static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(1);
|
||||
constexpr glm::ivec2 B = A + 1;
|
||||
constexpr glm::ivec2 C(3);
|
||||
static_assert(A + B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 D = +A;
|
||||
static_assert(D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(3);
|
||||
constexpr glm::ivec2 B = A - 1;
|
||||
constexpr glm::ivec2 C(1);
|
||||
static_assert(A - B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 D = -A;
|
||||
static_assert(-D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(3);
|
||||
constexpr glm::ivec2 B = A * 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 C(1);
|
||||
static_assert(B * C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(3);
|
||||
constexpr glm::ivec2 B = A / 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec2 C(1);
|
||||
static_assert(B / C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(3);
|
||||
constexpr glm::ivec2 B = A % 2;
|
||||
constexpr glm::ivec2 C(1);
|
||||
static_assert(B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 D(2);
|
||||
static_assert(A % D == C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(1);
|
||||
constexpr glm::ivec2 B = A & 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A & C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(1);
|
||||
constexpr glm::ivec2 B = A | 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A | C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(1);
|
||||
constexpr glm::ivec2 B = A ^ 0;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(0);
|
||||
static_assert(A == (A ^ C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(1);
|
||||
constexpr glm::ivec2 B = A << 1;
|
||||
static_assert(B == glm::ivec2(2), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == (A << C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(2);
|
||||
constexpr glm::ivec2 B = A >> 1;
|
||||
static_assert(B == glm::ivec2(1), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == A >> C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec2 A(~0);
|
||||
constexpr glm::ivec2 B = ~A;
|
||||
static_assert(A == ~B, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec3()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
constexpr glm::bvec3 B(true);
|
||||
constexpr bool A = glm::all(B);
|
||||
static_assert(A, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::bvec3 D(true, false, true);
|
||||
constexpr bool C = glm::any(D);
|
||||
static_assert(C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec3 C(true);
|
||||
constexpr glm::bvec3 B(true, false, true);
|
||||
static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 O(glm::ivec1(1));
|
||||
static_assert(glm::ivec3(1) == O, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 A(1);
|
||||
static_assert(glm::ivec3(1) == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 B(glm::ivec2(1, 2), 3);
|
||||
static_assert(glm::ivec3(1, 2, 3) == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 C(1, glm::ivec2(2, 3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 D(glm::ivec1(1), glm::ivec2(2, 3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == D, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 E(glm::ivec2(1, 2), glm::ivec1(3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == E, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 F(glm::ivec1(1), glm::ivec1(2), glm::ivec1(3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == F, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 G(1, glm::ivec1(2), glm::ivec1(3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == G, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 H(glm::ivec1(1), 2, glm::ivec1(3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == H, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 I(1, 2, glm::ivec1(3));
|
||||
static_assert(glm::ivec3(1, 2, 3) == I, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 J(glm::ivec1(1), glm::ivec1(2), 3);
|
||||
static_assert(glm::ivec3(1, 2, 3) == J, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 K(1, glm::ivec1(2), 3);
|
||||
static_assert(glm::ivec3(1, 2, 3) == K, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 L(glm::ivec1(1), 2, 3);
|
||||
static_assert(glm::ivec3(1, 2, 3) == L, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 M(1, 2, 3);
|
||||
static_assert(glm::ivec3(1, 2, 3) == M, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 N(glm::ivec4(1, 2, 3, 4));
|
||||
static_assert(glm::ivec3(1, 2, 3) == N, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 const A(1);
|
||||
static_assert(A[0] == 1, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec3 A1(true);
|
||||
constexpr glm::bvec3 A2(true);
|
||||
constexpr glm::bvec3 B1(false);
|
||||
constexpr glm::bvec3 B2(false);
|
||||
static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
|
||||
static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(1);
|
||||
constexpr glm::ivec3 B = A + 1;
|
||||
constexpr glm::ivec3 C(3);
|
||||
static_assert(A + B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 D = +A;
|
||||
static_assert(D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(3);
|
||||
constexpr glm::ivec3 B = A - 1;
|
||||
constexpr glm::ivec3 C(1);
|
||||
static_assert(A - B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 D = -A;
|
||||
static_assert(-D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(3);
|
||||
constexpr glm::ivec3 B = A * 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 C(1);
|
||||
static_assert(B * C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(3);
|
||||
constexpr glm::ivec3 B = A / 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec3 C(1);
|
||||
static_assert(B / C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(3);
|
||||
constexpr glm::ivec3 B = A % 2;
|
||||
constexpr glm::ivec3 C(1);
|
||||
static_assert(B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 D(2);
|
||||
static_assert(A % D == C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(1);
|
||||
constexpr glm::ivec3 B = A & 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A & C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(1);
|
||||
constexpr glm::ivec3 B = A | 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A | C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(1);
|
||||
constexpr glm::ivec3 B = A ^ 0;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(0);
|
||||
static_assert(A == (A ^ C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(1);
|
||||
constexpr glm::ivec3 B = A << 1;
|
||||
static_assert(B == glm::ivec3(2), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == (A << C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(2);
|
||||
constexpr glm::ivec3 B = A >> 1;
|
||||
static_assert(B == glm::ivec3(1), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == A >> C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec3 A(~0);
|
||||
constexpr glm::ivec3 B = ~A;
|
||||
static_assert(A == ~B, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
constexpr glm::bvec4 B(true);
|
||||
constexpr bool A = glm::all(B);
|
||||
static_assert(A, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::bvec4 D(true, false, true, false);
|
||||
constexpr bool C = glm::any(D);
|
||||
static_assert(C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec4 C(true);
|
||||
constexpr glm::bvec4 B(true, false, true, false);
|
||||
static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 O(glm::ivec4(1));
|
||||
static_assert(glm::ivec4(1) == O, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 A(1);
|
||||
static_assert(glm::ivec4(1) == A, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 N(glm::ivec4(1, 2, 3, 4));
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == N, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(glm::ivec3(1, 2, 3), 4);
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == A, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 B(glm::ivec2(1, 2), glm::ivec2(3, 4));
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 C(1, glm::ivec3(2, 3, 4));
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 D(glm::ivec1(1), glm::ivec2(2, 3), glm::ivec1(4));
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == D, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 E(glm::ivec2(1, 2), glm::ivec1(3), glm::ivec1(4));
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == E, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 F(glm::ivec1(1), glm::ivec1(2), glm::ivec2(3, 4));
|
||||
static_assert(glm::ivec4(1, 2, 3, 4) == F, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(1);
|
||||
static_assert(A[0] == 1, "GLM: Failed constexpr");
|
||||
static_assert(glm::ivec4(1).x > 0, "GLM: Failed constexpr");
|
||||
static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).x > 0, "GLM: Failed constexpr");
|
||||
static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).y < 0, "GLM: Failed constexpr");
|
||||
static_assert(glm::ivec4::length() == 4, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::bvec4 A1(true);
|
||||
constexpr glm::bvec4 A2(true);
|
||||
constexpr glm::bvec4 B1(false);
|
||||
constexpr glm::bvec4 B2(false);
|
||||
static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr");
|
||||
static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(1);
|
||||
constexpr glm::ivec4 B = A + 1;
|
||||
constexpr glm::ivec4 C(3);
|
||||
static_assert(A + B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 D = +A;
|
||||
static_assert(D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(3);
|
||||
constexpr glm::ivec4 B = A - 1;
|
||||
constexpr glm::ivec4 C(1);
|
||||
static_assert(A - B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 D = -A;
|
||||
static_assert(-D == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(3);
|
||||
constexpr glm::ivec4 B = A * 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 C(1);
|
||||
static_assert(B * C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(3);
|
||||
constexpr glm::ivec4 B = A / 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec4 C(1);
|
||||
static_assert(B / C == A, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(3);
|
||||
constexpr glm::ivec4 B = A % 2;
|
||||
constexpr glm::ivec4 C(1);
|
||||
static_assert(B == C, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 D(2);
|
||||
static_assert(A % D == C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(1);
|
||||
constexpr glm::ivec4 B = A & 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A & C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(1);
|
||||
constexpr glm::ivec4 B = A | 1;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(A == (A | C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(1);
|
||||
constexpr glm::ivec4 B = A ^ 0;
|
||||
static_assert(A == B, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(0);
|
||||
static_assert(A == (A ^ C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(1);
|
||||
constexpr glm::ivec4 B = A << 1;
|
||||
static_assert(B == glm::ivec4(2), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == (A << C), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(2);
|
||||
constexpr glm::ivec4 B = A >> 1;
|
||||
static_assert(B == glm::ivec4(1), "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::ivec1 C(1);
|
||||
static_assert(B == A >> C, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
{
|
||||
constexpr glm::ivec4 A(~0);
|
||||
constexpr glm::ivec4 B = ~A;
|
||||
static_assert(A == ~B, "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_quat()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
static_assert(glm::quat::length() == 4, "GLM: Failed constexpr");
|
||||
static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::quat(1.0f, 0.0f, 0.0f, 0.0f).w > 0.0f, "GLM: Failed constexpr");
|
||||
|
||||
glm::quat constexpr Q = glm::identity<glm::quat>();
|
||||
static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon<float>(), "GLM: Failed constexpr");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat2x2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
static_assert(glm::mat2x2::length() == 2, "GLM: Failed constexpr");
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
#endif//GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
Error += test_vec1();
|
||||
Error += test_vec2();
|
||||
Error += test_vec3();
|
||||
Error += test_vec4();
|
||||
Error += test_quat();
|
||||
Error += test_mat2x2();
|
||||
# endif//GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
145
lib/glm/test/core/core_cpp_defaulted_ctor.cpp
Normal file
145
lib/glm/test/core/core_cpp_defaulted_ctor.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <cstring>
|
||||
|
||||
static int test_vec_memcpy()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec1 const A = glm::ivec1(76);
|
||||
glm::ivec1 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::ivec1));
|
||||
Error += B == A ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 const A = glm::ivec2(76);
|
||||
glm::ivec2 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::ivec2));
|
||||
Error += B == A ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A = glm::ivec3(76);
|
||||
glm::ivec3 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::ivec3));
|
||||
Error += B == A ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A = glm::ivec4(76);
|
||||
glm::ivec4 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::ivec4));
|
||||
Error += B == A ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat_memcpy()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::mat2x2 const A = glm::mat2x2(76);
|
||||
glm::mat2x2 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat2x2));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat2x3 const A = glm::mat2x3(76);
|
||||
glm::mat2x3 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat2x3));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat2x4 const A = glm::mat2x4(76);
|
||||
glm::mat2x4 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat2x4));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x2 const A = glm::mat3x2(76);
|
||||
glm::mat3x2 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat3x2));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x3 const A = glm::mat3x3(76);
|
||||
glm::mat3x3 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat3x3));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x4 const A = glm::mat3x4(76);
|
||||
glm::mat3x4 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat3x4));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4x2 const A = glm::mat4x2(76);
|
||||
glm::mat4x2 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat4x2));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4x3 const A = glm::mat4x3(76);
|
||||
glm::mat4x3 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat4x3));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4x4 const A = glm::mat4x4(76);
|
||||
glm::mat4x4 B;
|
||||
std::memcpy(&B, &A, sizeof(glm::mat4x4));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_quat_memcpy()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::quat const A = glm::quat(1, 0, 0, 0);
|
||||
glm::quat B;
|
||||
std::memcpy(&B, &A, sizeof(glm::quat));
|
||||
Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
#endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
Error += test_vec_memcpy();
|
||||
Error += test_mat_memcpy();
|
||||
Error += test_quat_memcpy();
|
||||
# endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
10
lib/glm/test/core/core_force_aligned_gentypes.cpp
Normal file
10
lib/glm/test/core/core_force_aligned_gentypes.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
14
lib/glm/test/core/core_force_arch_unknown.cpp
Normal file
14
lib/glm/test/core/core_force_arch_unknown.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GLM_FORCE_ARCH_UNKNOWN
|
||||
# define GLM_FORCE_ARCH_UNKNOWN
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
14
lib/glm/test/core/core_force_compiler_unknown.cpp
Normal file
14
lib/glm/test/core/core_force_compiler_unknown.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GLM_FORCE_COMPILER_UNKNOWN
|
||||
# define GLM_FORCE_COMPILER_UNKNOWN
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
139
lib/glm/test/core/core_force_ctor_init.cpp
Normal file
139
lib/glm/test/core/core_force_ctor_init.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
#define GLM_FORCE_CTOR_INIT
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
static int test_vec()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec1 V1;
|
||||
Error += glm::all(glm::equal(V1, glm::vec1(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dvec1 U1;
|
||||
Error += glm::all(glm::equal(U1, glm::dvec1(0), glm::epsilon<double>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 V2;
|
||||
Error += glm::all(glm::equal(V2, glm::vec2(0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dvec2 U2;
|
||||
Error += glm::all(glm::equal(U2, glm::dvec2(0, 0), glm::epsilon<double>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 V3;
|
||||
Error += glm::all(glm::equal(V3, glm::vec3(0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dvec3 U3;
|
||||
Error += glm::all(glm::equal(U3, glm::dvec3(0, 0, 0), glm::epsilon<double>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 V4;
|
||||
Error += glm::all(glm::equal(V4, glm::vec4(0, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dvec4 U4;
|
||||
Error += glm::all(glm::equal(U4, glm::dvec4(0, 0, 0, 0), glm::epsilon<double>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::mat2x2 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat2x2(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat2x2 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat2x2(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat2x3 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat2x3(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat2x3 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat2x3(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat2x4 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat2x4(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat2x4 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat2x4(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x2 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat3x2(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat3x2 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat3x2(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x3 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat3x3(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat3x3 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat3x3(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x4 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat3x4(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat3x4 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat3x4(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4x2 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat4x2(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat4x2 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat4x2(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4x3 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat4x3(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat4x3 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat4x3(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4x4 F;
|
||||
Error += glm::all(glm::equal(F, glm::mat4x4(1), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dmat4x4 D;
|
||||
Error += glm::all(glm::equal(D, glm::dmat4x4(1), glm::epsilon<double>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_qua()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::quat F;
|
||||
Error += glm::all(glm::equal(F, glm::quat(1, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::dquat D;
|
||||
Error += glm::all(glm::equal(D, glm::dquat(1, 0, 0, 0), glm::epsilon<double>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_vec();
|
||||
Error += test_mat();
|
||||
Error += test_qua();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
14
lib/glm/test/core/core_force_cxx03.cpp
Normal file
14
lib/glm/test/core/core_force_cxx03.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GLM_FORCE_CXX03
|
||||
# define GLM_FORCE_CXX03
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
14
lib/glm/test/core/core_force_cxx98.cpp
Normal file
14
lib/glm/test/core/core_force_cxx98.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GLM_FORCE_CXX98
|
||||
# define GLM_FORCE_CXX98
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
14
lib/glm/test/core/core_force_cxx_unknown.cpp
Normal file
14
lib/glm/test/core/core_force_cxx_unknown.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GLM_FORCE_CXX_UNKNOWN
|
||||
# define GLM_FORCE_CXX_UNKNOWN
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
12
lib/glm/test/core/core_force_depth_zero_to_one.cpp
Normal file
12
lib/glm/test/core/core_force_depth_zero_to_one.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
17
lib/glm/test/core/core_force_explicit_ctor.cpp
Normal file
17
lib/glm/test/core/core_force_explicit_ctor.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#define GLM_FORCE_EXPLICIT_CTOR
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec4 B(1);
|
||||
Error += B == glm::ivec4(1) ? 0 : 1;
|
||||
|
||||
//glm::vec4 A = B;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
12
lib/glm/test/core/core_force_inline.cpp
Normal file
12
lib/glm/test/core/core_force_inline.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#define GLM_FORCE_INLINE
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
12
lib/glm/test/core/core_force_left_handed.cpp
Normal file
12
lib/glm/test/core/core_force_left_handed.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#define GLM_FORCE_LEFT_HANDED
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
14
lib/glm/test/core/core_force_platform_unknown.cpp
Normal file
14
lib/glm/test/core/core_force_platform_unknown.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef GLM_FORCE_PLATFORM_UNKNOWN
|
||||
# define GLM_FORCE_PLATFORM_UNKNOWN
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
434
lib/glm/test/core/core_force_pure.cpp
Normal file
434
lib/glm/test/core/core_force_pure.cpp
Normal file
@@ -0,0 +1,434 @@
|
||||
#ifndef GLM_FORCE_PURE
|
||||
# define GLM_FORCE_PURE
|
||||
#endif//GLM_FORCE_PURE
|
||||
#define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
static int test_vec4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec4 A(1, 2, 3, 4);
|
||||
glm::ivec4 B(A);
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
}
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec4>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::vec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dvec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::ivec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::uvec4>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::vec4>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::vec4 a{ 0, 1, 2, 3 };
|
||||
std::vector<glm::vec4> v = {
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 0, 1}};
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec4 a{ 0, 1, 2, 3 };
|
||||
std::vector<glm::dvec4> v = {
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 0, 1}};
|
||||
}
|
||||
#endif
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A.xyzw;
|
||||
glm::ivec4 C(A.xyzw);
|
||||
glm::ivec4 D(A.xyzw());
|
||||
glm::ivec4 E(A.x, A.yzw);
|
||||
glm::ivec4 F(A.x, A.yzw());
|
||||
glm::ivec4 G(A.xyz, A.w);
|
||||
glm::ivec4 H(A.xyz(), A.w);
|
||||
glm::ivec4 I(A.xy, A.zw);
|
||||
glm::ivec4 J(A.xy(), A.zw());
|
||||
glm::ivec4 K(A.x, A.y, A.zw);
|
||||
glm::ivec4 L(A.x, A.yz, A.w);
|
||||
glm::ivec4 M(A.xy, A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE
|
||||
{
|
||||
glm::ivec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A.xyzw();
|
||||
glm::ivec4 C(A.xyzw());
|
||||
glm::ivec4 D(A.xyzw());
|
||||
glm::ivec4 E(A.x, A.yzw());
|
||||
glm::ivec4 F(A.x, A.yzw());
|
||||
glm::ivec4 G(A.xyz(), A.w);
|
||||
glm::ivec4 H(A.xyz(), A.w);
|
||||
glm::ivec4 I(A.xy(), A.zw());
|
||||
glm::ivec4 J(A.xy(), A.zw());
|
||||
glm::ivec4 K(A.x, A.y, A.zw());
|
||||
glm::ivec4 L(A.x, A.yz(), A.w);
|
||||
glm::ivec4 M(A.xy(), A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE
|
||||
|
||||
{
|
||||
glm::ivec4 A(1);
|
||||
glm::ivec4 B(1, 1, 1, 1);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::ivec4> Tests;
|
||||
Tests.push_back(glm::ivec4(glm::ivec2(1, 2), 3, 4));
|
||||
Tests.push_back(glm::ivec4(1, glm::ivec2(2, 3), 4));
|
||||
Tests.push_back(glm::ivec4(1, 2, glm::ivec2(3, 4)));
|
||||
Tests.push_back(glm::ivec4(glm::ivec3(1, 2, 3), 4));
|
||||
Tests.push_back(glm::ivec4(1, glm::ivec3(2, 3, 4)));
|
||||
Tests.push_back(glm::ivec4(glm::ivec2(1, 2), glm::ivec2(3, 4)));
|
||||
Tests.push_back(glm::ivec4(1, 2, 3, 4));
|
||||
Tests.push_back(glm::ivec4(glm::ivec4(1, 2, 3, 4)));
|
||||
|
||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
||||
Error += Tests[i] == glm::ivec4(1, 2, 3, 4) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_bvec4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::bvec4 const A(true);
|
||||
glm::bvec4 const B(true);
|
||||
glm::bvec4 const C(false);
|
||||
glm::bvec4 const D = A && B;
|
||||
glm::bvec4 const E = A && C;
|
||||
glm::bvec4 const F = A || C;
|
||||
|
||||
Error += D == glm::bvec4(true) ? 0 : 1;
|
||||
Error += E == glm::bvec4(false) ? 0 : 1;
|
||||
Error += F == glm::bvec4(true) ? 0 : 1;
|
||||
|
||||
bool const G = A == C;
|
||||
bool const H = A != C;
|
||||
|
||||
Error += !G ? 0 : 1;
|
||||
Error += H ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec4 A(1);
|
||||
glm::ivec4 B(1);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 const A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 const B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
glm::vec4 const C = A + B;
|
||||
Error += glm::all(glm::equal(C, glm::vec4(5, 7, 9, 11), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 D = B - A;
|
||||
Error += glm::all(glm::equal(D, glm::vec4(3, 3, 3, 3), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = A * B;
|
||||
Error += glm::all(glm::equal(E, glm::vec4(4, 10, 18, 28), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 F = B / A;
|
||||
Error += glm::all(glm::equal(F, glm::vec4(4, 2.5, 2, 7.0f / 4.0f), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 G = A + 1.0f;
|
||||
Error += glm::all(glm::equal(G, glm::vec4(2, 3, 4, 5), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 H = B - 1.0f;
|
||||
Error += glm::all(glm::equal(H, glm::vec4(3, 4, 5, 6), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 I = A * 2.0f;
|
||||
Error += glm::all(glm::equal(I, glm::vec4(2, 4, 6, 8), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 J = B / 2.0f;
|
||||
Error += glm::all(glm::equal(J, glm::vec4(2, 2.5, 3, 3.5), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 K = 1.0f + A;
|
||||
Error += glm::all(glm::equal(K, glm::vec4(2, 3, 4, 5), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 L = 1.0f - B;
|
||||
Error += glm::all(glm::equal(L, glm::vec4(-3, -4, -5, -6), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 M = 2.0f * A;
|
||||
Error += glm::all(glm::equal(M, glm::vec4(2, 4, 6, 8), 0.001f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 const N = 2.0f / B;
|
||||
Error += glm::all(glm::equal(N, glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0), 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
A += B;
|
||||
Error += A == glm::ivec4(5, 7, 9, 11) ? 0 : 1;
|
||||
|
||||
A += 1;
|
||||
Error += A == glm::ivec4(6, 8, 10, 12) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::ivec4(3, 3, 3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1;
|
||||
Error += B == glm::ivec4(2, 2, 2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::ivec4(4, 10, 18, 28) ? 0 : 1;
|
||||
|
||||
A *= 2;
|
||||
Error += A == glm::ivec4(8, 20, 36, 56) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 4.0f, 6.0f, 8.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::ivec4(4, 2, 2, 2) ? 0 : 1;
|
||||
|
||||
B /= 2;
|
||||
Error += B == glm::ivec4(2, 1, 1, 1) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 B(2);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::ivec4(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = -A;
|
||||
Error += B == glm::ivec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = --A;
|
||||
Error += B == glm::ivec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A--;
|
||||
Error += B == glm::ivec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = ++A;
|
||||
Error += B == glm::ivec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A++;
|
||||
Error += B == glm::ivec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4_equal()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::uvec4 const A(1, 2, 3, 4);
|
||||
glm::uvec4 const B(1, 2, 3, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
Error += A != B ? 1 : 0;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1, 2, 3, 4);
|
||||
glm::ivec4 const B(1, 2, 3, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
Error += A != B ? 1 : 0;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::lowp_vec4) ? 0 : 1;
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::mediump_vec4) ? 0 : 1;
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
|
||||
Error += 16 == sizeof(glm::mediump_vec4) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::lowp_dvec4) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::mediump_dvec4) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
|
||||
Error += 32 == sizeof(glm::highp_dvec4) ? 0 : 1;
|
||||
Error += glm::vec4().length() == 4 ? 0 : 1;
|
||||
Error += glm::dvec4().length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
glm::ivec4 A(1, 2, 3, 4);
|
||||
|
||||
{
|
||||
glm::ivec4 B(A.xy, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 B(A.xy, 3, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 B(1, A.yz, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 B(1, 2, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(A.xyz, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 B(1, A.yzw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_operator_increment()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::ivec4 v0(1);
|
||||
glm::ivec4 v1(v0);
|
||||
glm::ivec4 v2(v0);
|
||||
glm::ivec4 v3 = ++v1;
|
||||
glm::ivec4 v4 = v2++;
|
||||
|
||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
||||
|
||||
int i0(1);
|
||||
int i1(i0);
|
||||
int i2(i0);
|
||||
int i3 = ++i1;
|
||||
int i4 = i2++;
|
||||
|
||||
Error += i0 == i4 ? 0 : 1;
|
||||
Error += i1 == i2 ? 0 : 1;
|
||||
Error += i1 == i3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4_simd()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 const a(std::clock(), std::clock(), std::clock(), std::clock());
|
||||
glm::vec4 const b(std::clock(), std::clock(), std::clock(), std::clock());
|
||||
|
||||
glm::vec4 const c(b * a);
|
||||
glm::vec4 const d(a + c);
|
||||
|
||||
Error += glm::all(glm::greaterThanEqual(d, glm::vec4(0))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_vec4_ctor();
|
||||
Error += test_bvec4_ctor();
|
||||
Error += test_vec4_size();
|
||||
Error += test_vec4_operators();
|
||||
Error += test_vec4_equal();
|
||||
Error += test_vec4_swizzle_partial();
|
||||
Error += test_vec4_simd();
|
||||
Error += test_operator_increment();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
13
lib/glm/test/core/core_force_quat_wxyz.cpp
Normal file
13
lib/glm/test/core/core_force_quat_wxyz.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#define GLM_FORCE_QUAT_DATA_WXYZ
|
||||
#define GLM_FORCE_INLINE
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
12
lib/glm/test/core/core_force_size_t_length.cpp
Normal file
12
lib/glm/test/core/core_force_size_t_length.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#define GLM_FORCE_SIZE_T_LENGTH
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
12
lib/glm/test/core/core_force_unrestricted_gentype.cpp
Normal file
12
lib/glm/test/core/core_force_unrestricted_gentype.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#define GLM_FORCE_UNRESTRICTED_GENTYPE
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
58
lib/glm/test/core/core_force_xyzw_only.cpp
Normal file
58
lib/glm/test/core/core_force_xyzw_only.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#define GLM_FORCE_XYZW_ONLY
|
||||
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
|
||||
static int test_comp()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec1 const A(1);
|
||||
Error += A.x == 1 ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 const A(1, 2);
|
||||
Error += A.x == 1 ? 0 : 1;
|
||||
Error += A.y == 2 ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
Error += A.x == 1 ? 0 : 1;
|
||||
Error += A.y == 2 ? 0 : 1;
|
||||
Error += A.z == 3 ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1, 2, 3, 4);
|
||||
Error += A.x == 1 ? 0 : 1;
|
||||
Error += A.y == 2 ? 0 : 1;
|
||||
Error += A.z == 3 ? 0 : 1;
|
||||
Error += A.w == 4 ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_comp();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
1349
lib/glm/test/core/core_func_common.cpp
Normal file
1349
lib/glm/test/core/core_func_common.cpp
Normal file
File diff suppressed because it is too large
Load Diff
185
lib/glm/test/core/core_func_exponential.cpp
Normal file
185
lib/glm/test/core/core_func_exponential.cpp
Normal file
@@ -0,0 +1,185 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/common.hpp>
|
||||
#include <glm/exponential.hpp>
|
||||
|
||||
static int test_pow()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::pow(2.f, 2.f);
|
||||
Error += glm::equal(A, 4.f, 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 B = glm::pow(glm::vec1(2.f), glm::vec1(2.f));
|
||||
Error += glm::all(glm::equal(B, glm::vec1(4.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 C = glm::pow(glm::vec2(2.f), glm::vec2(2.f));
|
||||
Error += glm::all(glm::equal(C, glm::vec2(4.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = glm::pow(glm::vec3(2.f), glm::vec3(2.f));
|
||||
Error += glm::all(glm::equal(D, glm::vec3(4.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = glm::pow(glm::vec4(2.f), glm::vec4(2.f));
|
||||
Error += glm::all(glm::equal(E, glm::vec4(4.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_sqrt()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = glm::sqrt(4.f);
|
||||
Error += glm::equal(A, 2.f, 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 B = glm::sqrt(glm::vec1(4.f));
|
||||
Error += glm::all(glm::equal(B, glm::vec1(2.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 C = glm::sqrt(glm::vec2(4.f));
|
||||
Error += glm::all(glm::equal(C, glm::vec2(2.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = glm::sqrt(glm::vec3(4.f));
|
||||
Error += glm::all(glm::equal(D, glm::vec3(2.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = glm::sqrt(glm::vec4(4.f));
|
||||
Error += glm::all(glm::equal(E, glm::vec4(2.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_exp()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = glm::exp(1.f);
|
||||
Error += glm::equal(A, glm::e<float>(), 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 B = glm::exp(glm::vec1(1.f));
|
||||
Error += glm::all(glm::equal(B, glm::vec1(glm::e<float>()), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 C = glm::exp(glm::vec2(1.f));
|
||||
Error += glm::all(glm::equal(C, glm::vec2(glm::e<float>()), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = glm::exp(glm::vec3(1.f));
|
||||
Error += glm::all(glm::equal(D, glm::vec3(glm::e<float>()), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = glm::exp(glm::vec4(1.f));
|
||||
Error += glm::all(glm::equal(E, glm::vec4(glm::e<float>()), 0.01f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_log()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float const A = glm::log(glm::e<float>());
|
||||
Error += glm::equal(A, 1.f, 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 const B = glm::log(glm::vec1(glm::e<float>()));
|
||||
Error += glm::all(glm::equal(B, glm::vec1(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const C = glm::log(glm::vec2(glm::e<float>()));
|
||||
Error += glm::all(glm::equal(C, glm::vec2(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 const D = glm::log(glm::vec3(glm::e<float>()));
|
||||
Error += glm::all(glm::equal(D, glm::vec3(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 const E = glm::log(glm::vec4(glm::e<float>()));
|
||||
Error += glm::all(glm::equal(E, glm::vec4(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_exp2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = glm::exp2(4.f);
|
||||
Error += glm::equal(A, 16.f, 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 B = glm::exp2(glm::vec1(4.f));
|
||||
Error += glm::all(glm::equal(B, glm::vec1(16.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 C = glm::exp2(glm::vec2(4.f, 3.f));
|
||||
Error += glm::all(glm::equal(C, glm::vec2(16.f, 8.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = glm::exp2(glm::vec3(4.f, 3.f, 2.f));
|
||||
Error += glm::all(glm::equal(D, glm::vec3(16.f, 8.f, 4.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = glm::exp2(glm::vec4(4.f, 3.f, 2.f, 1.f));
|
||||
Error += glm::all(glm::equal(E, glm::vec4(16.f, 8.f, 4.f, 2.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
# if GLM_HAS_CXX11_STL
|
||||
//large exponent
|
||||
float F = glm::exp2(23.f);
|
||||
Error += glm::equal(F, 8388608.f, 0.01f) ? 0 : 1;
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_log2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = glm::log2(16.f);
|
||||
Error += glm::equal(A, 4.f, 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 B = glm::log2(glm::vec1(16.f));
|
||||
Error += glm::all(glm::equal(B, glm::vec1(4.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 C = glm::log2(glm::vec2(16.f, 8.f));
|
||||
Error += glm::all(glm::equal(C, glm::vec2(4.f, 3.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = glm::log2(glm::vec3(16.f, 8.f, 4.f));
|
||||
Error += glm::all(glm::equal(D, glm::vec3(4.f, 3.f, 2.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = glm::log2(glm::vec4(16.f, 8.f, 4.f, 2.f));
|
||||
Error += glm::all(glm::equal(E, glm::vec4(4.f, 3.f, 2.f, 1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_inversesqrt()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = glm::inversesqrt(16.f) * glm::sqrt(16.f);
|
||||
Error += glm::equal(A, 1.f, 0.01f) ? 0 : 1;
|
||||
|
||||
glm::vec1 B = glm::inversesqrt(glm::vec1(16.f)) * glm::sqrt(16.f);
|
||||
Error += glm::all(glm::equal(B, glm::vec1(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 C = glm::inversesqrt(glm::vec2(16.f)) * glm::sqrt(16.f);
|
||||
Error += glm::all(glm::equal(C, glm::vec2(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = glm::inversesqrt(glm::vec3(16.f)) * glm::sqrt(16.f);
|
||||
Error += glm::all(glm::equal(D, glm::vec3(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = glm::inversesqrt(glm::vec4(16.f)) * glm::sqrt(16.f);
|
||||
Error += glm::all(glm::equal(E, glm::vec4(1.f), 0.01f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_pow();
|
||||
Error += test_sqrt();
|
||||
Error += test_exp();
|
||||
Error += test_log();
|
||||
Error += test_exp2();
|
||||
Error += test_log2();
|
||||
Error += test_inversesqrt();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
200
lib/glm/test/core/core_func_geometric.cpp
Normal file
200
lib/glm/test/core/core_func_geometric.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
#include <glm/geometric.hpp>
|
||||
#include <glm/trigonometric.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <limits>
|
||||
|
||||
namespace length
|
||||
{
|
||||
int test()
|
||||
{
|
||||
float Length1 = glm::length(glm::vec1(1));
|
||||
float Length2 = glm::length(glm::vec2(1, 0));
|
||||
float Length3 = glm::length(glm::vec3(1, 0, 0));
|
||||
float Length4 = glm::length(glm::vec4(1, 0, 0, 0));
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::abs(Length1 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Length2 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Length3 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Length4 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace length
|
||||
|
||||
namespace distance
|
||||
{
|
||||
int test()
|
||||
{
|
||||
float Distance1 = glm::distance(glm::vec1(1), glm::vec1(1));
|
||||
float Distance2 = glm::distance(glm::vec2(1, 0), glm::vec2(1, 0));
|
||||
float Distance3 = glm::distance(glm::vec3(1, 0, 0), glm::vec3(1, 0, 0));
|
||||
float Distance4 = glm::distance(glm::vec4(1, 0, 0, 0), glm::vec4(1, 0, 0, 0));
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::abs(Distance1) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Distance2) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Distance3) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Distance4) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace distance
|
||||
|
||||
namespace dot
|
||||
{
|
||||
int test()
|
||||
{
|
||||
float Dot1 = glm::dot(glm::vec1(1), glm::vec1(1));
|
||||
float Dot2 = glm::dot(glm::vec2(1), glm::vec2(1));
|
||||
float Dot3 = glm::dot(glm::vec3(1), glm::vec3(1));
|
||||
float Dot4 = glm::dot(glm::vec4(1), glm::vec4(1));
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::abs(Dot1 - 1.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Dot2 - 2.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Dot3 - 3.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
Error += glm::abs(Dot4 - 4.0f) < std::numeric_limits<float>::epsilon() ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace dot
|
||||
|
||||
namespace cross
|
||||
{
|
||||
int test()
|
||||
{
|
||||
glm::vec3 Cross1 = glm::cross(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
glm::vec3 Cross2 = glm::cross(glm::vec3(0, 1, 0), glm::vec3(1, 0, 0));
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::all(glm::lessThan(glm::abs(Cross1 - glm::vec3(0, 0, 1)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
|
||||
Error += glm::all(glm::lessThan(glm::abs(Cross2 - glm::vec3(0, 0,-1)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cross
|
||||
|
||||
namespace normalize
|
||||
{
|
||||
int test()
|
||||
{
|
||||
glm::vec3 Normalize1 = glm::normalize(glm::vec3(1, 0, 0));
|
||||
glm::vec3 Normalize2 = glm::normalize(glm::vec3(2, 0, 0));
|
||||
|
||||
glm::vec3 Normalize3 = glm::normalize(glm::vec3(-0.6, 0.7, -0.5));
|
||||
|
||||
glm::vec3 ro = glm::vec3(glm::cos(5.f) * 3.f, 2.f, glm::sin(5.f) * 3.f);
|
||||
glm::vec3 w = glm::normalize(glm::vec3(0, -0.2f, 0) - ro);
|
||||
glm::vec3 u = glm::normalize(glm::cross(w, glm::vec3(0, 1, 0)));
|
||||
glm::vec3 v = glm::cross(u, w);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::all(glm::lessThan(glm::abs(Normalize1 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
|
||||
Error += glm::all(glm::lessThan(glm::abs(Normalize2 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits<float>::epsilon()))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace normalize
|
||||
|
||||
namespace faceforward
|
||||
{
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec3 N(0.0f, 0.0f, 1.0f);
|
||||
glm::vec3 I(1.0f, 0.0f, 1.0f);
|
||||
glm::vec3 Nref(0.0f, 0.0f, 1.0f);
|
||||
glm::vec3 F = glm::faceforward(N, I, Nref);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace faceforward
|
||||
|
||||
namespace reflect
|
||||
{
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f,-1.0f);
|
||||
glm::vec2 B(0.0f, 1.0f);
|
||||
glm::vec2 C = glm::reflect(A, B);
|
||||
Error += glm::all(glm::equal(C, glm::vec2(1.0, 1.0), 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 A(1.0f,-1.0f);
|
||||
glm::dvec2 B(0.0f, 1.0f);
|
||||
glm::dvec2 C = glm::reflect(A, B);
|
||||
Error += glm::all(glm::equal(C, glm::dvec2(1.0, 1.0), 0.0001)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace reflect
|
||||
|
||||
namespace refract
|
||||
{
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
float A(-1.0f);
|
||||
float B(1.0f);
|
||||
float C = glm::refract(A, B, 0.5f);
|
||||
Error += glm::equal(C, -1.0f, 0.0001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(0.0f,-1.0f);
|
||||
glm::vec2 B(0.0f, 1.0f);
|
||||
glm::vec2 C = glm::refract(A, B, 0.5f);
|
||||
Error += glm::all(glm::equal(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 A(0.0f,-1.0f);
|
||||
glm::dvec2 B(0.0f, 1.0f);
|
||||
glm::dvec2 C = glm::refract(A, B, 0.5);
|
||||
Error += glm::all(glm::equal(C, glm::dvec2(0.0, -1.0), 0.0001)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace refract
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += length::test();
|
||||
Error += distance::test();
|
||||
Error += dot::test();
|
||||
Error += cross::test();
|
||||
Error += normalize::test();
|
||||
Error += faceforward::test();
|
||||
Error += reflect::test();
|
||||
Error += refract::test();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
1556
lib/glm/test/core/core_func_integer.cpp
Normal file
1556
lib/glm/test/core/core_func_integer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
291
lib/glm/test/core/core_func_integer_bit_count.cpp
Normal file
291
lib/glm/test/core/core_func_integer_bit_count.cpp
Normal file
@@ -0,0 +1,291 @@
|
||||
// This has the programs for computing the number of 1-bits
|
||||
// in a word, or byte, etc.
|
||||
// Max line length is 57, to fit in hacker.book.
|
||||
#include <cstdio>
|
||||
#include <cstdlib> //To define "exit", req'd by XLC.
|
||||
#include <ctime>
|
||||
|
||||
unsigned rotatel(unsigned x, int n)
|
||||
{
|
||||
if (static_cast<unsigned>(n) > 63) { std::printf("rotatel, n out of range.\n"); std::exit(1);}
|
||||
return (x << n) | (x >> (32 - n));
|
||||
}
|
||||
|
||||
int pop0(unsigned x)
|
||||
{
|
||||
x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
|
||||
x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF);
|
||||
x = (x & 0x0000FFFF) + ((x >>16) & 0x0000FFFF);
|
||||
return x;
|
||||
}
|
||||
|
||||
int pop1(unsigned x)
|
||||
{
|
||||
x = x - ((x >> 1) & 0x55555555);
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x = x + (x >> 8);
|
||||
x = x + (x >> 16);
|
||||
return x & 0x0000003F;
|
||||
}
|
||||
/* Note: an alternative to the last three executable lines above is:
|
||||
return x*0x01010101 >> 24;
|
||||
if your machine has a fast multiplier (suggested by Jari Kirma). */
|
||||
|
||||
int pop2(unsigned x)
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
n = (x >> 1) & 033333333333; // Count bits in
|
||||
x = x - n; // each 3-bit
|
||||
n = (n >> 1) & 033333333333; // field.
|
||||
x = x - n;
|
||||
x = (x + (x >> 3)) & 030707070707; // 6-bit sums.
|
||||
return x%63; // Add 6-bit sums.
|
||||
}
|
||||
|
||||
/* An alternative to the "return" statement above is:
|
||||
return ((x * 0404040404) >> 26) + // Add 6-bit sums.
|
||||
(x >> 30);
|
||||
which runs faster on most machines (suggested by Norbert Juffa). */
|
||||
|
||||
int pop3(unsigned x)
|
||||
{
|
||||
unsigned n;
|
||||
|
||||
n = (x >> 1) & 0x77777777; // Count bits in
|
||||
x = x - n; // each 4-bit
|
||||
n = (n >> 1) & 0x77777777; // field.
|
||||
x = x - n;
|
||||
n = (n >> 1) & 0x77777777;
|
||||
x = x - n;
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F; // Get byte sums.
|
||||
x = x*0x01010101; // Add the bytes.
|
||||
return x >> 24;
|
||||
}
|
||||
|
||||
int pop4(unsigned x)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = 0;
|
||||
while (x != 0) {
|
||||
n = n + 1;
|
||||
x = x & (x - 1);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int pop5(unsigned x)
|
||||
{
|
||||
int i, sum;
|
||||
|
||||
// Rotate and sum method // Shift right & subtract
|
||||
|
||||
sum = x; // sum = x;
|
||||
for (i = 1; i <= 31; i++) { // while (x != 0) {
|
||||
x = rotatel(x, 1); // x = x >> 1;
|
||||
sum = sum + x; // sum = sum - x;
|
||||
} // }
|
||||
return -sum; // return sum;
|
||||
}
|
||||
|
||||
int pop5a(unsigned x)
|
||||
{
|
||||
int sum;
|
||||
|
||||
// Shift right & subtract
|
||||
|
||||
sum = x;
|
||||
while (x != 0) {
|
||||
x = x >> 1;
|
||||
sum = sum - x;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int pop6(unsigned x)
|
||||
{ // Table lookup.
|
||||
static char table[256] = {
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
|
||||
|
||||
return table[x & 0xFF] +
|
||||
table[(x >> 8) & 0xFF] +
|
||||
table[(x >> 16) & 0xFF] +
|
||||
table[(x >> 24)];
|
||||
}
|
||||
|
||||
// The following works only for 8-bit quantities.
|
||||
int pop7(unsigned x)
|
||||
{
|
||||
x = x*0x08040201; // Make 4 copies.
|
||||
x = x >> 3; // So next step hits proper bits.
|
||||
x = x & 0x11111111; // Every 4th bit.
|
||||
x = x*0x11111111; // Sum the digits (each 0 or 1).
|
||||
x = x >> 28; // Position the result.
|
||||
return x;
|
||||
}
|
||||
|
||||
// The following works only for 7-bit quantities.
|
||||
int pop8(unsigned x)
|
||||
{
|
||||
x = x*0x02040810; // Make 4 copies, left-adjusted.
|
||||
x = x & 0x11111111; // Every 4th bit.
|
||||
x = x*0x11111111; // Sum the digits (each 0 or 1).
|
||||
x = x >> 28; // Position the result.
|
||||
return x;
|
||||
}
|
||||
|
||||
// The following works only for 15-bit quantities.
|
||||
int pop9(unsigned x)
|
||||
{
|
||||
unsigned long long y;
|
||||
y = x * 0x0002000400080010ULL;
|
||||
y = y & 0x1111111111111111ULL;
|
||||
y = y * 0x1111111111111111ULL;
|
||||
y = y >> 60;
|
||||
return static_cast<int>(y);
|
||||
}
|
||||
|
||||
int errors;
|
||||
void error(int x, int y)
|
||||
{
|
||||
errors = errors + 1;
|
||||
std::printf("Error for x = %08x, got %08x\n", x, y);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
# ifdef NDEBUG
|
||||
|
||||
int i, n;
|
||||
static unsigned test[] = {0,0, 1,1, 2,1, 3,2, 4,1, 5,2, 6,2, 7,3,
|
||||
8,1, 9,2, 10,2, 11,3, 12,2, 13,3, 14,3, 15,4, 16,1, 17,2,
|
||||
0x3F,6, 0x40,1, 0x41,2, 0x7f,7, 0x80,1, 0x81,2, 0xfe,7, 0xff,8,
|
||||
0x4000,1, 0x4001,2, 0x7000,3, 0x7fff,15,
|
||||
0x55555555,16, 0xAAAAAAAA, 16, 0xFF000000,8, 0xC0C0C0C0,8,
|
||||
0x0FFFFFF0,24, 0x80000000,1, 0xFFFFFFFF,32};
|
||||
|
||||
std::size_t const Count = 1000000;
|
||||
|
||||
n = sizeof(test)/4;
|
||||
|
||||
std::clock_t TimestampBeg = 0;
|
||||
std::clock_t TimestampEnd = 0;
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop0(test[i]) != test[i+1]) error(test[i], pop0(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop0: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop1(test[i]) != test[i+1]) error(test[i], pop1(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop1: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop2(test[i]) != test[i+1]) error(test[i], pop2(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop2: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop3(test[i]) != test[i+1]) error(test[i], pop3(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop3: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop4(test[i]) != test[i+1]) error(test[i], pop4(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop4: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop5(test[i]) != test[i+1]) error(test[i], pop5(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop5: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop5a(test[i]) != test[i+1]) error(test[i], pop5a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop5a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (pop6(test[i]) != test[i+1]) error(test[i], pop6(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop6: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if ((test[i] & 0xffffff00) == 0)
|
||||
if (pop7(test[i]) != test[i+1]) error(test[i], pop7(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if ((test[i] & 0xffffff80) == 0)
|
||||
if (pop8(test[i]) != test[i+1]) error(test[i], pop8(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop8: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if ((test[i] & 0xffff8000) == 0)
|
||||
if (pop9(test[i]) != test[i+1]) error(test[i], pop9(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("pop9: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
if (errors == 0)
|
||||
std::printf("Passed all %d cases.\n", static_cast<int>(sizeof(test)/8));
|
||||
|
||||
# endif//NDEBUG
|
||||
}
|
||||
416
lib/glm/test/core/core_func_integer_find_lsb.cpp
Normal file
416
lib/glm/test/core/core_func_integer_find_lsb.cpp
Normal file
@@ -0,0 +1,416 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib> //To define "exit", req'd by XLC.
|
||||
#include <ctime>
|
||||
|
||||
int nlz(unsigned x)
|
||||
{
|
||||
int pop(unsigned x);
|
||||
|
||||
x = x | (x >> 1);
|
||||
x = x | (x >> 2);
|
||||
x = x | (x >> 4);
|
||||
x = x | (x >> 8);
|
||||
x = x | (x >>16);
|
||||
return pop(~x);
|
||||
}
|
||||
|
||||
int pop(unsigned x)
|
||||
{
|
||||
x = x - ((x >> 1) & 0x55555555);
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x = x + (x << 8);
|
||||
x = x + (x << 16);
|
||||
return x >> 24;
|
||||
}
|
||||
|
||||
int ntz1(unsigned x)
|
||||
{
|
||||
return 32 - nlz(~x & (x-1));
|
||||
}
|
||||
|
||||
int ntz2(unsigned x)
|
||||
{
|
||||
return pop(~x & (x - 1));
|
||||
}
|
||||
|
||||
int ntz3(unsigned x)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (x == 0) return(32);
|
||||
n = 1;
|
||||
if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;}
|
||||
if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;}
|
||||
if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;}
|
||||
if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;}
|
||||
return n - (x & 1);
|
||||
}
|
||||
|
||||
int ntz4(unsigned x)
|
||||
{
|
||||
unsigned y;
|
||||
int n;
|
||||
|
||||
if (x == 0) return 32;
|
||||
n = 31;
|
||||
y = x <<16; if (y != 0) {n = n -16; x = y;}
|
||||
y = x << 8; if (y != 0) {n = n - 8; x = y;}
|
||||
y = x << 4; if (y != 0) {n = n - 4; x = y;}
|
||||
y = x << 2; if (y != 0) {n = n - 2; x = y;}
|
||||
y = x << 1; if (y != 0) {n = n - 1;}
|
||||
return n;
|
||||
}
|
||||
|
||||
int ntz4a(unsigned x)
|
||||
{
|
||||
unsigned y;
|
||||
int n;
|
||||
|
||||
if (x == 0) return 32;
|
||||
n = 31;
|
||||
y = x <<16; if (y != 0) {n = n -16; x = y;}
|
||||
y = x << 8; if (y != 0) {n = n - 8; x = y;}
|
||||
y = x << 4; if (y != 0) {n = n - 4; x = y;}
|
||||
y = x << 2; if (y != 0) {n = n - 2; x = y;}
|
||||
n = n - ((x << 1) >> 31);
|
||||
return n;
|
||||
}
|
||||
|
||||
int ntz5(char x)
|
||||
{
|
||||
if (x & 15) {
|
||||
if (x & 3) {
|
||||
if (x & 1) return 0;
|
||||
else return 1;
|
||||
}
|
||||
else if (x & 4) return 2;
|
||||
else return 3;
|
||||
}
|
||||
else if (x & 0x30) {
|
||||
if (x & 0x10) return 4;
|
||||
else return 5;
|
||||
}
|
||||
else if (x & 0x40) return 6;
|
||||
else if (x) return 7;
|
||||
else return 8;
|
||||
}
|
||||
|
||||
int ntz6(unsigned x)
|
||||
{
|
||||
int n;
|
||||
|
||||
x = ~x & (x - 1);
|
||||
n = 0; // n = 32;
|
||||
while(x != 0)
|
||||
{ // while (x != 0) {
|
||||
n = n + 1; // n = n - 1;
|
||||
x = x >> 1; // x = x + x;
|
||||
} // }
|
||||
return n; // return n;
|
||||
}
|
||||
|
||||
int ntz6a(unsigned x)
|
||||
{
|
||||
int n = 32;
|
||||
|
||||
while (x != 0) {
|
||||
n = n - 1;
|
||||
x = x + x;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Dean Gaudet's algorithm. To be most useful there must be a good way
|
||||
to evaluate the C "conditional expression" (a?b:c construction) without
|
||||
branching. The result of a?b:c is b if a is true (nonzero), and c if a
|
||||
is false (0).
|
||||
For example, a compare to zero op that sets a target GPR to 1 if the
|
||||
operand is 0, and to 0 if the operand is nonzero, will do it. With this
|
||||
instruction, the algorithm is entirely branch-free. But the most
|
||||
interesting thing about it is the high degree of parallelism. All six
|
||||
lines with conditional expressions can be executed in parallel (on a
|
||||
machine with sufficient computational units).
|
||||
Although the instruction count is 30 measured statically, it could
|
||||
execute in only 10 cycles on a machine with sufficient parallelism.
|
||||
The first two uses of y can instead be x, which would increase the
|
||||
useful parallelism on most machines (the assignments to y, bz, and b4
|
||||
could then all run in parallel). */
|
||||
|
||||
int ntz7(unsigned x)
|
||||
{
|
||||
unsigned y, bz, b4, b3, b2, b1, b0;
|
||||
|
||||
y = x & -x; // Isolate rightmost 1-bit.
|
||||
bz = y ? 0 : 1; // 1 if y = 0.
|
||||
b4 = (y & 0x0000FFFF) ? 0 : 16;
|
||||
b3 = (y & 0x00FF00FF) ? 0 : 8;
|
||||
b2 = (y & 0x0F0F0F0F) ? 0 : 4;
|
||||
b1 = (y & 0x33333333) ? 0 : 2;
|
||||
b0 = (y & 0x55555555) ? 0 : 1;
|
||||
return bz + b4 + b3 + b2 + b1 + b0;
|
||||
}
|
||||
|
||||
// This file has divisions by zero to test isnan
|
||||
#if GLM_COMPILER & GLM_COMPILER_VC
|
||||
# pragma warning(disable : 4800)
|
||||
#endif
|
||||
|
||||
int ntz7_christophe(unsigned x)
|
||||
{
|
||||
unsigned y, bz, b4, b3, b2, b1, b0;
|
||||
|
||||
y = x & -x; // Isolate rightmost 1-bit.
|
||||
bz = unsigned(!bool(y)); // 1 if y = 0.
|
||||
b4 = unsigned(!bool(y & 0x0000FFFF)) * 16;
|
||||
b3 = unsigned(!bool(y & 0x00FF00FF)) * 8;
|
||||
b2 = unsigned(!bool(y & 0x0F0F0F0F)) * 4;
|
||||
b1 = unsigned(!bool(y & 0x33333333)) * 2;
|
||||
b0 = unsigned(!bool(y & 0x55555555)) * 1;
|
||||
return bz + b4 + b3 + b2 + b1 + b0;
|
||||
}
|
||||
|
||||
/* Below is David Seal's algorithm, found at
|
||||
http://www.ciphersbyritter.com/NEWS4/BITCT.HTM Table
|
||||
entries marked "u" are unused. 6 ops including a
|
||||
multiply, plus an indexed load. */
|
||||
|
||||
#define u 99
|
||||
int ntz8(unsigned x)
|
||||
{
|
||||
static char table[64] =
|
||||
{32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14,
|
||||
10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15,
|
||||
31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26,
|
||||
30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u};
|
||||
|
||||
x = (x & -x)*0x0450FBAF;
|
||||
return table[x >> 26];
|
||||
}
|
||||
|
||||
/* Seal's algorithm with multiply expanded.
|
||||
9 elementary ops plus an indexed load. */
|
||||
|
||||
int ntz8a(unsigned x)
|
||||
{
|
||||
static char table[64] =
|
||||
{32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14,
|
||||
10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15,
|
||||
31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26,
|
||||
30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u};
|
||||
|
||||
x = (x & -x);
|
||||
x = (x << 4) + x; // x = x*17.
|
||||
x = (x << 6) + x; // x = x*65.
|
||||
x = (x << 16) - x; // x = x*65535.
|
||||
return table[x >> 26];
|
||||
}
|
||||
|
||||
/* Reiser's algorithm. Three ops including a "remainder,"
|
||||
plus an indexed load. */
|
||||
|
||||
int ntz9(unsigned x)
|
||||
{
|
||||
static char table[37] = {
|
||||
32, 0, 1, 26, 2, 23, 27,
|
||||
u, 3, 16, 24, 30, 28, 11, u, 13, 4,
|
||||
7, 17, u, 25, 22, 31, 15, 29, 10, 12,
|
||||
6, u, 21, 14, 9, 5, 20, 8, 19, 18};
|
||||
|
||||
x = (x & -x)%37;
|
||||
return table[x];
|
||||
}
|
||||
|
||||
/* Using a de Bruijn sequence. This is a table lookup with a 32-entry
|
||||
table. The de Bruijn sequence used here is
|
||||
0000 0100 1101 0111 0110 0101 0001 1111,
|
||||
obtained from Danny Dube's October 3, 1997, posting in
|
||||
comp.compression.research. Thanks to Norbert Juffa for this reference. */
|
||||
|
||||
int ntz10(unsigned x) {
|
||||
|
||||
static char table[32] =
|
||||
{ 0, 1, 2,24, 3,19, 6,25, 22, 4,20,10,16, 7,12,26,
|
||||
31,23,18, 5,21, 9,15,11, 30,17, 8,14,29,13,28,27};
|
||||
|
||||
if (x == 0) return 32;
|
||||
x = (x & -x)*0x04D7651F;
|
||||
return table[x >> 27];
|
||||
}
|
||||
|
||||
/* Norbert Juffa's code, answer to exercise 1 of Chapter 5 (2nd ed). */
|
||||
|
||||
#define SLOW_MUL
|
||||
int ntz11 (unsigned int n) {
|
||||
|
||||
static unsigned char tab[32] =
|
||||
{ 0, 1, 2, 24, 3, 19, 6, 25,
|
||||
22, 4, 20, 10, 16, 7, 12, 26,
|
||||
31, 23, 18, 5, 21, 9, 15, 11,
|
||||
30, 17, 8, 14, 29, 13, 28, 27
|
||||
};
|
||||
unsigned int k;
|
||||
n = n & (-n); /* isolate lsb */
|
||||
printf("n = %d\n", n);
|
||||
#if defined(SLOW_MUL)
|
||||
k = (n << 11) - n;
|
||||
k = (k << 2) + k;
|
||||
k = (k << 8) + n;
|
||||
k = (k << 5) - k;
|
||||
#else
|
||||
k = n * 0x4d7651f;
|
||||
#endif
|
||||
return n ? tab[k>>27] : 32;
|
||||
}
|
||||
|
||||
int errors;
|
||||
void error(int x, int y) {
|
||||
errors = errors + 1;
|
||||
std::printf("Error for x = %08x, got %d\n", x, y);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
# ifdef NDEBUG
|
||||
|
||||
int i, m, n;
|
||||
static unsigned test[] = {0,32, 1,0, 2,1, 3,0, 4,2, 5,0, 6,1, 7,0,
|
||||
8,3, 9,0, 16,4, 32,5, 64,6, 128,7, 255,0, 256,8, 512,9, 1024,10,
|
||||
2048,11, 4096,12, 8192,13, 16384,14, 32768,15, 65536,16,
|
||||
0x20000,17, 0x40000,18, 0x80000,19, 0x100000,20, 0x200000,21,
|
||||
0x400000,22, 0x800000,23, 0x1000000,24, 0x2000000,25,
|
||||
0x4000000,26, 0x8000000,27, 0x10000000,28, 0x20000000,29,
|
||||
0x40000000,30, 0x80000000,31, 0xFFFFFFF0,4, 0x3000FF00,8,
|
||||
0xC0000000,30, 0x60000000,29, 0x00011000, 12};
|
||||
|
||||
std::size_t const Count = 1000;
|
||||
|
||||
n = sizeof(test)/4;
|
||||
|
||||
std::clock_t TimestampBeg = 0;
|
||||
std::clock_t TimestampEnd = 0;
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz1(test[i]) != test[i+1]) error(test[i], ntz1(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz1: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz2(test[i]) != test[i+1]) error(test[i], ntz2(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz2: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz3(test[i]) != test[i+1]) error(test[i], ntz3(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz3: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz4(test[i]) != test[i+1]) error(test[i], ntz4(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz4: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz4a(test[i]) != test[i+1]) error(test[i], ntz4a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz4a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for(std::size_t k = 0; k < Count; ++k)
|
||||
for(i = 0; i < n; i += 2)
|
||||
{
|
||||
m = test[i+1];
|
||||
if(m > 8)
|
||||
m = 8;
|
||||
if(ntz5(static_cast<char>(test[i])) != m)
|
||||
error(test[i], ntz5(static_cast<char>(test[i])));
|
||||
}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz5: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz6(test[i]) != test[i+1]) error(test[i], ntz6(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz6: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz6a(test[i]) != test[i+1]) error(test[i], ntz6a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz6a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz7(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz7_christophe(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz7_christophe: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz8(test[i]) != test[i+1]) error(test[i], ntz8(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz8: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz8a(test[i]) != test[i+1]) error(test[i], ntz8a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz8a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz9(test[i]) != test[i+1]) error(test[i], ntz9(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz9: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (ntz10(test[i]) != test[i+1]) error(test[i], ntz10(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("ntz10: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
if (errors == 0)
|
||||
std::printf("Passed all %d cases.\n", static_cast<int>(sizeof(test)/8));
|
||||
|
||||
# endif//NDEBUG
|
||||
}
|
||||
440
lib/glm/test/core/core_func_integer_find_msb.cpp
Normal file
440
lib/glm/test/core/core_func_integer_find_msb.cpp
Normal file
@@ -0,0 +1,440 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib> // To define "exit", req'd by XLC.
|
||||
#include <ctime>
|
||||
|
||||
#define LE 1 // 1 for little-endian, 0 for big-endian.
|
||||
|
||||
int pop(unsigned x) {
|
||||
x = x - ((x >> 1) & 0x55555555);
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x = x + (x << 8);
|
||||
x = x + (x << 16);
|
||||
return x >> 24;
|
||||
}
|
||||
|
||||
int nlz1(unsigned x) {
|
||||
int n;
|
||||
|
||||
if (x == 0) return(32);
|
||||
n = 0;
|
||||
if (x <= 0x0000FFFF) {n = n +16; x = x <<16;}
|
||||
if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;}
|
||||
if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;}
|
||||
if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;}
|
||||
if (x <= 0x7FFFFFFF) {n = n + 1;}
|
||||
return n;
|
||||
}
|
||||
|
||||
int nlz1a(unsigned x) {
|
||||
int n;
|
||||
|
||||
/* if (x == 0) return(32); */
|
||||
if (static_cast<int>(x) <= 0) return (~x >> 26) & 32;
|
||||
n = 1;
|
||||
if ((x >> 16) == 0) {n = n +16; x = x <<16;}
|
||||
if ((x >> 24) == 0) {n = n + 8; x = x << 8;}
|
||||
if ((x >> 28) == 0) {n = n + 4; x = x << 4;}
|
||||
if ((x >> 30) == 0) {n = n + 2; x = x << 2;}
|
||||
n = n - (x >> 31);
|
||||
return n;
|
||||
}
|
||||
// On basic Risc, 12 to 20 instructions.
|
||||
|
||||
int nlz2(unsigned x) {
|
||||
unsigned y;
|
||||
int n;
|
||||
|
||||
n = 32;
|
||||
y = x >>16; if (y != 0) {n = n -16; x = y;}
|
||||
y = x >> 8; if (y != 0) {n = n - 8; x = y;}
|
||||
y = x >> 4; if (y != 0) {n = n - 4; x = y;}
|
||||
y = x >> 2; if (y != 0) {n = n - 2; x = y;}
|
||||
y = x >> 1; if (y != 0) return n - 2;
|
||||
return n - x;
|
||||
}
|
||||
|
||||
// As above but coded as a loop for compactness:
|
||||
// 23 to 33 basic Risc instructions.
|
||||
int nlz2a(unsigned x) {
|
||||
unsigned y;
|
||||
int n, c;
|
||||
|
||||
n = 32;
|
||||
c = 16;
|
||||
do {
|
||||
y = x >> c; if (y != 0) {n = n - c; x = y;}
|
||||
c = c >> 1;
|
||||
} while (c != 0);
|
||||
return n - x;
|
||||
}
|
||||
|
||||
int nlz3(int x) {
|
||||
int y, n;
|
||||
|
||||
n = 0;
|
||||
y = x;
|
||||
L: if (x < 0) return n;
|
||||
if (y == 0) return 32 - n;
|
||||
n = n + 1;
|
||||
x = x << 1;
|
||||
y = y >> 1;
|
||||
goto L;
|
||||
}
|
||||
|
||||
int nlz4(unsigned x) {
|
||||
int y, m, n;
|
||||
|
||||
y = -(x >> 16); // If left half of x is 0,
|
||||
m = (y >> 16) & 16; // set n = 16. If left half
|
||||
n = 16 - m; // is nonzero, set n = 0 and
|
||||
x = x >> m; // shift x right 16.
|
||||
// Now x is of the form 0000xxxx.
|
||||
y = x - 0x100; // If positions 8-15 are 0,
|
||||
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x - 0x1000; // If positions 12-15 are 0,
|
||||
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x - 0x4000; // If positions 14-15 are 0,
|
||||
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
|
||||
n = n + m;
|
||||
x = x << m;
|
||||
|
||||
y = x >> 14; // Set y = 0, 1, 2, or 3.
|
||||
m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp.
|
||||
return n + 2 - m;
|
||||
}
|
||||
|
||||
int nlz5(unsigned x) {
|
||||
int pop(unsigned x);
|
||||
|
||||
x = x | (x >> 1);
|
||||
x = x | (x >> 2);
|
||||
x = x | (x >> 4);
|
||||
x = x | (x >> 8);
|
||||
x = x | (x >>16);
|
||||
return pop(~x);
|
||||
}
|
||||
|
||||
/* The four programs below are not valid ANSI C programs. This is
|
||||
because they refer to the same storage locations as two different types.
|
||||
However, they work with xlc/AIX, gcc/AIX, and gcc/NT. If you try to
|
||||
code them more compactly by declaring a variable xx to be "double," and
|
||||
then using
|
||||
|
||||
n = 1054 - (*((unsigned *)&xx + LE) >> 20);
|
||||
|
||||
then you are violating not only the rule above, but also the ANSI C
|
||||
rule that pointer arithmetic can be performed only on pointers to
|
||||
array elements.
|
||||
When coded with the above statement, the program fails with xlc,
|
||||
gcc/AIX, and gcc/NT, at some optimization levels.
|
||||
BTW, these programs use the "anonymous union" feature of C++, not
|
||||
available in C. */
|
||||
|
||||
int nlz6(unsigned k)
|
||||
{
|
||||
union {
|
||||
unsigned asInt[2];
|
||||
double asDouble;
|
||||
};
|
||||
int n;
|
||||
|
||||
asDouble = static_cast<double>(k) + 0.5;
|
||||
n = 1054 - (asInt[LE] >> 20);
|
||||
return n;
|
||||
}
|
||||
|
||||
int nlz7(unsigned k)
|
||||
{
|
||||
union {
|
||||
unsigned asInt[2];
|
||||
double asDouble;
|
||||
};
|
||||
int n;
|
||||
|
||||
asDouble = static_cast<double>(k);
|
||||
n = 1054 - (asInt[LE] >> 20);
|
||||
n = (n & 31) + (n >> 9);
|
||||
return n;
|
||||
}
|
||||
|
||||
/* In single qualifier, round-to-nearest mode, the basic method fails for:
|
||||
k = 0, k = 01FFFFFF, 03FFFFFE <= k <= 03FFFFFF,
|
||||
07FFFFFC <= k <= 07FFFFFF,
|
||||
0FFFFFF8 <= k <= 0FFFFFFF,
|
||||
...
|
||||
7FFFFFC0 <= k <= 7FFFFFFF.
|
||||
FFFFFF80 <= k <= FFFFFFFF.
|
||||
For k = 0 it gives 158, and for the other values it is too low by 1. */
|
||||
|
||||
int nlz8(unsigned k)
|
||||
{
|
||||
union {
|
||||
unsigned asInt;
|
||||
float asFloat;
|
||||
};
|
||||
int n;
|
||||
|
||||
k = k & ~(k >> 1); /* Fix problem with rounding. */
|
||||
asFloat = static_cast<float>(k) + 0.5f;
|
||||
n = 158 - (asInt >> 23);
|
||||
return n;
|
||||
}
|
||||
|
||||
/* The example below shows how to make a macro for nlz. It uses an
|
||||
extension to the C and C++ languages that is provided by the GNU C/C++
|
||||
compiler, namely, that of allowing statements and declarations in
|
||||
expressions (see "Using and Porting GNU CC", by Richard M. Stallman
|
||||
(1998). The underscores are necessary to protect against the
|
||||
possibility that the macro argument will conflict with one of its local
|
||||
variables, e.g., NLZ(k). */
|
||||
|
||||
int nlz9(unsigned k)
|
||||
{
|
||||
union {
|
||||
unsigned asInt;
|
||||
float asFloat;
|
||||
};
|
||||
int n;
|
||||
|
||||
k = k & ~(k >> 1); /* Fix problem with rounding. */
|
||||
asFloat = static_cast<float>(k);
|
||||
n = 158 - (asInt >> 23);
|
||||
n = (n & 31) + (n >> 6); /* Fix problem with k = 0. */
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Below are three nearly equivalent programs for computing the number
|
||||
of leading zeros in a word. This material is not in HD, but may be in a
|
||||
future edition.
|
||||
Immediately below is Robert Harley's algorithm, found at the
|
||||
comp.arch newsgroup entry dated 7/12/96, pointed out to me by Norbert
|
||||
Juffa.
|
||||
Table entries marked "u" are unused. 14 ops including a multiply,
|
||||
plus an indexed load.
|
||||
The smallest multiplier that works is 0x045BCED1 = 17*65*129*513 (all
|
||||
of form 2**k + 1). There are no multipliers of three terms of the form
|
||||
2**k +- 1 that work, with a table size of 64 or 128. There are some,
|
||||
with a table size of 64, if you precede the multiplication with x = x -
|
||||
(x >> 1), but that seems less elegant. There are also some if you use a
|
||||
table size of 256, the smallest is 0x01033CBF = 65*255*1025 (this would
|
||||
save two instructions in the form of this algorithm with the
|
||||
multiplication expanded into shifts and adds, but the table size is
|
||||
getting a bit large). */
|
||||
|
||||
#define u 99
|
||||
int nlz10(unsigned x)
|
||||
{
|
||||
static char table[64] =
|
||||
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
|
||||
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
|
||||
17, u, 4, u, u, u,11, u, 13,22,20, u,26, u, u,18,
|
||||
5, u, u,23, u,27, u, 6, u,24, 7, u, 8, u, 0, u};
|
||||
|
||||
x = x | (x >> 1); // Propagate leftmost
|
||||
x = x | (x >> 2); // 1-bit to the right.
|
||||
x = x | (x >> 4);
|
||||
x = x | (x >> 8);
|
||||
x = x | (x >>16);
|
||||
x = x*0x06EB14F9; // Multiplier is 7*255**3.
|
||||
return table[x >> 26];
|
||||
}
|
||||
|
||||
/* Harley's algorithm with multiply expanded.
|
||||
19 elementary ops plus an indexed load. */
|
||||
|
||||
int nlz10a(unsigned x)
|
||||
{
|
||||
static char table[64] =
|
||||
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
|
||||
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
|
||||
17, u, 4, u, u, u,11, u, 13,22,20, u,26, u, u,18,
|
||||
5, u, u,23, u,27, u, 6, u,24, 7, u, 8, u, 0, u};
|
||||
|
||||
x = x | (x >> 1); // Propagate leftmost
|
||||
x = x | (x >> 2); // 1-bit to the right.
|
||||
x = x | (x >> 4);
|
||||
x = x | (x >> 8);
|
||||
x = x | (x >> 16);
|
||||
x = (x << 3) - x; // Multiply by 7.
|
||||
x = (x << 8) - x; // Multiply by 255.
|
||||
x = (x << 8) - x; // Again.
|
||||
x = (x << 8) - x; // Again.
|
||||
return table[x >> 26];
|
||||
}
|
||||
|
||||
/* Julius Goryavsky's version of Harley's algorithm.
|
||||
17 elementary ops plus an indexed load, if the machine
|
||||
has "and not." */
|
||||
|
||||
int nlz10b(unsigned x)
|
||||
{
|
||||
static char table[64] =
|
||||
{32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u,
|
||||
u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u,
|
||||
u,21, u, 8,11, u,15, u, u, u, u, 2,27, 0,25, u,
|
||||
22, u,12, u, u, 3,28, u, 23, u, 4,29, u, u,30,31};
|
||||
|
||||
x = x | (x >> 1); // Propagate leftmost
|
||||
x = x | (x >> 2); // 1-bit to the right.
|
||||
x = x | (x >> 4);
|
||||
x = x | (x >> 8);
|
||||
x = x & ~(x >> 16);
|
||||
x = x*0xFD7049FF; // Activate this line or the following 3.
|
||||
// x = (x << 9) - x; // Multiply by 511.
|
||||
// x = (x << 11) - x; // Multiply by 2047.
|
||||
// x = (x << 14) - x; // Multiply by 16383.
|
||||
return table[x >> 26];
|
||||
}
|
||||
|
||||
int errors;
|
||||
void error(int x, int y)
|
||||
{
|
||||
errors = errors + 1;
|
||||
std::printf("Error for x = %08x, got %d\n", x, y);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
# ifdef NDEBUG
|
||||
|
||||
int i, n;
|
||||
static unsigned test[] = {0,32, 1,31, 2,30, 3,30, 4,29, 5,29, 6,29,
|
||||
7,29, 8,28, 9,28, 16,27, 32,26, 64,25, 128,24, 255,24, 256,23,
|
||||
512,22, 1024,21, 2048,20, 4096,19, 8192,18, 16384,17, 32768,16,
|
||||
65536,15, 0x20000,14, 0x40000,13, 0x80000,12, 0x100000,11,
|
||||
0x200000,10, 0x400000,9, 0x800000,8, 0x1000000,7, 0x2000000,6,
|
||||
0x4000000,5, 0x8000000,4, 0x0FFFFFFF,4, 0x10000000,3,
|
||||
0x3000FFFF,2, 0x50003333,1, 0x7FFFFFFF,1, 0x80000000,0,
|
||||
0xFFFFFFFF,0};
|
||||
std::size_t const Count = 1000;
|
||||
|
||||
n = sizeof(test)/4;
|
||||
|
||||
std::clock_t TimestampBeg = 0;
|
||||
std::clock_t TimestampEnd = 0;
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz1(test[i]) != test[i+1]) error(test[i], nlz1(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz1: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz1a(test[i]) != test[i+1]) error(test[i], nlz1a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz1a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz2(test[i]) != test[i+1]) error(test[i], nlz2(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz2: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz2a(test[i]) != test[i+1]) error(test[i], nlz2a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz2a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz3(test[i]) != test[i+1]) error(test[i], nlz3(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz3: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz4(test[i]) != test[i+1]) error(test[i], nlz4(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz4: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz5(test[i]) != test[i+1]) error(test[i], nlz5(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz5: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz6(test[i]) != test[i+1]) error(test[i], nlz6(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz6: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz7(test[i]) != test[i+1]) error(test[i], nlz7(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz7: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz8(test[i]) != test[i+1]) error(test[i], nlz8(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz8: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz9(test[i]) != test[i+1]) error(test[i], nlz9(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz9: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz10(test[i]) != test[i+1]) error(test[i], nlz10(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz10: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz10a(test[i]) != test[i+1]) error(test[i], nlz10a(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz10a: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
TimestampBeg = std::clock();
|
||||
for (std::size_t k = 0; k < Count; ++k)
|
||||
for (i = 0; i < n; i += 2) {
|
||||
if (nlz10b(test[i]) != test[i+1]) error(test[i], nlz10b(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
std::printf("nlz10b: %d clocks\n", static_cast<int>(TimestampEnd - TimestampBeg));
|
||||
|
||||
if (errors == 0)
|
||||
std::printf("Passed all %d cases.\n", static_cast<int>(sizeof(test)/8));
|
||||
|
||||
# endif//NDEBUG
|
||||
}
|
||||
329
lib/glm/test/core/core_func_matrix.cpp
Normal file
329
lib/glm/test/core/core_func_matrix.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
#include <glm/matrix.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/ulp.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace glm;
|
||||
|
||||
int test_matrixCompMult()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
mat2 m(0, 1, 2, 3);
|
||||
mat2 n = matrixCompMult(m, m);
|
||||
mat2 expected = mat2(0, 1, 4, 9);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x3 m(0, 1, 2, 3, 4, 5);
|
||||
mat2x3 n = matrixCompMult(m, m);
|
||||
mat2x3 expected = mat2x3(0, 1, 4, 9, 16, 25);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat2x4 n = matrixCompMult(m, m);
|
||||
mat2x4 expected = mat2x4(0, 1, 4, 9, 16, 25, 36, 49);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mat3 n = matrixCompMult(m, m);
|
||||
mat3 expected = mat3(0, 1, 4, 9, 16, 25, 36, 49, 64);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x2 m(0, 1, 2, 3, 4, 5);
|
||||
mat3x2 n = matrixCompMult(m, m);
|
||||
mat3x2 expected = mat3x2(0, 1, 4, 9, 16, 25);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat3x4 n = matrixCompMult(m, m);
|
||||
mat3x4 expected = mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
||||
mat4 n = matrixCompMult(m, m);
|
||||
mat4 expected = mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat4x2 n = matrixCompMult(m, m);
|
||||
mat4x2 expected = mat4x2(0, 1, 4, 9, 16, 25, 36, 49);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat4x3 n = matrixCompMult(m, m);
|
||||
mat4x3 expected = mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121);
|
||||
for (length_t l = 0; l < m.length(); ++l)
|
||||
Error += all(epsilonEqual(n[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_outerProduct()
|
||||
{
|
||||
{ glm::mat2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec2(1.0f)); }
|
||||
{ glm::mat3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec3(1.0f)); }
|
||||
{ glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f)); }
|
||||
|
||||
{ glm::mat2x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec2(1.0f)); }
|
||||
{ glm::mat2x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec2(1.0f)); }
|
||||
|
||||
{ glm::mat3x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec3(1.0f)); }
|
||||
{ glm::mat3x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec3(1.0f)); }
|
||||
|
||||
{ glm::mat4x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec4(1.0f)); }
|
||||
{ glm::mat4x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec4(1.0f)); }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_transpose()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
mat2 const m(0, 1, 2, 3);
|
||||
mat2 const t = transpose(m);
|
||||
mat2 const expected = mat2(0, 2, 1, 3);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x3 m(0, 1, 2, 3, 4, 5);
|
||||
mat3x2 t = transpose(m);
|
||||
mat3x2 const expected = mat3x2(0, 3, 1, 4, 2, 5);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat4x2 t = transpose(m);
|
||||
mat4x2 const expected = mat4x2(0, 4, 1, 5, 2, 6, 3, 7);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mat3 t = transpose(m);
|
||||
mat3 const expected = mat3(0, 3, 6, 1, 4, 7, 2, 5, 8);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x2 m(0, 1, 2, 3, 4, 5);
|
||||
mat2x3 t = transpose(m);
|
||||
mat2x3 const expected = mat2x3(0, 2, 4, 1, 3, 5);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat4x3 t = transpose(m);
|
||||
mat4x3 const expected = mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
||||
mat4 t = transpose(m);
|
||||
mat4 const expected = mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat2x4 t = transpose(m);
|
||||
mat2x4 const expected = mat2x4(0, 2, 4, 6, 1, 3, 5, 7);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat3x4 t = transpose(m);
|
||||
mat3x4 const expected = mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11);
|
||||
for (length_t l = 0; l < expected.length(); ++l)
|
||||
Error += all(epsilonEqual(t[l], expected[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_determinant()
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_inverse()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::mat4x4 A4x4(
|
||||
glm::vec4(1, 0, 1, 0),
|
||||
glm::vec4(0, 1, 0, 0),
|
||||
glm::vec4(0, 0, 1, 0),
|
||||
glm::vec4(0, 0, 0, 1));
|
||||
glm::mat4x4 B4x4 = inverse(A4x4);
|
||||
glm::mat4x4 I4x4 = A4x4 * B4x4;
|
||||
glm::mat4x4 Identity(1);
|
||||
for (length_t l = 0; l < Identity.length(); ++l)
|
||||
Error += all(epsilonEqual(I4x4[l], Identity[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3x3 A3x3(
|
||||
glm::vec3(1, 0, 1),
|
||||
glm::vec3(0, 1, 0),
|
||||
glm::vec3(0, 0, 1));
|
||||
glm::mat3x3 B3x3 = glm::inverse(A3x3);
|
||||
glm::mat3x3 I3x3 = A3x3 * B3x3;
|
||||
glm::mat3x3 Identity(1);
|
||||
for (length_t l = 0; l < Identity.length(); ++l)
|
||||
Error += all(epsilonEqual(I3x3[l], Identity[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat2x2 A2x2(
|
||||
glm::vec2(1, 1),
|
||||
glm::vec2(0, 1));
|
||||
glm::mat2x2 B2x2 = glm::inverse(A2x2);
|
||||
glm::mat2x2 I2x2 = A2x2 * B2x2;
|
||||
glm::mat2x2 Identity(1);
|
||||
for (length_t l = 0; l < Identity.length(); ++l)
|
||||
Error += all(epsilonEqual(I2x2[l], Identity[l], epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_inverse_simd()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::mat4x4 const Identity(1);
|
||||
|
||||
glm::mat4x4 const A4x4(
|
||||
glm::vec4(1, 0, 1, 0),
|
||||
glm::vec4(0, 1, 0, 0),
|
||||
glm::vec4(0, 0, 1, 0),
|
||||
glm::vec4(0, 0, 0, 1));
|
||||
glm::mat4x4 const B4x4 = glm::inverse(A4x4);
|
||||
glm::mat4x4 const I4x4 = A4x4 * B4x4;
|
||||
|
||||
Error += glm::all(glm::epsilonEqual(I4x4[0], Identity[0], 0.001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(I4x4[1], Identity[1], 0.001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(I4x4[2], Identity[2], 0.001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(I4x4[3], Identity[3], 0.001f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template<typename VEC3, typename MAT4>
|
||||
int test_inverse_perf(std::size_t Count, std::size_t Instance, char const * Message)
|
||||
{
|
||||
std::vector<MAT4> TestInputs;
|
||||
TestInputs.resize(Count);
|
||||
std::vector<MAT4> TestOutputs;
|
||||
TestOutputs.resize(TestInputs.size());
|
||||
|
||||
VEC3 Axis(glm::normalize(VEC3(1.0f, 2.0f, 3.0f)));
|
||||
|
||||
for(std::size_t i = 0; i < TestInputs.size(); ++i)
|
||||
{
|
||||
typename MAT4::value_type f = static_cast<typename MAT4::value_type>(i + Instance) * typename MAT4::value_type(0.1) + typename MAT4::value_type(0.1);
|
||||
TestInputs[i] = glm::rotate(glm::translate(MAT4(1), Axis * f), f, Axis);
|
||||
//TestInputs[i] = glm::translate(MAT4(1), Axis * f);
|
||||
}
|
||||
|
||||
std::clock_t StartTime = std::clock();
|
||||
|
||||
for(std::size_t i = 0; i < TestInputs.size(); ++i)
|
||||
TestOutputs[i] = glm::inverse(TestInputs[i]);
|
||||
|
||||
std::clock_t EndTime = std::clock();
|
||||
|
||||
for(std::size_t i = 0; i < TestInputs.size(); ++i)
|
||||
TestOutputs[i] = TestOutputs[i] * TestInputs[i];
|
||||
|
||||
typename MAT4::value_type Diff(0);
|
||||
for(std::size_t Entry = 0; Entry < TestOutputs.size(); ++Entry)
|
||||
{
|
||||
MAT4 i(1.0);
|
||||
MAT4 m(TestOutputs[Entry]);
|
||||
for(glm::length_t y = 0; y < m.length(); ++y)
|
||||
for(glm::length_t x = 0; x < m[y].length(); ++x)
|
||||
Diff = glm::max(m[y][x], i[y][x]);
|
||||
}
|
||||
|
||||
//glm::uint Ulp = 0;
|
||||
//Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp);
|
||||
|
||||
std::printf("inverse<%s>(%f): %lu\n", Message, static_cast<double>(Diff), EndTime - StartTime);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
Error += test_matrixCompMult();
|
||||
Error += test_outerProduct();
|
||||
Error += test_transpose();
|
||||
Error += test_determinant();
|
||||
Error += test_inverse();
|
||||
Error += test_inverse_simd();
|
||||
|
||||
# ifdef NDEBUG
|
||||
std::size_t const Samples = 1000;
|
||||
# else
|
||||
std::size_t const Samples = 1;
|
||||
# endif//NDEBUG
|
||||
|
||||
for(std::size_t i = 0; i < 1; ++i)
|
||||
{
|
||||
Error += test_inverse_perf<glm::vec3, glm::mat4>(Samples, i, "mat4");
|
||||
Error += test_inverse_perf<glm::dvec3, glm::dmat4>(Samples, i, "dmat4");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
7
lib/glm/test/core/core_func_noise.cpp
Normal file
7
lib/glm/test/core/core_func_noise.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
156
lib/glm/test/core/core_func_packing.cpp
Normal file
156
lib/glm/test/core/core_func_packing.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/packing.hpp>
|
||||
#include <vector>
|
||||
|
||||
int test_packUnorm2x16()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::vector<glm::vec2> A;
|
||||
A.push_back(glm::vec2(1.0f, 0.0f));
|
||||
A.push_back(glm::vec2(0.5f, 0.7f));
|
||||
A.push_back(glm::vec2(0.1f, 0.2f));
|
||||
|
||||
for(std::size_t i = 0; i < A.size(); ++i)
|
||||
{
|
||||
glm::vec2 B(A[i]);
|
||||
glm::uint32 C = glm::packUnorm2x16(B);
|
||||
glm::vec2 D = glm::unpackUnorm2x16(C);
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_packSnorm2x16()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::vector<glm::vec2> A;
|
||||
A.push_back(glm::vec2( 1.0f, 0.0f));
|
||||
A.push_back(glm::vec2(-0.5f,-0.7f));
|
||||
A.push_back(glm::vec2(-0.1f, 0.1f));
|
||||
|
||||
for(std::size_t i = 0; i < A.size(); ++i)
|
||||
{
|
||||
glm::vec2 B(A[i]);
|
||||
glm::uint32 C = glm::packSnorm2x16(B);
|
||||
glm::vec2 D = glm::unpackSnorm2x16(C);
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_packUnorm4x8()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::uint32 Packed = glm::packUnorm4x8(glm::vec4(1.0f, 0.5f, 0.0f, 1.0f));
|
||||
glm::u8vec4 Vec(255, 128, 0, 255);
|
||||
glm::uint32 & Ref = *reinterpret_cast<glm::uint32*>(&Vec[0]);
|
||||
|
||||
Error += Packed == Ref ? 0 : 1;
|
||||
|
||||
std::vector<glm::vec4> A;
|
||||
A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f));
|
||||
A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f));
|
||||
|
||||
for(std::size_t i = 0; i < A.size(); ++i)
|
||||
{
|
||||
glm::vec4 B(A[i]);
|
||||
glm::uint32 C = glm::packUnorm4x8(B);
|
||||
glm::vec4 D = glm::unpackUnorm4x8(C);
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_packSnorm4x8()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::vector<glm::vec4> A;
|
||||
A.push_back(glm::vec4( 1.0f, 0.0f,-0.5f,-1.0f));
|
||||
A.push_back(glm::vec4(-0.7f,-0.1f, 0.1f, 0.7f));
|
||||
|
||||
for(std::size_t i = 0; i < A.size(); ++i)
|
||||
{
|
||||
glm::vec4 B(A[i]);
|
||||
glm::uint32 C = glm::packSnorm4x8(B);
|
||||
glm::vec4 D = glm::unpackSnorm4x8(C);
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_packHalf2x16()
|
||||
{
|
||||
int Error = 0;
|
||||
/*
|
||||
std::vector<glm::hvec2> A;
|
||||
A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 2.0f)));
|
||||
A.push_back(glm::hvec2(glm::half(-1.0f), glm::half(-2.0f)));
|
||||
A.push_back(glm::hvec2(glm::half(-1.1f), glm::half( 1.1f)));
|
||||
*/
|
||||
std::vector<glm::vec2> A;
|
||||
A.push_back(glm::vec2( 1.0f, 2.0f));
|
||||
A.push_back(glm::vec2(-1.0f,-2.0f));
|
||||
A.push_back(glm::vec2(-1.1f, 1.1f));
|
||||
|
||||
for(std::size_t i = 0; i < A.size(); ++i)
|
||||
{
|
||||
glm::vec2 B(A[i]);
|
||||
glm::uint C = glm::packHalf2x16(B);
|
||||
glm::vec2 D = glm::unpackHalf2x16(C);
|
||||
//Error += B == D ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_packDouble2x32()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::vector<glm::uvec2> A;
|
||||
A.push_back(glm::uvec2( 1, 2));
|
||||
A.push_back(glm::uvec2(-1,-2));
|
||||
A.push_back(glm::uvec2(-1000, 1100));
|
||||
|
||||
for(std::size_t i = 0; i < A.size(); ++i)
|
||||
{
|
||||
glm::uvec2 B(A[i]);
|
||||
double C = glm::packDouble2x32(B);
|
||||
glm::uvec2 D = glm::unpackDouble2x32(C);
|
||||
Error += B == D ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_packSnorm4x8();
|
||||
Error += test_packUnorm4x8();
|
||||
Error += test_packSnorm2x16();
|
||||
Error += test_packUnorm2x16();
|
||||
Error += test_packHalf2x16();
|
||||
Error += test_packDouble2x32();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
164
lib/glm/test/core/core_func_swizzle.cpp
Normal file
164
lib/glm/test/core/core_func_swizzle.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
static int test_ivec2_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::ivec2 A(1, 2);
|
||||
glm::ivec2 B = A.yx();
|
||||
glm::ivec2 C = B.yx();
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec2 A(1, 2);
|
||||
glm::ivec2 B = A.yx;
|
||||
glm::ivec2 C = A.yx;
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += B == C ? 0 : 1;
|
||||
|
||||
B.xy = B.yx;
|
||||
C.xy = C.yx;
|
||||
|
||||
Error += B == C ? 0 : 1;
|
||||
|
||||
glm::ivec2 D(0, 0);
|
||||
D.yx = A.xy;
|
||||
Error += A.yx() == D ? 0 : 1;
|
||||
|
||||
glm::ivec2 E = A.yx;
|
||||
Error += E == D ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_ivec3_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::ivec3 A(1, 2, 3);
|
||||
glm::ivec3 B = A.zyx();
|
||||
glm::ivec3 C = B.zyx();
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
glm::ivec2 B = A.yx;
|
||||
glm::ivec2 C = A.yx;
|
||||
|
||||
Error += A.yx() == B ? 0 : 1;
|
||||
Error += B == C ? 0 : 1;
|
||||
|
||||
B.xy = B.yx;
|
||||
C.xy = C.yx;
|
||||
|
||||
Error += B == C ? 0 : 1;
|
||||
|
||||
glm::ivec2 D(0, 0);
|
||||
D.yx = A.xy;
|
||||
|
||||
Error += A.yx() == D ? 0 : 1;
|
||||
|
||||
glm::ivec2 E(0, 0);
|
||||
E.xy = A.xy();
|
||||
|
||||
Error += E == A.xy() ? 0 : 1;
|
||||
Error += E.xy() == A.xy() ? 0 : 1;
|
||||
|
||||
glm::ivec3 const F = A.xxx + A.xxx;
|
||||
Error += F == glm::ivec3(2) ? 0 : 1;
|
||||
|
||||
glm::ivec3 const G = A.xxx - A.xxx;
|
||||
Error += G == glm::ivec3(0) ? 0 : 1;
|
||||
|
||||
glm::ivec3 const H = A.xxx * A.xxx;
|
||||
Error += H == glm::ivec3(1) ? 0 : 1;
|
||||
|
||||
glm::ivec3 const I = A.xxx / A.xxx;
|
||||
Error += I == glm::ivec3(1) ? 0 : 1;
|
||||
|
||||
glm::ivec3 J(1, 2, 3);
|
||||
J.xyz += glm::ivec3(1);
|
||||
Error += J == glm::ivec3(2, 3, 4) ? 0 : 1;
|
||||
|
||||
glm::ivec3 K(1, 2, 3);
|
||||
K.xyz += A.xyz;
|
||||
Error += K == glm::ivec3(2, 4, 6) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_ivec4_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::ivec4 A(1, 2, 3, 4);
|
||||
glm::ivec4 B = A.wzyx();
|
||||
glm::ivec4 C = B.wzyx();
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec4_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
glm::vec4 B = A.wzyx();
|
||||
glm::vec4 C = B.wzyx();
|
||||
|
||||
Error += glm::any(glm::notEqual(A, B, 0.0001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, 0.0001f)) ? 0 : 1;
|
||||
|
||||
float D = glm::dot(C.wzyx(), C.xyzw());
|
||||
Error += glm::equal(D, 20.f, 0.001f) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_ivec2_swizzle();
|
||||
Error += test_ivec3_swizzle();
|
||||
Error += test_ivec4_swizzle();
|
||||
Error += test_vec4_swizzle();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
lib/glm/test/core/core_func_trigonometric.cpp
Normal file
10
lib/glm/test/core/core_func_trigonometric.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <glm/trigonometric.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
180
lib/glm/test/core/core_func_vector_relational.cpp
Normal file
180
lib/glm/test/core/core_func_vector_relational.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
|
||||
static int test_not()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::bvec1 v(false);
|
||||
Error += glm::all(glm::not_(v)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::bvec2 v(false);
|
||||
Error += glm::all(glm::not_(v)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::bvec3 v(false);
|
||||
Error += glm::all(glm::not_(v)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::bvec4 v(false);
|
||||
Error += glm::all(glm::not_(v)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_less()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec2 const A(1, 2);
|
||||
glm::vec2 const B(2, 3);
|
||||
Error += glm::all(glm::lessThan(A, B)) ? 0: 1;
|
||||
Error += glm::all(glm::lessThanEqual(A, B)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 const A(1, 2, 3);
|
||||
glm::vec3 const B(2, 3, 4);
|
||||
Error += glm::all(glm::lessThan(A, B)) ? 0: 1;
|
||||
Error += glm::all(glm::lessThanEqual(A, B)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 const A(1, 2, 3, 4);
|
||||
glm::vec4 const B(2, 3, 4, 5);
|
||||
Error += glm::all(glm::lessThan(A, B)) ? 0: 1;
|
||||
Error += glm::all(glm::lessThanEqual(A, B)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 const A(1, 2);
|
||||
glm::ivec2 const B(2, 3);
|
||||
Error += glm::all(glm::lessThan(A, B)) ? 0: 1;
|
||||
|
||||
glm::ivec2 const C(1, 3);
|
||||
Error += glm::all(glm::lessThanEqual(A, C)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
glm::ivec3 const B(2, 3, 4);
|
||||
Error += glm::all(glm::lessThan(A, B)) ? 0: 1;
|
||||
|
||||
glm::ivec3 const C(1, 3, 4);
|
||||
Error += glm::all(glm::lessThanEqual(A, C)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1, 2, 3, 4);
|
||||
glm::ivec4 const B(2, 3, 4, 5);
|
||||
Error += glm::all(glm::lessThan(A, B)) ? 0: 1;
|
||||
|
||||
glm::ivec4 const C(1, 3, 4, 5);
|
||||
Error += glm::all(glm::lessThanEqual(A, C)) ? 0: 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_greater()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec2 const A(1, 2);
|
||||
glm::vec2 const B(2, 3);
|
||||
Error += glm::all(glm::greaterThan(B, A)) ? 0: 1;
|
||||
Error += glm::all(glm::greaterThanEqual(B, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 const A(1, 2, 3);
|
||||
glm::vec3 const B(2, 3, 4);
|
||||
Error += glm::all(glm::greaterThan(B, A)) ? 0: 1;
|
||||
Error += glm::all(glm::greaterThanEqual(B, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 const A(1, 2, 3, 4);
|
||||
glm::vec4 const B(2, 3, 4, 5);
|
||||
Error += glm::all(glm::greaterThan(B, A)) ? 0: 1;
|
||||
Error += glm::all(glm::greaterThanEqual(B, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 const A(1, 2);
|
||||
glm::ivec2 const B(2, 3);
|
||||
Error += glm::all(glm::greaterThan(B, A)) ? 0: 1;
|
||||
|
||||
glm::ivec2 const C(1, 3);
|
||||
Error += glm::all(glm::greaterThanEqual(C, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
glm::ivec3 const B(2, 3, 4);
|
||||
Error += glm::all(glm::greaterThan(B, A)) ? 0: 1;
|
||||
|
||||
glm::ivec3 const C(1, 3, 4);
|
||||
Error += glm::all(glm::greaterThanEqual(C, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1, 2, 3, 4);
|
||||
glm::ivec4 const B(2, 3, 4, 5);
|
||||
Error += glm::all(glm::greaterThan(B, A)) ? 0: 1;
|
||||
|
||||
glm::ivec4 const C(1, 3, 4, 5);
|
||||
Error += glm::all(glm::greaterThanEqual(C, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_equal()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec2 const A(1, 2);
|
||||
glm::ivec2 const B(1, 2);
|
||||
Error += glm::all(glm::equal(B, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
glm::ivec3 const B(1, 2, 3);
|
||||
Error += glm::all(glm::equal(B, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1, 2, 3, 4);
|
||||
glm::ivec4 const B(1, 2, 3, 4);
|
||||
Error += glm::all(glm::equal(B, A)) ? 0: 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_not();
|
||||
Error += test_less();
|
||||
Error += test_greater();
|
||||
Error += test_equal();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
12
lib/glm/test/core/core_setup_force_cxx98.cpp
Normal file
12
lib/glm/test/core/core_setup_force_cxx98.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef GLM_FORCE_CXX98
|
||||
# define GLM_FORCE_CXX98
|
||||
#endif
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
22
lib/glm/test/core/core_setup_force_size_t_length.cpp
Normal file
22
lib/glm/test/core/core_setup_force_size_t_length.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#define GLM_FORCE_SIZE_T_LENGTH
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
template <typename genType>
|
||||
genType add(genType const& a, genType const& b)
|
||||
{
|
||||
genType result(0);
|
||||
for(glm::length_t i = 0; i < a.length(); ++i)
|
||||
result[i] = a[i] + b[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec4 v(1);
|
||||
Error += add(v, v) == glm::ivec4(2) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
230
lib/glm/test/core/core_setup_message.cpp
Normal file
230
lib/glm/test/core/core_setup_message.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
#define GLM_FORCE_MESSAGES
|
||||
#include <glm/vec3.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
int test_compiler()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_VC12:
|
||||
std::printf("Visual C++ 12 - 2013\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC14:
|
||||
std::printf("Visual C++ 14 - 2015\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15:
|
||||
std::printf("Visual C++ 15 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15_3:
|
||||
std::printf("Visual C++ 15.3 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15_5:
|
||||
std::printf("Visual C++ 15.5 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15_6:
|
||||
std::printf("Visual C++ 15.6 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15_7:
|
||||
std::printf("Visual C++ 15.7 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15_8:
|
||||
std::printf("Visual C++ 15.8 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC15_9:
|
||||
std::printf("Visual C++ 15.9 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC16:
|
||||
std::printf("Visual C++ 16 - 2019\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("Visual C++ version not detected\n");
|
||||
Error += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_GCC46:
|
||||
std::printf("GCC 4.6\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC47:
|
||||
std::printf("GCC 4.7\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC48:
|
||||
std::printf("GCC 4.8\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC49:
|
||||
std::printf("GCC 4.9\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC5:
|
||||
std::printf("GCC 5\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC6:
|
||||
std::printf("GCC 6\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC7:
|
||||
std::printf("GCC 7\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC8:
|
||||
std::printf("GCC 8\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("GCC version not detected\n");
|
||||
Error += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_CUDA)
|
||||
{
|
||||
std::printf("CUDA\n");
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_CLANG34:
|
||||
std::printf("Clang 3.4\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG35:
|
||||
std::printf("Clang 3.5\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG36:
|
||||
std::printf("Clang 3.6\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG37:
|
||||
std::printf("Clang 3.7\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG38:
|
||||
std::printf("Clang 3.8\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG39:
|
||||
std::printf("Clang 3.9\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG40:
|
||||
std::printf("Clang 4.0\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG41:
|
||||
std::printf("Clang 4.1\n");
|
||||
break;
|
||||
case GLM_COMPILER_CLANG42:
|
||||
std::printf("Clang 4.2\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("LLVM version not detected\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_INTEL)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_INTEL14:
|
||||
std::printf("ICC 14 - 2013 SP1\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL15:
|
||||
std::printf("ICC 15 - 2015\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL16:
|
||||
std::printf("ICC 16 - 2017\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL17:
|
||||
std::printf("ICC 17 - 20XX\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("Intel compiler version not detected\n");
|
||||
Error += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::printf("Undetected compiler\n");
|
||||
Error += 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_model()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += ((sizeof(void*) == 4) && (GLM_MODEL == GLM_MODEL_32)) || ((sizeof(void*) == 8) && (GLM_MODEL == GLM_MODEL_64)) ? 0 : 1;
|
||||
|
||||
if(GLM_MODEL == GLM_MODEL_32)
|
||||
std::printf("GLM_MODEL_32\n");
|
||||
else if(GLM_MODEL == GLM_MODEL_64)
|
||||
std::printf("GLM_MODEL_64\n");
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_instruction_set()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::printf("GLM_ARCH: ");
|
||||
|
||||
if(GLM_ARCH & GLM_ARCH_ARM_BIT)
|
||||
std::printf("ARM ");
|
||||
if(GLM_ARCH & GLM_ARCH_NEON_BIT)
|
||||
std::printf("NEON ");
|
||||
if(GLM_ARCH & GLM_ARCH_AVX2)
|
||||
std::printf("AVX2 ");
|
||||
if(GLM_ARCH & GLM_ARCH_AVX)
|
||||
std::printf("AVX ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSE42_BIT)
|
||||
std::printf("SSE4.2 ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSE41_BIT)
|
||||
std::printf("SSE4.1 ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSSE3_BIT)
|
||||
std::printf("SSSE3 ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSE3_BIT)
|
||||
std::printf("SSE3 ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSE2_BIT)
|
||||
std::printf("SSE2 ");
|
||||
|
||||
std::printf("\n");
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_cpp_version()
|
||||
{
|
||||
std::printf("__cplusplus: %d\n", static_cast<int>(__cplusplus));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_operators()
|
||||
{
|
||||
glm::ivec3 A(1);
|
||||
glm::ivec3 B(1);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if !defined(GLM_FORCE_PLATFORM_UNKNOWN) && !defined(GLM_FORCE_COMPILER_UNKNOWN) && !defined(GLM_FORCE_ARCH_UNKNOWN) && !defined(GLM_FORCE_CXX_UNKNOWN)
|
||||
|
||||
Error += test_cpp_version();
|
||||
Error += test_compiler();
|
||||
Error += test_model();
|
||||
Error += test_instruction_set();
|
||||
Error += test_operators();
|
||||
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
21
lib/glm/test/core/core_setup_platform_unknown.cpp
Normal file
21
lib/glm/test/core/core_setup_platform_unknown.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef GLM_FORCE_PLATFORM_UNKNOWN
|
||||
# define GLM_FORCE_PLATFORM_UNKNOWN
|
||||
#endif
|
||||
#ifndef GLM_FORCE_COMPILER_UNKNOWN
|
||||
# define GLM_FORCE_COMPILER_UNKNOWN
|
||||
#endif
|
||||
#ifndef GLM_FORCE_ARCH_UNKNOWN
|
||||
# define GLM_FORCE_ARCH_UNKNOWN
|
||||
#endif
|
||||
#ifndef GLM_FORCE_CXX_UNKNOWN
|
||||
# define GLM_FORCE_CXX_UNKNOWN
|
||||
#endif
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
58
lib/glm/test/core/core_setup_precision.cpp
Normal file
58
lib/glm/test/core/core_setup_precision.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#define GLM_FORCE_INLINE
|
||||
#define GLM_PRECISION_HIGHP_FLOAT
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
static int test_mat()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::mat2) == sizeof(glm::highp_mat2) ? 0 : 1;
|
||||
Error += sizeof(glm::mat3) == sizeof(glm::highp_mat3) ? 0 : 1;
|
||||
Error += sizeof(glm::mat4) == sizeof(glm::highp_mat4) ? 0 : 1;
|
||||
|
||||
Error += sizeof(glm::mat2x2) == sizeof(glm::highp_mat2x2) ? 0 : 1;
|
||||
Error += sizeof(glm::mat2x3) == sizeof(glm::highp_mat2x3) ? 0 : 1;
|
||||
Error += sizeof(glm::mat2x4) == sizeof(glm::highp_mat2x4) ? 0 : 1;
|
||||
Error += sizeof(glm::mat3x2) == sizeof(glm::highp_mat3x2) ? 0 : 1;
|
||||
Error += sizeof(glm::mat3x3) == sizeof(glm::highp_mat3x3) ? 0 : 1;
|
||||
Error += sizeof(glm::mat3x4) == sizeof(glm::highp_mat3x4) ? 0 : 1;
|
||||
Error += sizeof(glm::mat4x2) == sizeof(glm::highp_mat4x2) ? 0 : 1;
|
||||
Error += sizeof(glm::mat4x3) == sizeof(glm::highp_mat4x3) ? 0 : 1;
|
||||
Error += sizeof(glm::mat4x4) == sizeof(glm::highp_mat4x4) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec2) == sizeof(glm::highp_vec2) ? 0 : 1;
|
||||
Error += sizeof(glm::vec3) == sizeof(glm::highp_vec3) ? 0 : 1;
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_dvec()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_mat();
|
||||
Error += test_vec();
|
||||
Error += test_dvec();
|
||||
|
||||
return Error;
|
||||
}
|
||||
92
lib/glm/test/core/core_type_aligned.cpp
Normal file
92
lib/glm/test/core/core_type_aligned.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE
|
||||
#include <type_traits>
|
||||
|
||||
static_assert(sizeof(glm::bvec4) > sizeof(glm::bvec2), "Invalid sizeof");
|
||||
static_assert(sizeof(glm::ivec4) > sizeof(glm::uvec2), "Invalid sizeof");
|
||||
static_assert(sizeof(glm::dvec4) > sizeof(glm::dvec2), "Invalid sizeof");
|
||||
|
||||
static_assert(sizeof(glm::bvec4) == sizeof(glm::bvec3), "Invalid sizeof");
|
||||
static_assert(sizeof(glm::uvec4) == sizeof(glm::uvec3), "Invalid sizeof");
|
||||
static_assert(sizeof(glm::dvec4) == sizeof(glm::dvec3), "Invalid sizeof");
|
||||
|
||||
static int test_storage_aligned()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
size_t size1_aligned = sizeof(glm::detail::storage<1, int, true>::type);
|
||||
Error += size1_aligned == sizeof(int) * 1 ? 0 : 1;
|
||||
size_t size2_aligned = sizeof(glm::detail::storage<2, int, true>::type);
|
||||
Error += size2_aligned == sizeof(int) * 2 ? 0 : 1;
|
||||
size_t size4_aligned = sizeof(glm::detail::storage<4, int, true>::type);
|
||||
Error += size4_aligned == sizeof(int) * 4 ? 0 : 1;
|
||||
|
||||
size_t align1_aligned = alignof(glm::detail::storage<1, int, true>::type);
|
||||
Error += align1_aligned == 4 ? 0 : 1;
|
||||
size_t align2_aligned = alignof(glm::detail::storage<2, int, true>::type);
|
||||
Error += align2_aligned == 8 ? 0 : 1;
|
||||
size_t align4_aligned = alignof(glm::detail::storage<4, int, true>::type);
|
||||
Error += align4_aligned == 16 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_storage_unaligned()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
size_t align1_unaligned = alignof(glm::detail::storage<1, int, false>::type);
|
||||
Error += align1_unaligned == sizeof(int) ? 0 : 1;
|
||||
size_t align2_unaligned = alignof(glm::detail::storage<2, int, false>::type);
|
||||
Error += align2_unaligned == sizeof(int) ? 0 : 1;
|
||||
size_t align3_unaligned = alignof(glm::detail::storage<3, int, false>::type);
|
||||
Error += align3_unaligned == sizeof(int) ? 0 : 1;
|
||||
size_t align4_unaligned = alignof(glm::detail::storage<4, int, false>::type);
|
||||
Error += align4_unaligned == sizeof(int) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec3_aligned()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
struct Struct1
|
||||
{
|
||||
glm::vec4 A;
|
||||
float B;
|
||||
glm::vec3 C;
|
||||
};
|
||||
|
||||
std::size_t const Size1 = sizeof(Struct1);
|
||||
Error += Size1 == 48 ? 0 : 1;
|
||||
|
||||
struct Struct2
|
||||
{
|
||||
glm::vec4 A;
|
||||
glm::vec3 B;
|
||||
float C;
|
||||
};
|
||||
|
||||
std::size_t const Size2 = sizeof(Struct2);
|
||||
Error += Size2 == 48 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE
|
||||
Error += test_storage_aligned();
|
||||
Error += test_storage_unaligned();
|
||||
Error += test_vec3_aligned();
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
146
lib/glm/test/core/core_type_cast.cpp
Normal file
146
lib/glm/test/core/core_type_cast.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
struct my_vec2
|
||||
{
|
||||
operator glm::vec2() { return glm::vec2(x, y); }
|
||||
float x, y;
|
||||
};
|
||||
|
||||
int test_vec2_cast()
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::lowp_vec2 B(A);
|
||||
glm::mediump_vec2 C(A);
|
||||
glm::highp_vec2 D(A);
|
||||
|
||||
glm::vec2 E = static_cast<glm::vec2>(A);
|
||||
glm::lowp_vec2 F = static_cast<glm::lowp_vec2>(A);
|
||||
glm::mediump_vec2 G = static_cast<glm::mediump_vec2>(A);
|
||||
glm::highp_vec2 H = static_cast<glm::highp_vec2>(A);
|
||||
|
||||
my_vec2 I;
|
||||
glm::vec2 J = static_cast<glm::vec2>(I);
|
||||
glm::vec2 K(7.8f);
|
||||
|
||||
int Error(0);
|
||||
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(B, F, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(C, G, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(D, H, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_cast()
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::lowp_vec3 B(A);
|
||||
glm::mediump_vec3 C(A);
|
||||
glm::highp_vec3 D(A);
|
||||
|
||||
glm::vec3 E = static_cast<glm::vec3>(A);
|
||||
glm::lowp_vec3 F = static_cast<glm::lowp_vec3>(A);
|
||||
glm::mediump_vec3 G = static_cast<glm::mediump_vec3>(A);
|
||||
glm::highp_vec3 H = static_cast<glm::highp_vec3>(A);
|
||||
|
||||
int Error(0);
|
||||
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(B, F, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(C, G, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(D, H, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec4_cast()
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::lowp_vec4 B(A);
|
||||
glm::mediump_vec4 C(A);
|
||||
glm::highp_vec4 D(A);
|
||||
|
||||
glm::vec4 E = static_cast<glm::vec4>(A);
|
||||
glm::lowp_vec4 F = static_cast<glm::lowp_vec4>(A);
|
||||
glm::mediump_vec4 G = static_cast<glm::mediump_vec4>(A);
|
||||
glm::highp_vec4 H = static_cast<glm::highp_vec4>(A);
|
||||
|
||||
int Error(0);
|
||||
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(B, F, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(C, G, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(D, H, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_std_copy()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
std::vector<int> High;
|
||||
High.resize(64);
|
||||
std::vector<int> Medium(High.size());
|
||||
|
||||
std::copy(High.begin(), High.end(), Medium.begin());
|
||||
|
||||
*Medium.begin() = *High.begin();
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::dvec4> High4;
|
||||
High4.resize(64);
|
||||
std::vector<glm::vec4> Medium4(High4.size());
|
||||
|
||||
std::copy(High4.begin(), High4.end(), Medium4.begin());
|
||||
|
||||
*Medium4.begin() = *High4.begin();
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::dvec3> High3;
|
||||
High3.resize(64);
|
||||
std::vector<glm::vec3> Medium3(High3.size());
|
||||
|
||||
std::copy(High3.begin(), High3.end(), Medium3.begin());
|
||||
|
||||
*Medium3.begin() = *High3.begin();
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::dvec2> High2;
|
||||
High2.resize(64);
|
||||
std::vector<glm::vec2> Medium2(High2.size());
|
||||
|
||||
std::copy(High2.begin(), High2.end(), Medium2.begin());
|
||||
|
||||
*Medium2.begin() = *High2.begin();
|
||||
}
|
||||
|
||||
glm::dvec4 v1;
|
||||
glm::vec4 v2;
|
||||
|
||||
v2 = v1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_std_copy();
|
||||
Error += test_vec2_cast();
|
||||
Error += test_vec3_cast();
|
||||
Error += test_vec4_cast();
|
||||
|
||||
return Error;
|
||||
}
|
||||
351
lib/glm/test/core/core_type_ctor.cpp
Normal file
351
lib/glm/test/core/core_type_ctor.cpp
Normal file
@@ -0,0 +1,351 @@
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
static int test_vec1_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::vec1 f;
|
||||
glm::ivec1 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::vec1(0);
|
||||
Error += glm::all(glm::equal(A.i, glm::ivec1(0))) ? 0 : 1;
|
||||
|
||||
B.f = glm::vec1(1);
|
||||
Error += glm::all(glm::equal(B.i, glm::ivec1(1065353216))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::vec2 f;
|
||||
glm::ivec2 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::vec2(0);
|
||||
Error += glm::all(glm::equal(A.i, glm::ivec2(0))) ? 0 : 1;
|
||||
|
||||
B.f = glm::vec2(1);
|
||||
Error += glm::all(glm::equal(B.i, glm::ivec2(1065353216))) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::vec3 f;
|
||||
glm::ivec3 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::vec3(0);
|
||||
Error += glm::all(glm::equal(A.i, glm::ivec3(0))) ? 0 : 1;
|
||||
|
||||
B.f = glm::vec3(1);
|
||||
Error += glm::all(glm::equal(B.i, glm::ivec3(1065353216))) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::vec4 f;
|
||||
glm::ivec4 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::vec4(0);
|
||||
Error += glm::all(glm::equal(A.i, glm::ivec4(0))) ? 0 : 1;
|
||||
|
||||
B.f = glm::vec4(1);
|
||||
Error += glm::all(glm::equal(B.i, glm::ivec4(1065353216))) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat2x2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat2x2 f;
|
||||
glm::mat2x2 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat2x2(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec2(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat2x2(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec2(1, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat2x3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat2x3 f;
|
||||
glm::mat2x3 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat2x3(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec3(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat2x3(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec3(1, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat2x4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat2x4 f;
|
||||
glm::mat2x4 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat2x4(0);
|
||||
glm::vec4 const C(0, 0, 0, 0);
|
||||
Error += glm::all(glm::equal(A.i[0], C, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat2x4(1);
|
||||
glm::vec4 const D(1, 0, 0, 0);
|
||||
Error += glm::all(glm::equal(B.i[0], D, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat3x2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat3x2 f;
|
||||
glm::mat3x2 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat3x2(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec2(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat3x2(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec2(1, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat3x3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat3x3 f;
|
||||
glm::mat3x3 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat3x3(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec3(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat3x3(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec3(1, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat3x4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat3x4 f;
|
||||
glm::mat3x4 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat3x4(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec4(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat3x4(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec4(1, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat4x2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat4x2 f;
|
||||
glm::mat4x2 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat4x2(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec2(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat4x2(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec2(1, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat4x3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat4x3 f;
|
||||
glm::mat4x3 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat4x3(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec3(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat4x3(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec3(1, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mat4x4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat4 f;
|
||||
glm::mat4 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat4(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec4(0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat4(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec4(1, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_quat_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::quat f;
|
||||
glm::quat i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::quat(0, 0, 0, 0);
|
||||
Error += glm::all(glm::equal(A.i, glm::quat(0, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
B.f = glm::quat(1, 1, 1, 1);
|
||||
Error += glm::all(glm::equal(B.i, glm::quat(1, 1, 1, 1), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_vec1_ctor();
|
||||
Error += test_vec2_ctor();
|
||||
Error += test_vec3_ctor();
|
||||
Error += test_vec4_ctor();
|
||||
Error += test_mat2x2_ctor();
|
||||
Error += test_mat2x3_ctor();
|
||||
Error += test_mat2x4_ctor();
|
||||
Error += test_mat3x2_ctor();
|
||||
Error += test_mat3x3_ctor();
|
||||
Error += test_mat3x4_ctor();
|
||||
Error += test_mat4x2_ctor();
|
||||
Error += test_mat4x3_ctor();
|
||||
Error += test_mat4x4_ctor();
|
||||
Error += test_quat_ctor();
|
||||
|
||||
return Error;
|
||||
}
|
||||
26
lib/glm/test/core/core_type_int.cpp
Normal file
26
lib/glm/test/core/core_type_int.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext/scalar_int_sized.hpp>
|
||||
|
||||
static int test_bit_operator()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec4 const a(1);
|
||||
glm::ivec4 const b = ~a;
|
||||
Error += glm::all(glm::equal(b, glm::ivec4(-2))) ? 0 : 1;
|
||||
|
||||
glm::int32 const c(1);
|
||||
glm::int32 const d = ~c;
|
||||
Error += d == -2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_bit_operator();
|
||||
|
||||
return Error;
|
||||
}
|
||||
79
lib/glm/test/core/core_type_length.cpp
Normal file
79
lib/glm/test/core/core_type_length.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
static int test_length_mat_non_squared()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::mat2x3().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat2x4().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat3x2().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat3x4().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat4x2().length() == 4 ? 0 : 1;
|
||||
Error += glm::mat4x3().length() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::dmat2x3().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x4().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat3x2().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x4().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat4x2().length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4x3().length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_length_mat()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::mat2().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat3().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat4().length() == 4 ? 0 : 1;
|
||||
Error += glm::mat2x2().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat3x3().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat4x4().length() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::dmat2().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat3().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat4().length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat2x2().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat3x3().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat4x4().length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_length_vec()
|
||||
{
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::vec2().length() == 2 ? 0 : 1;
|
||||
Error += glm::vec3().length() == 3 ? 0 : 1;
|
||||
Error += glm::vec4().length() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::ivec2().length() == 2 ? 0 : 1;
|
||||
Error += glm::ivec3().length() == 3 ? 0 : 1;
|
||||
Error += glm::ivec4().length() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::uvec2().length() == 2 ? 0 : 1;
|
||||
Error += glm::uvec3().length() == 3 ? 0 : 1;
|
||||
Error += glm::uvec4().length() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::dvec2().length() == 2 ? 0 : 1;
|
||||
Error += glm::dvec3().length() == 3 ? 0 : 1;
|
||||
Error += glm::dvec4().length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_length_vec();
|
||||
Error += test_length_mat();
|
||||
Error += test_length_mat_non_squared();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
177
lib/glm/test/core/core_type_mat2x2.cpp
Normal file
177
lib/glm/test/core/core_type_mat2x2.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/matrix.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
int test_operators()
|
||||
{
|
||||
glm::mat2x2 l(1.0f);
|
||||
glm::mat2x2 m(1.0f);
|
||||
glm::vec2 u(1.0f);
|
||||
glm::vec2 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec2 a = m * u;
|
||||
glm::vec2 b = v * m;
|
||||
glm::mat2x2 n = x / m;
|
||||
glm::mat2x2 o = m / x;
|
||||
glm::mat2x2 p = x * m;
|
||||
glm::mat2x2 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_inverse()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
glm::mat2 const Matrix(1, 2, 3, 4);
|
||||
glm::mat2 const Inverse = glm::inverse(Matrix);
|
||||
glm::mat2 const Identity = Matrix * Inverse;
|
||||
|
||||
Error += glm::all(glm::equal(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat2 const Matrix(1, 2, 3, 4);
|
||||
glm::mat2 const Identity = Matrix / Matrix;
|
||||
|
||||
Error += glm::all(glm::equal(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::mediump_mat2x2 const A(1.0f);
|
||||
glm::highp_mat2x2 const B(A);
|
||||
glm::mediump_mat2x2 const C(B);
|
||||
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
glm::mat2x2 m0(
|
||||
glm::vec2(0, 1),
|
||||
glm::vec2(2, 3));
|
||||
|
||||
glm::mat2x2 m1{0, 1, 2, 3};
|
||||
|
||||
glm::mat2x2 m2{
|
||||
{0, 1},
|
||||
{2, 3}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat2x2> v1{
|
||||
{0, 1, 2, 3},
|
||||
{0, 1, 2, 3}
|
||||
};
|
||||
|
||||
std::vector<glm::mat2x2> v2{
|
||||
{
|
||||
{ 0, 1},
|
||||
{ 4, 5}
|
||||
},
|
||||
{
|
||||
{ 0, 1},
|
||||
{ 4, 5}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat2 B(A);
|
||||
glm::mat2 Identity(1.0f);
|
||||
|
||||
Error += glm::all(glm::equal(B, Identity, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 16 == sizeof(glm::mat2x2) ? 0 : 1;
|
||||
Error += 32 == sizeof(glm::dmat2x2) ? 0 : 1;
|
||||
Error += glm::mat2x2().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x2().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat2x2::length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x2::length() == 2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat2x2::length() == 2, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_inverse();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
142
lib/glm/test/core/core_type_mat2x3.cpp
Normal file
142
lib/glm/test/core/core_type_mat2x3.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
glm::mat2x3 l(1.0f);
|
||||
glm::mat2x3 m(1.0f);
|
||||
glm::vec2 u(1.0f);
|
||||
glm::vec3 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec3 a = m * u;
|
||||
glm::vec2 b = v * m;
|
||||
glm::mat2x3 n = x / m;
|
||||
glm::mat2x3 o = m / x;
|
||||
glm::mat2x3 p = x * m;
|
||||
glm::mat2x3 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
glm::mat2x3 m0(
|
||||
glm::vec3(0, 1, 2),
|
||||
glm::vec3(3, 4, 5));
|
||||
|
||||
glm::mat2x3 m1{0, 1, 2, 3, 4, 5};
|
||||
|
||||
glm::mat2x3 m2{
|
||||
{0, 1, 2},
|
||||
{3, 4, 5}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat2x3> v1{
|
||||
{0, 1, 2, 3, 4, 5},
|
||||
{0, 1, 2, 3, 4, 5}
|
||||
};
|
||||
|
||||
std::vector<glm::mat2x3> v2{
|
||||
{
|
||||
{ 0, 1, 2},
|
||||
{ 4, 5, 6}
|
||||
},
|
||||
{
|
||||
{ 0, 1, 2},
|
||||
{ 4, 5, 6}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat2x3 B(A);
|
||||
glm::mat2x3 Identity(1.0f);
|
||||
|
||||
Error += glm::all(glm::equal(B, Identity, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 24 == sizeof(glm::mat2x3) ? 0 : 1;
|
||||
Error += 48 == sizeof(glm::dmat2x3) ? 0 : 1;
|
||||
Error += glm::mat2x3().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x3().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat2x3::length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x3::length() == 2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat2x3::length() == 2, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
147
lib/glm/test/core/core_type_mat2x4.cpp
Normal file
147
lib/glm/test/core/core_type_mat2x4.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
glm::mat2x4 l(1.0f);
|
||||
glm::mat2x4 m(1.0f);
|
||||
glm::vec2 u(1.0f);
|
||||
glm::vec4 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec4 a = m * u;
|
||||
glm::vec2 b = v * m;
|
||||
glm::mat2x4 n = x / m;
|
||||
glm::mat2x4 o = m / x;
|
||||
glm::mat2x4 p = x * m;
|
||||
glm::mat2x4 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
glm::mat2x4 m0(
|
||||
glm::vec4(0, 1, 2, 3),
|
||||
glm::vec4(4, 5, 6, 7));
|
||||
|
||||
glm::mat2x4 m1{0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
glm::mat2x4 m2{
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat2x4> v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
};
|
||||
|
||||
std::vector<glm::mat2x4> v2{
|
||||
{
|
||||
{ 0, 1, 2, 3},
|
||||
{ 4, 5, 6, 7}
|
||||
},
|
||||
{
|
||||
{ 0, 1, 2, 3},
|
||||
{ 4, 5, 6, 7}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat2x4 B(A);
|
||||
glm::mat2x4 Identity(1.0f);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::epsilonEqual(B[i], Identity[i], glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 32 == sizeof(glm::mat2x4) ? 0 : 1;
|
||||
Error += 64 == sizeof(glm::dmat2x4) ? 0 : 1;
|
||||
Error += glm::mat2x4().length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x4().length() == 2 ? 0 : 1;
|
||||
Error += glm::mat2x4::length() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x4::length() == 2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat2x4::length() == 2, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
148
lib/glm/test/core/core_type_mat3x2.cpp
Normal file
148
lib/glm/test/core/core_type_mat3x2.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static bool test_operators()
|
||||
{
|
||||
glm::mat3x2 l(1.0f);
|
||||
glm::mat3x2 m(1.0f);
|
||||
glm::vec3 u(1.0f);
|
||||
glm::vec2 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec2 a = m * u;
|
||||
glm::vec3 b = v * m;
|
||||
glm::mat3x2 n = x / m;
|
||||
glm::mat3x2 o = m / x;
|
||||
glm::mat3x2 p = x * m;
|
||||
glm::mat3x2 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
glm::mat3x2 m0(
|
||||
glm::vec2(0, 1),
|
||||
glm::vec2(2, 3),
|
||||
glm::vec2(4, 5));
|
||||
|
||||
glm::mat3x2 m1{0, 1, 2, 3, 4, 5};
|
||||
|
||||
glm::mat3x2 m2{
|
||||
{0, 1},
|
||||
{2, 3},
|
||||
{4, 5}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat3x2> v1{
|
||||
{0, 1, 2, 3, 4, 5},
|
||||
{0, 1, 2, 3, 4, 5}
|
||||
};
|
||||
|
||||
std::vector<glm::mat3x2> v2{
|
||||
{
|
||||
{ 0, 1},
|
||||
{ 2, 3},
|
||||
{ 4, 5}
|
||||
},
|
||||
{
|
||||
{ 0, 1},
|
||||
{ 2, 3},
|
||||
{ 4, 5}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat3x2 B(A);
|
||||
glm::mat3x2 Identity(1.0f);
|
||||
|
||||
Error += glm::all(glm::equal(B, Identity, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 24 == sizeof(glm::mat3x2) ? 0 : 1;
|
||||
Error += 48 == sizeof(glm::dmat3x2) ? 0 : 1;
|
||||
Error += glm::mat3x2().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x2().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat3x2::length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x2::length() == 3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat3x2::length() == 3, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
197
lib/glm/test/core/core_type_mat3x3.cpp
Normal file
197
lib/glm/test/core/core_type_mat3x3.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/matrix.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static int test_mat3x3()
|
||||
{
|
||||
glm::dmat3 Mat0(
|
||||
glm::dvec3(0.6f, 0.2f, 0.3f),
|
||||
glm::dvec3(0.2f, 0.7f, 0.5f),
|
||||
glm::dvec3(0.3f, 0.5f, 0.7f));
|
||||
glm::dmat3 Inv0 = glm::inverse(Mat0);
|
||||
glm::dmat3 Res0 = Mat0 * Inv0;
|
||||
|
||||
return glm::all(glm::equal(Res0, glm::dmat3(1.0), 0.01)) ? 0 : 1;
|
||||
}
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
glm::mat3x3 l(1.0f);
|
||||
glm::mat3x3 m(1.0f);
|
||||
glm::vec3 u(1.0f);
|
||||
glm::vec3 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec3 a = m * u;
|
||||
glm::vec3 b = v * m;
|
||||
glm::mat3x3 n = x / m;
|
||||
glm::mat3x3 o = m / x;
|
||||
glm::mat3x3 p = x * m;
|
||||
glm::mat3x3 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
static int test_inverse()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
glm::mat3 const Matrix(
|
||||
glm::vec3(0.6f, 0.2f, 0.3f),
|
||||
glm::vec3(0.2f, 0.7f, 0.5f),
|
||||
glm::vec3(0.3f, 0.5f, 0.7f));
|
||||
glm::mat3 const Inverse = glm::inverse(Matrix);
|
||||
glm::mat3 const Identity = Matrix * Inverse;
|
||||
|
||||
Error += glm::all(glm::equal(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat3 const Matrix(
|
||||
glm::vec3(0.6f, 0.2f, 0.3f),
|
||||
glm::vec3(0.2f, 0.7f, 0.5f),
|
||||
glm::vec3(0.3f, 0.5f, 0.7f));
|
||||
glm::mat3 const Identity = Matrix / Matrix;
|
||||
|
||||
Error += glm::all(glm::equal(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
glm::mat3x3 m0(
|
||||
glm::vec3(0, 1, 2),
|
||||
glm::vec3(3, 4, 5),
|
||||
glm::vec3(6, 7, 8));
|
||||
|
||||
glm::mat3x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
glm::mat3x3 m2{
|
||||
{0, 1, 2},
|
||||
{3, 4, 5},
|
||||
{6, 7, 8}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat3x3> v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8}
|
||||
};
|
||||
|
||||
std::vector<glm::mat3x3> v2{
|
||||
{
|
||||
{ 0, 1, 2},
|
||||
{ 3, 4, 5},
|
||||
{ 6, 7, 8}
|
||||
},
|
||||
{
|
||||
{ 0, 1, 2},
|
||||
{ 3, 4, 5},
|
||||
{ 6, 7, 8}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat3x3 B(A);
|
||||
glm::mat3x3 Identity(1.0f);
|
||||
|
||||
Error += glm::all(glm::equal(B, Identity, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 36 == sizeof(glm::mat3x3) ? 0 : 1;
|
||||
Error += 72 == sizeof(glm::dmat3x3) ? 0 : 1;
|
||||
Error += glm::mat3x3().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x3().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat3x3::length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x3::length() == 3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat3x3::length() == 3, "GLM: Failed constexpr");
|
||||
|
||||
constexpr glm::mat3x3 const Z(0.0f);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_mat3x3();
|
||||
Error += test_operators();
|
||||
Error += test_inverse();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
149
lib/glm/test/core/core_type_mat3x4.cpp
Normal file
149
lib/glm/test/core/core_type_mat3x4.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static bool test_operators()
|
||||
{
|
||||
glm::mat3x4 l(1.0f);
|
||||
glm::mat3x4 m(1.0f);
|
||||
glm::vec3 u(1.0f);
|
||||
glm::vec4 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec4 a = m * u;
|
||||
glm::vec3 b = v * m;
|
||||
glm::mat3x4 n = x / m;
|
||||
glm::mat3x4 o = m / x;
|
||||
glm::mat3x4 p = x * m;
|
||||
glm::mat3x4 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
glm::mat3x4 m0(
|
||||
glm::vec4(0, 1, 2, 3),
|
||||
glm::vec4(4, 5, 6, 7),
|
||||
glm::vec4(8, 9, 10, 11));
|
||||
|
||||
glm::mat3x4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
|
||||
|
||||
glm::mat3x4 m2{
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 10, 11}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat3x4> v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
};
|
||||
|
||||
std::vector<glm::mat3x4> v2{
|
||||
{
|
||||
{ 0, 1, 2, 3},
|
||||
{ 4, 5, 6, 7},
|
||||
{ 8, 9, 10, 11}
|
||||
},
|
||||
{
|
||||
{ 0, 1, 2, 3},
|
||||
{ 4, 5, 6, 7},
|
||||
{ 8, 9, 10, 11}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat3x4 B(A);
|
||||
glm::mat3x4 Identity(1.0f);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::epsilonEqual(B[i], Identity[i], glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 48 == sizeof(glm::mat3x4) ? 0 : 1;
|
||||
Error += 96 == sizeof(glm::dmat3x4) ? 0 : 1;
|
||||
Error += glm::mat3x4().length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x4().length() == 3 ? 0 : 1;
|
||||
Error += glm::mat3x4::length() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x4::length() == 3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat3x4::length() == 3, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
151
lib/glm/test/core/core_type_mat4x2.cpp
Normal file
151
lib/glm/test/core/core_type_mat4x2.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
glm::mat4x2 l(1.0f);
|
||||
glm::mat4x2 m(1.0f);
|
||||
glm::vec4 u(1.0f);
|
||||
glm::vec2 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec2 a = m * u;
|
||||
glm::vec4 b = v * m;
|
||||
glm::mat4x2 n = x / m;
|
||||
glm::mat4x2 o = m / x;
|
||||
glm::mat4x2 p = x * m;
|
||||
glm::mat4x2 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
glm::mat4x2 m0(
|
||||
glm::vec2(0, 1),
|
||||
glm::vec2(2, 3),
|
||||
glm::vec2(4, 5),
|
||||
glm::vec2(6, 7));
|
||||
|
||||
glm::mat4x2 m1{0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
glm::mat4x2 m2{
|
||||
{0, 1},
|
||||
{2, 3},
|
||||
{4, 5},
|
||||
{6, 7}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat4x2> v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7}
|
||||
};
|
||||
|
||||
std::vector<glm::mat4x2> v2{
|
||||
{
|
||||
{ 0, 1},
|
||||
{ 4, 5},
|
||||
{ 8, 9},
|
||||
{ 12, 13}
|
||||
},
|
||||
{
|
||||
{ 0, 1},
|
||||
{ 4, 5},
|
||||
{ 8, 9},
|
||||
{ 12, 13}
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat4x2 B(A);
|
||||
glm::mat4x2 Identity(1.0f);
|
||||
|
||||
Error += glm::all(glm::equal(B, Identity, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 32 == sizeof(glm::mat4x2) ? 0 : 1;
|
||||
Error += 64 == sizeof(glm::dmat4x2) ? 0 : 1;
|
||||
Error += glm::mat4x2().length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4x2().length() == 4 ? 0 : 1;
|
||||
Error += glm::mat4x2::length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4x2::length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat4x2::length() == 4, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
152
lib/glm/test/core/core_type_mat4x3.cpp
Normal file
152
lib/glm/test/core/core_type_mat4x3.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/mat2x2.hpp>
|
||||
#include <glm/mat2x3.hpp>
|
||||
#include <glm/mat2x4.hpp>
|
||||
#include <glm/mat3x2.hpp>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat3x4.hpp>
|
||||
#include <glm/mat4x2.hpp>
|
||||
#include <glm/mat4x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
glm::mat4x3 l(1.0f);
|
||||
glm::mat4x3 m(1.0f);
|
||||
glm::vec4 u(1.0f);
|
||||
glm::vec3 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec3 a = m * u;
|
||||
glm::vec4 b = v * m;
|
||||
glm::mat4x3 n = x / m;
|
||||
glm::mat4x3 o = m / x;
|
||||
glm::mat4x3 p = x * m;
|
||||
glm::mat4x3 q = m * x;
|
||||
bool R = glm::any(glm::notEqual(m, q, glm::epsilon<float>()));
|
||||
bool S = glm::all(glm::equal(m, l, glm::epsilon<float>()));
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
glm::mat4x3 m0(
|
||||
glm::vec3(0, 1, 2),
|
||||
glm::vec3(3, 4, 5),
|
||||
glm::vec3(6, 7, 8),
|
||||
glm::vec3(9, 10, 11));
|
||||
|
||||
glm::mat4x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
|
||||
|
||||
glm::mat4x3 m2{
|
||||
{0, 1, 2},
|
||||
{3, 4, 5},
|
||||
{6, 7, 8},
|
||||
{9, 10, 11}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat4x3> v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
};
|
||||
|
||||
std::vector<glm::mat4x3> v2{
|
||||
{
|
||||
{ 0, 1, 2 },
|
||||
{ 4, 5, 6 },
|
||||
{ 8, 9, 10 },
|
||||
{ 12, 13, 14 }
|
||||
},
|
||||
{
|
||||
{ 0, 1, 2 },
|
||||
{ 4, 5, 6 },
|
||||
{ 8, 9, 10 },
|
||||
{ 12, 13, 14 }
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template<typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat4x3 B(A);
|
||||
glm::mat4x3 Identity(1.0f);
|
||||
|
||||
Error += glm::all(glm::equal(B, Identity, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += entry<glm::mat2x2>();
|
||||
Error += entry<glm::mat2x3>();
|
||||
Error += entry<glm::mat2x4>();
|
||||
Error += entry<glm::mat3x2>();
|
||||
Error += entry<glm::mat3x3>();
|
||||
Error += entry<glm::mat3x4>();
|
||||
Error += entry<glm::mat4x2>();
|
||||
Error += entry<glm::mat4x3>();
|
||||
Error += entry<glm::mat4x4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace cast
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 48 == sizeof(glm::mat4x3) ? 0 : 1;
|
||||
Error += 96 == sizeof(glm::dmat4x3) ? 0 : 1;
|
||||
Error += glm::mat4x3().length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4x3().length() == 4 ? 0 : 1;
|
||||
Error += glm::mat4x3::length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4x3::length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat4x3::length() == 4, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
218
lib/glm/test/core/core_type_mat4x4.cpp
Normal file
218
lib/glm/test/core/core_type_mat4x4.cpp
Normal file
@@ -0,0 +1,218 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/matrix.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <vector>
|
||||
|
||||
template <typename matType, typename vecType>
|
||||
static int test_operators()
|
||||
{
|
||||
typedef typename matType::value_type value_type;
|
||||
|
||||
value_type const Epsilon = static_cast<value_type>(0.001);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
matType const M(static_cast<value_type>(2.0f));
|
||||
matType const N(static_cast<value_type>(1.0f));
|
||||
vecType const U(static_cast<value_type>(2.0f));
|
||||
|
||||
{
|
||||
matType const P = N * static_cast<value_type>(2.0f);
|
||||
Error += glm::all(glm::equal(P, M, Epsilon)) ? 0 : 1;
|
||||
|
||||
matType const Q = M / static_cast<value_type>(2.0f);
|
||||
Error += glm::all(glm::equal(Q, N, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
vecType const V = M * U;
|
||||
Error += glm::all(glm::equal(V, vecType(static_cast<value_type>(4.f)), Epsilon)) ? 0 : 1;
|
||||
|
||||
vecType const W = U / M;
|
||||
Error += glm::all(glm::equal(W, vecType(static_cast<value_type>(1.f)), Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
matType const O = M * N;
|
||||
Error += glm::all(glm::equal(O, matType(static_cast<value_type>(2.f)), Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename matType>
|
||||
static int test_inverse()
|
||||
{
|
||||
typedef typename matType::value_type value_type;
|
||||
|
||||
value_type const Epsilon = static_cast<value_type>(0.001);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
matType const Identity(static_cast<value_type>(1.0f));
|
||||
matType const Matrix(
|
||||
glm::vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||
glm::vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||
glm::vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||
glm::vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||
matType const Inverse = Identity / Matrix;
|
||||
matType const Result = Matrix * Inverse;
|
||||
|
||||
Error += glm::all(glm::equal(Identity, Result, Epsilon)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ctr()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if GLM_HAS_TRIVIAL_QUERIES
|
||||
//Error += std::is_trivially_default_constructible<glm::mat4>::value ? 0 : 1;
|
||||
//Error += std::is_trivially_copy_assignable<glm::mat4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::mat4>::value ? 0 : 1;
|
||||
//Error += std::is_copy_constructible<glm::mat4>::value ? 0 : 1;
|
||||
//Error += std::has_trivial_copy_constructor<glm::mat4>::value ? 0 : 1;
|
||||
#endif
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
glm::mat4 const m0(
|
||||
glm::vec4(0, 1, 2, 3),
|
||||
glm::vec4(4, 5, 6, 7),
|
||||
glm::vec4(8, 9, 10, 11),
|
||||
glm::vec4(12, 13, 14, 15));
|
||||
|
||||
assert(sizeof(m0) == 4 * 4 * 4);
|
||||
|
||||
glm::vec4 const V{0, 1, 2, 3};
|
||||
|
||||
glm::mat4 const m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
|
||||
glm::mat4 const m2{
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 10, 11},
|
||||
{12, 13, 14, 15}};
|
||||
|
||||
Error += glm::all(glm::equal(m0, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(m1, m2, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
|
||||
std::vector<glm::mat4> const m3{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
|
||||
|
||||
glm::mat4 const m4{
|
||||
{1, 0, 0, 0},
|
||||
{0, 1, 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 0, 1} };
|
||||
|
||||
Error += glm::equal(m4[0][0], 1.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::equal(m4[3][3], 1.0f, 0.0001f) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat4> const v1{
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
|
||||
|
||||
std::vector<glm::mat4> const v2{
|
||||
{
|
||||
{ 0, 1, 2, 3 },
|
||||
{ 4, 5, 6, 7 },
|
||||
{ 8, 9, 10, 11 },
|
||||
{ 12, 13, 14, 15 }
|
||||
},
|
||||
{
|
||||
{ 0, 1, 2, 3 },
|
||||
{ 4, 5, 6, 7 },
|
||||
{ 8, 9, 10, 11 },
|
||||
{ 12, 13, 14, 15 }
|
||||
}};
|
||||
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_member_alloc_bug()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
struct repro
|
||||
{
|
||||
repro(){ this->matrix = new glm::mat4(); }
|
||||
~repro(){delete this->matrix;}
|
||||
|
||||
glm::mat4* matrix;
|
||||
};
|
||||
|
||||
repro Repro;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += 64 == sizeof(glm::mat4) ? 0 : 1;
|
||||
Error += 128 == sizeof(glm::dmat4) ? 0 : 1;
|
||||
Error += glm::mat4().length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4().length() == 4 ? 0 : 1;
|
||||
Error += glm::mat4::length() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4::length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::mat4::length() == 4, "GLM: Failed constexpr");
|
||||
constexpr glm::mat4 A(1.f);
|
||||
constexpr glm::mat4 B(1.f);
|
||||
constexpr glm::bvec4 C = glm::equal(A, B, 0.01f);
|
||||
static_assert(glm::all(C), "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_member_alloc_bug();
|
||||
Error += test_ctr();
|
||||
|
||||
Error += test_operators<glm::mat4, glm::vec4>();
|
||||
Error += test_operators<glm::lowp_mat4, glm::lowp_vec4>();
|
||||
Error += test_operators<glm::mediump_mat4, glm::mediump_vec4>();
|
||||
Error += test_operators<glm::highp_mat4, glm::highp_vec4>();
|
||||
|
||||
Error += test_operators<glm::dmat4, glm::dvec4>();
|
||||
Error += test_operators<glm::lowp_dmat4, glm::lowp_dvec4>();
|
||||
Error += test_operators<glm::mediump_dmat4, glm::mediump_dvec4>();
|
||||
Error += test_operators<glm::highp_dmat4, glm::highp_dvec4>();
|
||||
|
||||
Error += test_inverse<glm::mat4>();
|
||||
Error += test_inverse<glm::lowp_mat4>();
|
||||
Error += test_inverse<glm::mediump_mat4>();
|
||||
Error += test_inverse<glm::highp_mat4>();
|
||||
|
||||
Error += test_inverse<glm::dmat4>();
|
||||
Error += test_inverse<glm::lowp_dmat4>();
|
||||
Error += test_inverse<glm::mediump_dmat4>();
|
||||
Error += test_inverse<glm::highp_dmat4>();
|
||||
|
||||
Error += test_size();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
169
lib/glm/test/core/core_type_vec1.cpp
Normal file
169
lib/glm/test/core/core_type_vec1.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <vector>
|
||||
|
||||
static glm::vec1 g1;
|
||||
static glm::vec1 g2(1);
|
||||
|
||||
int test_vec1_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec1 A(1);
|
||||
glm::ivec1 B(1);
|
||||
{
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
A *= 1;
|
||||
B *= 1;
|
||||
A += 1;
|
||||
B += 1;
|
||||
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec1_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec1>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::vec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dvec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::ivec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::uvec1>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::vec1>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
/*
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::vec1 a{ 0 };
|
||||
std::vector<glm::vec1> v = {
|
||||
{0.f},
|
||||
{4.f},
|
||||
{8.f}};
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 a{ 0 };
|
||||
std::vector<glm::dvec1> v = {
|
||||
{0.0},
|
||||
{4.0},
|
||||
{8.0}};
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
{
|
||||
glm::vec2 A = glm::vec2(2.0f);
|
||||
glm::vec2 B = glm::vec2(2.0f, 3.0f);
|
||||
glm::vec2 C = glm::vec2(2.0f, 3.0);
|
||||
//glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says?
|
||||
glm::vec2 E(glm::dvec2(2.0));
|
||||
glm::vec2 F(glm::ivec2(2));
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec1_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec1) == sizeof(glm::mediump_vec1) ? 0 : 1;
|
||||
Error += 4 == sizeof(glm::mediump_vec1) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec1) == sizeof(glm::highp_dvec1) ? 0 : 1;
|
||||
Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1;
|
||||
Error += glm::vec1().length() == 1 ? 0 : 1;
|
||||
Error += glm::dvec1().length() == 1 ? 0 : 1;
|
||||
Error += glm::vec1::length() == 1 ? 0 : 1;
|
||||
Error += glm::dvec1::length() == 1 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec1_operator_increment()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::ivec1 v0(1);
|
||||
glm::ivec1 v1(v0);
|
||||
glm::ivec1 v2(v0);
|
||||
glm::ivec1 v3 = ++v1;
|
||||
glm::ivec1 v4 = v2++;
|
||||
|
||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
||||
|
||||
int i0(1);
|
||||
int i1(i0);
|
||||
int i2(i0);
|
||||
int i3 = ++i1;
|
||||
int i4 = i2++;
|
||||
|
||||
Error += i0 == i4 ? 0 : 1;
|
||||
Error += i1 == i2 ? 0 : 1;
|
||||
Error += i1 == i3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::vec1 A = glm::vec1(1.0f);
|
||||
//glm::vec1 B = A.x;
|
||||
glm::vec1 C(A.x);
|
||||
|
||||
//Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_vec1_size();
|
||||
Error += test_vec1_ctor();
|
||||
Error += test_vec1_operators();
|
||||
Error += test_vec1_operator_increment();
|
||||
Error += test_swizzle();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
392
lib/glm/test/core/core_type_vec2.cpp
Normal file
392
lib/glm/test/core/core_type_vec2.cpp
Normal file
@@ -0,0 +1,392 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <vector>
|
||||
#if GLM_HAS_TRIVIAL_QUERIES
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
static glm::ivec2 g1;
|
||||
static glm::ivec2 g2(1);
|
||||
static glm::ivec2 g3(1, 1);
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec2 A(1);
|
||||
glm::ivec2 B(1);
|
||||
Error += A != B ? 1 : 0;
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 C = A + 1.0f;
|
||||
A += 1.0f;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(2.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 B(2.0f,-1.0f);
|
||||
glm::vec2 C = A + B;
|
||||
A += B;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(3.0f, 0.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 C = A - 1.0f;
|
||||
A -= 1.0f;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(0.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 B(2.0f,-1.0f);
|
||||
glm::vec2 C = A - B;
|
||||
A -= B;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(-1.0f, 2.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 C = A * 2.0f;
|
||||
A *= 2.0f;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(2.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(2.0f);
|
||||
glm::vec2 B(2.0f);
|
||||
glm::vec2 C = A / B;
|
||||
A /= B;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(1.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
glm::vec2 C = A + B;
|
||||
Error += glm::all(glm::equal(C, glm::vec2(5, 7), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 D = B - A;
|
||||
Error += glm::all(glm::equal(D, glm::vec2(3, 3), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 E = A * B;
|
||||
Error += glm::all(glm::equal(E, glm::vec2(4, 10), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 F = B / A;
|
||||
Error += glm::all(glm::equal(F, glm::vec2(4, 2.5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 G = A + 1.0f;
|
||||
Error += glm::all(glm::equal(G, glm::vec2(2, 3), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 H = B - 1.0f;
|
||||
Error += glm::all(glm::equal(H, glm::vec2(3, 4), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 I = A * 2.0f;
|
||||
Error += glm::all(glm::equal(I, glm::vec2(2, 4), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 J = B / 2.0f;
|
||||
Error += glm::all(glm::equal(J, glm::vec2(2, 2.5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 K = 1.0f + A;
|
||||
Error += glm::all(glm::equal(K, glm::vec2(2, 3), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 L = 1.0f - B;
|
||||
Error += glm::all(glm::equal(L, glm::vec2(-3, -4), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 M = 2.0f * A;
|
||||
Error += glm::all(glm::equal(M, glm::vec2(2, 4), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec2 N = 2.0f / B;
|
||||
Error += glm::all(glm::equal(N, glm::vec2(0.5, 2.0 / 5.0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
A += B;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(5, 7), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
A += 1.0f;
|
||||
Error += glm::all(glm::equal(A, glm::vec2(6, 8), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B(4.0f, 5.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::ivec2(3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1.0f;
|
||||
Error += B == glm::ivec2(2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B(4.0f, 5.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::ivec2(4, 10) ? 0 : 1;
|
||||
|
||||
A *= 2;
|
||||
Error += A == glm::ivec2(8, 20) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B(4.0f, 16.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::ivec2(4, 8) ? 0 : 1;
|
||||
|
||||
B /= 2.0f;
|
||||
Error += B == glm::ivec2(2, 4) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec2 B(2);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::ivec2(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B = -A;
|
||||
Error += B == glm::ivec2(-1.0f, -2.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B = --A;
|
||||
Error += B == glm::ivec2(0.0f, 1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B = A--;
|
||||
Error += B == glm::ivec2(1.0f, 2.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec2(0.0f, 1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B = ++A;
|
||||
Error += B == glm::ivec2(2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec2 A(1.0f, 2.0f);
|
||||
glm::ivec2 B = A++;
|
||||
Error += B == glm::ivec2(1.0f, 2.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec2(2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec2 A(1);
|
||||
glm::ivec2 B(A);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec2>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec2>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::vec2>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dvec2>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::ivec2>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::uvec2>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::vec2>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::vec2 a{ 0, 1 };
|
||||
std::vector<glm::vec2> v = {
|
||||
{0, 1},
|
||||
{4, 5},
|
||||
{8, 9}};
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 a{ 0, 1 };
|
||||
std::vector<glm::dvec2> v = {
|
||||
{0, 1},
|
||||
{4, 5},
|
||||
{8, 9}};
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
glm::vec2 A = glm::vec2(2.0f);
|
||||
glm::vec2 B = glm::vec2(2.0f, 3.0f);
|
||||
glm::vec2 C = glm::vec2(2.0f, 3.0);
|
||||
//glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says?
|
||||
glm::vec2 E(glm::dvec2(2.0));
|
||||
glm::vec2 F(glm::ivec2(2));
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const R(1.0f);
|
||||
glm::vec1 const S(2.0f);
|
||||
glm::vec2 const O(1.0f, 2.0f);
|
||||
|
||||
glm::vec2 const A(R);
|
||||
glm::vec2 const B(1.0f);
|
||||
Error += glm::all(glm::equal(A, B, 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const C(R, S);
|
||||
Error += glm::all(glm::equal(C, O, 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const D(R, 2.0f);
|
||||
Error += glm::all(glm::equal(D, O, 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const E(1.0f, S);
|
||||
Error += glm::all(glm::equal(E, O, 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const R(1.0f);
|
||||
glm::dvec1 const S(2.0);
|
||||
glm::vec2 const O(1.0, 2.0);
|
||||
|
||||
glm::vec2 const A(R);
|
||||
glm::vec2 const B(1.0);
|
||||
Error += glm::all(glm::equal(A, B, 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const C(R, S);
|
||||
Error += glm::all(glm::equal(C, O, 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const D(R, 2.0);
|
||||
Error += glm::all(glm::equal(D, O, 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::vec2 const E(1.0, S);
|
||||
Error += glm::all(glm::equal(E, O, 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec2) == sizeof(glm::mediump_vec2) ? 0 : 1;
|
||||
Error += 8 == sizeof(glm::mediump_vec2) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1;
|
||||
Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1;
|
||||
Error += glm::vec2().length() == 2 ? 0 : 1;
|
||||
Error += glm::dvec2().length() == 2 ? 0 : 1;
|
||||
Error += glm::vec2::length() == 2 ? 0 : 1;
|
||||
Error += glm::dvec2::length() == 2 ? 0 : 1;
|
||||
|
||||
GLM_CONSTEXPR std::size_t Length = glm::vec2::length();
|
||||
Error += Length == 2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_operator_increment()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec2 v0(1);
|
||||
glm::ivec2 v1(v0);
|
||||
glm::ivec2 v2(v0);
|
||||
glm::ivec2 v3 = ++v1;
|
||||
glm::ivec2 v4 = v2++;
|
||||
|
||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
||||
|
||||
int i0(1);
|
||||
int i1(i0);
|
||||
int i2(i0);
|
||||
int i3 = ++i1;
|
||||
int i4 = i2++;
|
||||
|
||||
Error += i0 == i4 ? 0 : 1;
|
||||
Error += i1 == i2 ? 0 : 1;
|
||||
Error += i1 == i3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::vec2::length() == 2, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2(1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec2(1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::vec2 A = glm::vec2(1.0f, 2.0f);
|
||||
glm::vec2 B = A.xy;
|
||||
glm::vec2 C(A.xy);
|
||||
glm::vec2 D(A.xy());
|
||||
|
||||
Error += glm::all(glm::equal(A, B, 0.0001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, 0.0001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D, 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::vec2 A = glm::vec2(1.0f, 2.0f);
|
||||
glm::vec2 B = A.xy();
|
||||
glm::vec2 C(A.xy());
|
||||
|
||||
Error += glm::all(glm::equal(A, B, 0.0001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_size();
|
||||
Error += test_ctor();
|
||||
Error += test_operators();
|
||||
Error += test_operator_increment();
|
||||
Error += test_swizzle();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
628
lib/glm/test/core/core_type_vec3.cpp
Normal file
628
lib/glm/test/core/core_type_vec3.cpp
Normal file
@@ -0,0 +1,628 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/geometric.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <vector>
|
||||
|
||||
static glm::vec3 g1;
|
||||
static glm::vec3 g2(1);
|
||||
static glm::vec3 g3(1, 1, 1);
|
||||
|
||||
int test_vec3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec3>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec3>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::vec3>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dvec3>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::ivec3>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::uvec3>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::vec3>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
# if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::vec3 a{ 0, 1, 2 };
|
||||
std::vector<glm::vec3> v = {
|
||||
{0, 1, 2},
|
||||
{4, 5, 6},
|
||||
{8, 9, 0}};
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec3 a{ 0, 1, 2 };
|
||||
std::vector<glm::dvec3> v = {
|
||||
{0, 1, 2},
|
||||
{4, 5, 6},
|
||||
{8, 9, 0}};
|
||||
}
|
||||
# endif
|
||||
|
||||
{
|
||||
glm::ivec3 A(1);
|
||||
glm::ivec3 B(1, 1, 1);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::ivec3> Tests;
|
||||
Tests.push_back(glm::ivec3(glm::ivec2(1, 2), 3));
|
||||
Tests.push_back(glm::ivec3(1, glm::ivec2(2, 3)));
|
||||
Tests.push_back(glm::ivec3(1, 2, 3));
|
||||
Tests.push_back(glm::ivec3(glm::ivec4(1, 2, 3, 4)));
|
||||
|
||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
||||
Error += Tests[i] == glm::ivec3(1, 2, 3) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const R(1.0f);
|
||||
glm::vec1 const S(2.0f);
|
||||
glm::vec1 const T(3.0f);
|
||||
glm::vec3 const O(1.0f, 2.0f, 3.0f);
|
||||
|
||||
glm::vec3 const A(R);
|
||||
glm::vec3 const B(1.0f);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const C(R, S, T);
|
||||
Error += glm::all(glm::equal(C, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const D(R, 2.0f, 3.0f);
|
||||
Error += glm::all(glm::equal(D, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const E(1.0f, S, 3.0f);
|
||||
Error += glm::all(glm::equal(E, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const F(1.0f, S, T);
|
||||
Error += glm::all(glm::equal(F, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const G(R, 2.0f, T);
|
||||
Error += glm::all(glm::equal(G, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const H(R, S, 3.0f);
|
||||
Error += glm::all(glm::equal(H, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const R(1.0);
|
||||
glm::dvec1 const S(2.0);
|
||||
glm::vec1 const T(3.0);
|
||||
glm::vec3 const O(1.0f, 2.0f, 3.0f);
|
||||
|
||||
glm::vec3 const A(R);
|
||||
glm::vec3 const B(1.0);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const C(R, S, T);
|
||||
Error += glm::all(glm::equal(C, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const D(R, 2.0, 3.0);
|
||||
Error += glm::all(glm::equal(D, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const E(1.0f, S, 3.0);
|
||||
Error += glm::all(glm::equal(E, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const F(1.0, S, T);
|
||||
Error += glm::all(glm::equal(F, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const G(R, 2.0, T);
|
||||
Error += glm::all(glm::equal(G, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const H(R, S, 3.0);
|
||||
Error += glm::all(glm::equal(H, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
float foo()
|
||||
{
|
||||
glm::vec3 bar = glm::vec3(0.0f, 1.0f, 1.0f);
|
||||
|
||||
return glm::length(bar);
|
||||
}
|
||||
|
||||
static int test_bvec3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::bvec3 const A(true);
|
||||
glm::bvec3 const B(true);
|
||||
glm::bvec3 const C(false);
|
||||
glm::bvec3 const D = A && B;
|
||||
glm::bvec3 const E = A && C;
|
||||
glm::bvec3 const F = A || C;
|
||||
|
||||
Error += D == glm::bvec3(true) ? 0 : 1;
|
||||
Error += E == glm::bvec3(false) ? 0 : 1;
|
||||
Error += F == glm::bvec3(true) ? 0 : 1;
|
||||
|
||||
bool const G = A == C;
|
||||
bool const H = A != C;
|
||||
Error += !G ? 0 : 1;
|
||||
Error += H ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec3_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec3 A(1);
|
||||
glm::ivec3 B(1);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 const A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 const B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
glm::vec3 const C = A + B;
|
||||
Error += glm::all(glm::equal(C, glm::vec3(5, 7, 9), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const D = B - A;
|
||||
Error += glm::all(glm::equal(D, glm::vec3(3, 3, 3), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const E = A * B;
|
||||
Error += glm::all(glm::equal(E, glm::vec3(4, 10, 18), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const F = B / A;
|
||||
Error += glm::all(glm::equal(F, glm::vec3(4, 2.5, 2), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const G = A + 1.0f;
|
||||
Error += glm::all(glm::equal(G, glm::vec3(2, 3, 4), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const H = B - 1.0f;
|
||||
Error += glm::all(glm::equal(H, glm::vec3(3, 4, 5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const I = A * 2.0f;
|
||||
Error += glm::all(glm::equal(I, glm::vec3(2, 4, 6), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const J = B / 2.0f;
|
||||
Error += glm::all(glm::equal(J, glm::vec3(2, 2.5, 3), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const K = 1.0f + A;
|
||||
Error += glm::all(glm::equal(K, glm::vec3(2, 3, 4), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const L = 1.0f - B;
|
||||
Error += glm::all(glm::equal(L, glm::vec3(-3, -4, -5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const M = 2.0f * A;
|
||||
Error += glm::all(glm::equal(M, glm::vec3(2, 4, 6), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec3 const N = 2.0f / B;
|
||||
Error += glm::all(glm::equal(N, glm::vec3(0.5, 2.0 / 5.0, 2.0 / 6.0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
A += B;
|
||||
Error += A == glm::ivec3(5, 7, 9) ? 0 : 1;
|
||||
|
||||
A += 1;
|
||||
Error += A == glm::ivec3(6, 8, 10) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::ivec3(3, 3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1;
|
||||
Error += B == glm::ivec3(2, 2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::ivec3(4, 10, 18) ? 0 : 1;
|
||||
|
||||
A *= 2;
|
||||
Error += A == glm::ivec3(8, 20, 36) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B(4.0f, 4.0f, 6.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::ivec3(4, 2, 2) ? 0 : 1;
|
||||
|
||||
B /= 2;
|
||||
Error += B == glm::ivec3(2, 1, 1) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec3 B(2);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::ivec3(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B = -A;
|
||||
Error += B == glm::ivec3(-1.0f, -2.0f, -3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B = --A;
|
||||
Error += B == glm::ivec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B = A--;
|
||||
Error += B == glm::ivec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B = ++A;
|
||||
Error += B == glm::ivec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::ivec3 B = A++;
|
||||
Error += B == glm::ivec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec3) == sizeof(glm::lowp_vec3) ? 0 : 1;
|
||||
Error += sizeof(glm::vec3) == sizeof(glm::mediump_vec3) ? 0 : 1;
|
||||
Error += sizeof(glm::vec3) == sizeof(glm::highp_vec3) ? 0 : 1;
|
||||
Error += 12 == sizeof(glm::mediump_vec3) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec3) == sizeof(glm::lowp_dvec3) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec3) == sizeof(glm::mediump_dvec3) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1;
|
||||
Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1;
|
||||
Error += glm::vec3().length() == 3 ? 0 : 1;
|
||||
Error += glm::dvec3().length() == 3 ? 0 : 1;
|
||||
Error += glm::vec3::length() == 3 ? 0 : 1;
|
||||
Error += glm::dvec3::length() == 3 ? 0 : 1;
|
||||
|
||||
GLM_CONSTEXPR std::size_t Length = glm::vec3::length();
|
||||
Error += Length == 3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle3_2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec3 v(1, 2, 3);
|
||||
glm::ivec2 u;
|
||||
|
||||
// Can not assign a vec3 swizzle to a vec2
|
||||
//u = v.xyz; //Illegal
|
||||
//u = v.rgb; //Illegal
|
||||
//u = v.stp; //Illegal
|
||||
|
||||
u = v.xx; Error += (u.x == 1 && u.y == 1) ? 0 : 1;
|
||||
u = v.xy; Error += (u.x == 1 && u.y == 2) ? 0 : 1;
|
||||
u = v.xz; Error += (u.x == 1 && u.y == 3) ? 0 : 1;
|
||||
u = v.yx; Error += (u.x == 2 && u.y == 1) ? 0 : 1;
|
||||
u = v.yy; Error += (u.x == 2 && u.y == 2) ? 0 : 1;
|
||||
u = v.yz; Error += (u.x == 2 && u.y == 3) ? 0 : 1;
|
||||
u = v.zx; Error += (u.x == 3 && u.y == 1) ? 0 : 1;
|
||||
u = v.zy; Error += (u.x == 3 && u.y == 2) ? 0 : 1;
|
||||
u = v.zz; Error += (u.x == 3 && u.y == 3) ? 0 : 1;
|
||||
|
||||
u = v.rr; Error += (u.r == 1 && u.g == 1) ? 0 : 1;
|
||||
u = v.rg; Error += (u.r == 1 && u.g == 2) ? 0 : 1;
|
||||
u = v.rb; Error += (u.r == 1 && u.g == 3) ? 0 : 1;
|
||||
u = v.gr; Error += (u.r == 2 && u.g == 1) ? 0 : 1;
|
||||
u = v.gg; Error += (u.r == 2 && u.g == 2) ? 0 : 1;
|
||||
u = v.gb; Error += (u.r == 2 && u.g == 3) ? 0 : 1;
|
||||
u = v.br; Error += (u.r == 3 && u.g == 1) ? 0 : 1;
|
||||
u = v.bg; Error += (u.r == 3 && u.g == 2) ? 0 : 1;
|
||||
u = v.bb; Error += (u.r == 3 && u.g == 3) ? 0 : 1;
|
||||
|
||||
u = v.ss; Error += (u.s == 1 && u.t == 1) ? 0 : 1;
|
||||
u = v.st; Error += (u.s == 1 && u.t == 2) ? 0 : 1;
|
||||
u = v.sp; Error += (u.s == 1 && u.t == 3) ? 0 : 1;
|
||||
u = v.ts; Error += (u.s == 2 && u.t == 1) ? 0 : 1;
|
||||
u = v.tt; Error += (u.s == 2 && u.t == 2) ? 0 : 1;
|
||||
u = v.tp; Error += (u.s == 2 && u.t == 3) ? 0 : 1;
|
||||
u = v.ps; Error += (u.s == 3 && u.t == 1) ? 0 : 1;
|
||||
u = v.pt; Error += (u.s == 3 && u.t == 2) ? 0 : 1;
|
||||
u = v.pp; Error += (u.s == 3 && u.t == 3) ? 0 : 1;
|
||||
// Mixed member aliases are not valid
|
||||
//u = v.rx; //Illegal
|
||||
//u = v.sy; //Illegal
|
||||
|
||||
u = glm::ivec2(1, 2);
|
||||
v = glm::ivec3(1, 2, 3);
|
||||
//v.xx = u; //Illegal
|
||||
v.xy = u; Error += (v.x == 1 && v.y == 2 && v.z == 3) ? 0 : 1;
|
||||
v.xz = u; Error += (v.x == 1 && v.y == 2 && v.z == 2) ? 0 : 1;
|
||||
v.yx = u; Error += (v.x == 2 && v.y == 1 && v.z == 2) ? 0 : 1;
|
||||
//v.yy = u; //Illegal
|
||||
v.yz = u; Error += (v.x == 2 && v.y == 1 && v.z == 2) ? 0 : 1;
|
||||
v.zx = u; Error += (v.x == 2 && v.y == 1 && v.z == 1) ? 0 : 1;
|
||||
v.zy = u; Error += (v.x == 2 && v.y == 2 && v.z == 1) ? 0 : 1;
|
||||
//v.zz = u; //Illegal
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle3_3()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec3 v(1, 2, 3);
|
||||
glm::ivec3 u;
|
||||
|
||||
u = v; Error += (u.x == 1 && u.y == 2 && u.z == 3) ? 0 : 1;
|
||||
|
||||
u = v.xyz; Error += (u.x == 1 && u.y == 2 && u.z == 3) ? 0 : 1;
|
||||
u = v.zyx; Error += (u.x == 3 && u.y == 2 && u.z == 1) ? 0 : 1;
|
||||
u.zyx = v; Error += (u.x == 3 && u.y == 2 && u.z == 1) ? 0 : 1;
|
||||
|
||||
u = v.rgb; Error += (u.x == 1 && u.y == 2 && u.z == 3) ? 0 : 1;
|
||||
u = v.bgr; Error += (u.x == 3 && u.y == 2 && u.z == 1) ? 0 : 1;
|
||||
u.bgr = v; Error += (u.x == 3 && u.y == 2 && u.z == 1) ? 0 : 1;
|
||||
|
||||
u = v.stp; Error += (u.x == 1 && u.y == 2 && u.z == 3) ? 0 : 1;
|
||||
u = v.pts; Error += (u.x == 3 && u.y == 2 && u.z == 1) ? 0 : 1;
|
||||
u.pts = v; Error += (u.x == 3 && u.y == 2 && u.z == 1) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec3 const u = glm::ivec3(1, 2, 3);
|
||||
glm::ivec3 const v = glm::ivec3(10, 20, 30);
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec3 q;
|
||||
|
||||
// Swizzle, swizzle binary operators
|
||||
q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1;
|
||||
q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1;
|
||||
q = (u.xxx * v.xxx); Error += (q == glm::ivec3(u.x * v.x)) ? 0 : 1;
|
||||
q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1;
|
||||
|
||||
// vec, swizzle binary operators
|
||||
q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1;
|
||||
q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1;
|
||||
q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1;
|
||||
q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1;
|
||||
|
||||
// swizzle,vec binary operators
|
||||
q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1;
|
||||
q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1;
|
||||
q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1;
|
||||
q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1;
|
||||
q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG
|
||||
|
||||
// Compile errors
|
||||
//q = (u.yz * v.xyz);
|
||||
//q = (u * v.xy);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_functions()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
// NOTE: template functions cannot pick up the implicit conversion from
|
||||
// a swizzle to the unswizzled type, therefore the operator() must be
|
||||
// used. E.g.:
|
||||
//
|
||||
// glm::dot(u.xy, v.xy); <--- Compile error
|
||||
// glm::dot(u.xy(), v.xy()); <--- Compiles correctly
|
||||
|
||||
float r;
|
||||
|
||||
// vec2
|
||||
glm::vec2 a(1, 2);
|
||||
glm::vec2 b(10, 20);
|
||||
r = glm::dot(a, b); Error += (int(r) == 50) ? 0 : 1;
|
||||
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.xy())); Error += (int(r) == 50) ? 0 : 1;
|
||||
r = glm::dot(glm::vec2(a.xy()), glm::vec2(b.yy())); Error += (int(r) == 60) ? 0 : 1;
|
||||
|
||||
// vec3
|
||||
glm::vec3 u = glm::vec3(1, 2, 3);
|
||||
glm::vec3 v = glm::vec3(10, 20, 30);
|
||||
r = glm::dot(u, v); Error += (int(r) == 140) ? 0 : 1;
|
||||
r = glm::dot(u.xyz(), v.zyz()); Error += (int(r) == 160) ? 0 : 1;
|
||||
r = glm::dot(u, v.zyx()); Error += (int(r) == 100) ? 0 : 1;
|
||||
r = glm::dot(u.xyz(), v); Error += (int(r) == 140) ? 0 : 1;
|
||||
r = glm::dot(u.xy(), v.xy()); Error += (int(r) == 50) ? 0 : 1;
|
||||
|
||||
// vec4
|
||||
glm::vec4 s = glm::vec4(1, 2, 3, 4);
|
||||
glm::vec4 t = glm::vec4(10, 20, 30, 40);
|
||||
r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1;
|
||||
r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1;
|
||||
r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::vec3 const A(1, 2, 3);
|
||||
glm::vec3 B(A.xy, 3);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
glm::ivec3 const B(1, A.yz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 const A(1, 2, 3);
|
||||
glm::ivec3 const B(A.xyz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_operator_increment()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec3 v0(1);
|
||||
glm::ivec3 v1(v0);
|
||||
glm::ivec3 v2(v0);
|
||||
glm::ivec3 v3 = ++v1;
|
||||
glm::ivec3 v4 = v2++;
|
||||
|
||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
||||
|
||||
int i0(1);
|
||||
int i1(i0);
|
||||
int i2(i0);
|
||||
int i3 = ++i1;
|
||||
int i4 = i2++;
|
||||
|
||||
Error += i0 == i4 ? 0 : 1;
|
||||
Error += i1 == i2 ? 0 : 1;
|
||||
Error += i1 == i3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A.xyz;
|
||||
glm::vec3 C(A.xyz);
|
||||
glm::vec3 D(A.xyz());
|
||||
glm::vec3 E(A.x, A.yz);
|
||||
glm::vec3 F(A.x, A.yz());
|
||||
glm::vec3 G(A.xy, A.z);
|
||||
glm::vec3 H(A.xy(), A.z);
|
||||
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::vec3 A = glm::vec3(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A.xyz();
|
||||
glm::vec3 C(A.xyz());
|
||||
glm::vec3 D(A.xyz());
|
||||
glm::vec3 E(A.x, A.yz());
|
||||
glm::vec3 F(A.x, A.yz());
|
||||
glm::vec3 G(A.xy(), A.z);
|
||||
glm::vec3 H(A.xy(), A.z);
|
||||
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_vec3_ctor();
|
||||
Error += test_bvec3_ctor();
|
||||
Error += test_vec3_operators();
|
||||
Error += test_vec3_size();
|
||||
Error += test_operator_increment();
|
||||
Error += test_constexpr();
|
||||
|
||||
Error += test_swizzle();
|
||||
Error += test_vec3_swizzle3_2();
|
||||
Error += test_vec3_swizzle3_3();
|
||||
Error += test_vec3_swizzle_partial();
|
||||
Error += test_vec3_swizzle_operators();
|
||||
Error += test_vec3_swizzle_functions();
|
||||
|
||||
return Error;
|
||||
}
|
||||
850
lib/glm/test/core/core_type_vec4.cpp
Normal file
850
lib/glm/test/core/core_type_vec4.cpp
Normal file
@@ -0,0 +1,850 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
static glm::vec4 g1;
|
||||
static glm::vec4 g2(1);
|
||||
static glm::vec4 g3(1, 1, 1, 1);
|
||||
|
||||
template <int Value>
|
||||
struct mask
|
||||
{
|
||||
enum{value = Value};
|
||||
};
|
||||
|
||||
enum comp
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
W
|
||||
};
|
||||
|
||||
//template<comp X, comp Y, comp Z, comp W>
|
||||
//__m128 swizzle(glm::vec4 const& v)
|
||||
//{
|
||||
// __m128 Src = _mm_set_ps(v.w, v.z, v.y, v.x);
|
||||
// return _mm_shuffle_ps(Src, Src, mask<(int(W) << 6) | (int(Z) << 4) | (int(Y) << 2) | (int(X) << 0)>::value);
|
||||
//}
|
||||
|
||||
static int test_vec4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec4 A(1, 2, 3, 4);
|
||||
glm::ivec4 B(A);
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
}
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec4>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::vec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dvec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::ivec4>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::uvec4>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::vec4>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
#if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::vec4 a{ 0, 1, 2, 3 };
|
||||
std::vector<glm::vec4> v = {
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 0, 1}};
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec4 a{ 0, 1, 2, 3 };
|
||||
std::vector<glm::dvec4> v = {
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 0, 1}};
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1);
|
||||
glm::ivec4 const B(1, 1, 1, 1);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::ivec4> Tests;
|
||||
Tests.push_back(glm::ivec4(glm::ivec2(1, 2), 3, 4));
|
||||
Tests.push_back(glm::ivec4(1, glm::ivec2(2, 3), 4));
|
||||
Tests.push_back(glm::ivec4(1, 2, glm::ivec2(3, 4)));
|
||||
Tests.push_back(glm::ivec4(glm::ivec3(1, 2, 3), 4));
|
||||
Tests.push_back(glm::ivec4(1, glm::ivec3(2, 3, 4)));
|
||||
Tests.push_back(glm::ivec4(glm::ivec2(1, 2), glm::ivec2(3, 4)));
|
||||
Tests.push_back(glm::ivec4(1, 2, 3, 4));
|
||||
Tests.push_back(glm::ivec4(glm::ivec4(1, 2, 3, 4)));
|
||||
|
||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
||||
Error += Tests[i] == glm::ivec4(1, 2, 3, 4) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const R(1.0f);
|
||||
glm::vec1 const S(2.0f);
|
||||
glm::vec1 const T(3.0f);
|
||||
glm::vec1 const U(4.0f);
|
||||
glm::vec4 const O(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
|
||||
glm::vec4 const A(R);
|
||||
glm::vec4 const B(1.0f);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const C(R, S, T, U);
|
||||
Error += glm::all(glm::equal(C, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const D(R, 2.0f, 3.0f, 4.0f);
|
||||
Error += glm::all(glm::equal(D, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const E(1.0f, S, 3.0f, 4.0f);
|
||||
Error += glm::all(glm::equal(E, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const F(R, S, 3.0f, 4.0f);
|
||||
Error += glm::all(glm::equal(F, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const G(1.0f, 2.0f, T, 4.0f);
|
||||
Error += glm::all(glm::equal(G, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const H(R, 2.0f, T, 4.0f);
|
||||
Error += glm::all(glm::equal(H, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const I(1.0f, S, T, 4.0f);
|
||||
Error += glm::all(glm::equal(I, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const J(R, S, T, 4.0f);
|
||||
Error += glm::all(glm::equal(J, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const K(R, 2.0f, 3.0f, U);
|
||||
Error += glm::all(glm::equal(K, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const L(1.0f, S, 3.0f, U);
|
||||
Error += glm::all(glm::equal(L, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const M(R, S, 3.0f, U);
|
||||
Error += glm::all(glm::equal(M, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const N(1.0f, 2.0f, T, U);
|
||||
Error += glm::all(glm::equal(N, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const P(R, 2.0f, T, U);
|
||||
Error += glm::all(glm::equal(P, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const Q(1.0f, S, T, U);
|
||||
Error += glm::all(glm::equal(Q, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const V(R, S, T, U);
|
||||
Error += glm::all(glm::equal(V, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const R(1.0f);
|
||||
glm::dvec1 const S(2.0);
|
||||
glm::vec1 const T(3.0);
|
||||
glm::dvec1 const U(4.0);
|
||||
glm::vec4 const O(1.0f, 2.0, 3.0f, 4.0);
|
||||
|
||||
glm::vec4 const A(R);
|
||||
glm::vec4 const B(1.0);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const C(R, S, T, U);
|
||||
Error += glm::all(glm::equal(C, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const D(R, 2.0f, 3.0, 4.0f);
|
||||
Error += glm::all(glm::equal(D, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const E(1.0, S, 3.0f, 4.0);
|
||||
Error += glm::all(glm::equal(E, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const F(R, S, 3.0, 4.0f);
|
||||
Error += glm::all(glm::equal(F, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const G(1.0f, 2.0, T, 4.0);
|
||||
Error += glm::all(glm::equal(G, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const H(R, 2.0, T, 4.0);
|
||||
Error += glm::all(glm::equal(H, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const I(1.0, S, T, 4.0f);
|
||||
Error += glm::all(glm::equal(I, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const J(R, S, T, 4.0f);
|
||||
Error += glm::all(glm::equal(J, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const K(R, 2.0f, 3.0, U);
|
||||
Error += glm::all(glm::equal(K, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const L(1.0f, S, 3.0, U);
|
||||
Error += glm::all(glm::equal(L, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const M(R, S, 3.0, U);
|
||||
Error += glm::all(glm::equal(M, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const N(1.0f, 2.0, T, U);
|
||||
Error += glm::all(glm::equal(N, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const P(R, 2.0, T, U);
|
||||
Error += glm::all(glm::equal(P, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const Q(1.0f, S, T, U);
|
||||
Error += glm::all(glm::equal(Q, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const V(R, S, T, U);
|
||||
Error += glm::all(glm::equal(V, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const v1_0(1.0f);
|
||||
glm::vec1 const v1_1(2.0f);
|
||||
glm::vec1 const v1_2(3.0f);
|
||||
glm::vec1 const v1_3(4.0f);
|
||||
|
||||
glm::vec2 const v2_0(1.0f, 2.0f);
|
||||
glm::vec2 const v2_1(2.0f, 3.0f);
|
||||
glm::vec2 const v2_2(3.0f, 4.0f);
|
||||
|
||||
glm::vec3 const v3_0(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 const v3_1(2.0f, 3.0f, 4.0f);
|
||||
|
||||
glm::vec4 const O(1.0f, 2.0, 3.0f, 4.0);
|
||||
|
||||
glm::vec4 const A(v1_0, v1_1, v2_2);
|
||||
Error += glm::all(glm::equal(A, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const B(1.0f, 2.0f, v2_2);
|
||||
Error += glm::all(glm::equal(B, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const C(v1_0, 2.0f, v2_2);
|
||||
Error += glm::all(glm::equal(C, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const D(1.0f, v1_1, v2_2);
|
||||
Error += glm::all(glm::equal(D, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const E(v2_0, v1_2, v1_3);
|
||||
Error += glm::all(glm::equal(E, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const F(v2_0, 3.0, v1_3);
|
||||
Error += glm::all(glm::equal(F, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const G(v2_0, v1_2, 4.0);
|
||||
Error += glm::all(glm::equal(G, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const H(v2_0, 3.0f, 4.0);
|
||||
Error += glm::all(glm::equal(H, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec1 const v1_0(1.0f);
|
||||
glm::vec1 const v1_1(2.0f);
|
||||
glm::vec1 const v1_2(3.0f);
|
||||
glm::vec1 const v1_3(4.0f);
|
||||
|
||||
glm::vec2 const v2(2.0f, 3.0f);
|
||||
|
||||
glm::vec4 const O(1.0f, 2.0, 3.0f, 4.0);
|
||||
|
||||
glm::vec4 const A(v1_0, v2, v1_3);
|
||||
Error += glm::all(glm::equal(A, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const B(v1_0, v2, 4.0);
|
||||
Error += glm::all(glm::equal(B, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const C(1.0, v2, v1_3);
|
||||
Error += glm::all(glm::equal(C, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const D(1.0f, v2, 4.0);
|
||||
Error += glm::all(glm::equal(D, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const E(1.0, v2, 4.0f);
|
||||
Error += glm::all(glm::equal(E, O, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_bvec4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::bvec4 const A(true);
|
||||
glm::bvec4 const B(true);
|
||||
glm::bvec4 const C(false);
|
||||
glm::bvec4 const D = A && B;
|
||||
glm::bvec4 const E = A && C;
|
||||
glm::bvec4 const F = A || C;
|
||||
|
||||
Error += D == glm::bvec4(true) ? 0 : 1;
|
||||
Error += E == glm::bvec4(false) ? 0 : 1;
|
||||
Error += F == glm::bvec4(true) ? 0 : 1;
|
||||
|
||||
bool const G = A == C;
|
||||
bool const H = A != C;
|
||||
Error += !G ? 0 : 1;
|
||||
Error += H ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::ivec4 A(1);
|
||||
glm::ivec4 B(1);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 const A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 const B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
glm::vec4 const C = A + B;
|
||||
Error += glm::all(glm::equal(C, glm::vec4(5, 7, 9, 11), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const D = B - A;
|
||||
Error += glm::all(glm::equal(D, glm::vec4(3, 3, 3, 3), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const E = A * B;
|
||||
Error += glm::all(glm::equal(E, glm::vec4(4, 10, 18, 28), glm::epsilon<float>()) )? 0 : 1;
|
||||
|
||||
glm::vec4 const F = B / A;
|
||||
Error += glm::all(glm::equal(F, glm::vec4(4, 2.5, 2, 7.0f / 4.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const G = A + 1.0f;
|
||||
Error += glm::all(glm::equal(G, glm::vec4(2, 3, 4, 5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const H = B - 1.0f;
|
||||
Error += glm::all(glm::equal(H, glm::vec4(3, 4, 5, 6), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const I = A * 2.0f;
|
||||
Error += glm::all(glm::equal(I, glm::vec4(2, 4, 6, 8), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const J = B / 2.0f;
|
||||
Error += glm::all(glm::equal(J, glm::vec4(2, 2.5, 3, 3.5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const K = 1.0f + A;
|
||||
Error += glm::all(glm::equal(K, glm::vec4(2, 3, 4, 5), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const L = 1.0f - B;
|
||||
Error += glm::all(glm::equal(L, glm::vec4(-3, -4, -5, -6), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const M = 2.0f * A;
|
||||
Error += glm::all(glm::equal(M, glm::vec4(2, 4, 6, 8), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::vec4 const N = 2.0f / B;
|
||||
Error += glm::all(glm::equal(N, glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0), glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
A += B;
|
||||
Error += A == glm::ivec4(5, 7, 9, 11) ? 0 : 1;
|
||||
|
||||
A += 1;
|
||||
Error += A == glm::ivec4(6, 8, 10, 12) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::ivec4(3, 3, 3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1;
|
||||
Error += B == glm::ivec4(2, 2, 2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::ivec4(4, 10, 18, 28) ? 0 : 1;
|
||||
|
||||
A *= 2;
|
||||
Error += A == glm::ivec4(8, 20, 36, 56) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 2.0f, 4.0f);
|
||||
glm::ivec4 B(4.0f, 4.0f, 8.0f, 8.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::ivec4(4, 2, 4, 2) ? 0 : 1;
|
||||
|
||||
B /= 2;
|
||||
Error += B == glm::ivec4(2, 1, 2, 1) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::ivec4 B(2);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::ivec4(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = -A;
|
||||
Error += B == glm::ivec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = --A;
|
||||
Error += B == glm::ivec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A--;
|
||||
Error += B == glm::ivec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = ++A;
|
||||
Error += B == glm::ivec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A++;
|
||||
Error += B == glm::ivec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
Error += A == glm::ivec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_equal()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::uvec4 const A(1, 2, 3, 4);
|
||||
glm::uvec4 const B(1, 2, 3, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
Error += A != B ? 1 : 0;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 const A(1, 2, 3, 4);
|
||||
glm::ivec4 const B(1, 2, 3, 4);
|
||||
Error += A == B ? 0 : 1;
|
||||
Error += A != B ? 1 : 0;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::lowp_vec4) ? 0 : 1;
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::mediump_vec4) ? 0 : 1;
|
||||
Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1;
|
||||
Error += 16 == sizeof(glm::mediump_vec4) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::lowp_dvec4) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::mediump_dvec4) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1;
|
||||
Error += 32 == sizeof(glm::highp_dvec4) ? 0 : 1;
|
||||
Error += glm::vec4().length() == 4 ? 0 : 1;
|
||||
Error += glm::dvec4().length() == 4 ? 0 : 1;
|
||||
Error += glm::vec4::length() == 4 ? 0 : 1;
|
||||
Error += glm::dvec4::length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 const A(1, 2, 3, 4);
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::vec4 B(A.xy, A.zw);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(A.xy, 3.0f, 4.0f);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(1.0f, A.yz, 4.0f);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(1.0f, 2.0f, A.zw);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 B(A.xyz, 4.0f);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(1.0f, A.yzw);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
{
|
||||
glm::ivec4 A = glm::ivec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::ivec4 B = A.xyzw;
|
||||
glm::ivec4 C(A.xyzw);
|
||||
glm::ivec4 D(A.xyzw());
|
||||
glm::ivec4 E(A.x, A.yzw);
|
||||
glm::ivec4 F(A.x, A.yzw());
|
||||
glm::ivec4 G(A.xyz, A.w);
|
||||
glm::ivec4 H(A.xyz(), A.w);
|
||||
glm::ivec4 I(A.xy, A.zw);
|
||||
glm::ivec4 J(A.xy(), A.zw());
|
||||
glm::ivec4 K(A.x, A.y, A.zw);
|
||||
glm::ivec4 L(A.x, A.yz, A.w);
|
||||
glm::ivec4 M(A.xy, A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
||||
|
||||
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
{
|
||||
glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A.xyzw();
|
||||
glm::vec4 C(A.xyzw());
|
||||
glm::vec4 D(A.xyzw());
|
||||
glm::vec4 E(A.x, A.yzw());
|
||||
glm::vec4 F(A.x, A.yzw());
|
||||
glm::vec4 G(A.xyz(), A.w);
|
||||
glm::vec4 H(A.xyz(), A.w);
|
||||
glm::vec4 I(A.xy(), A.zw());
|
||||
glm::vec4 J(A.xy(), A.zw());
|
||||
glm::vec4 K(A.x, A.y, A.zw());
|
||||
glm::vec4 L(A.x, A.yz(), A.w);
|
||||
glm::vec4 M(A.xy(), A.z, A.w);
|
||||
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, F, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, G, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, H, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, I, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, J, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, K, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, L, glm::epsilon<float>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, M, glm::epsilon<float>())) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_operator_increment()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec4 v0(1);
|
||||
glm::ivec4 v1(v0);
|
||||
glm::ivec4 v2(v0);
|
||||
glm::ivec4 v3 = ++v1;
|
||||
glm::ivec4 v4 = v2++;
|
||||
|
||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
||||
|
||||
int i0(1);
|
||||
int i1(i0);
|
||||
int i2(i0);
|
||||
int i3 = ++i1;
|
||||
int i4 = i2++;
|
||||
|
||||
Error += i0 == i4 ? 0 : 1;
|
||||
Error += i1 == i2 ? 0 : 1;
|
||||
Error += i1 == i3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
struct AoS
|
||||
{
|
||||
glm::vec4 A;
|
||||
glm::vec3 B;
|
||||
glm::vec3 C;
|
||||
glm::vec2 D;
|
||||
};
|
||||
|
||||
static int test_perf_AoS(std::size_t Size)
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::vector<AoS> In;
|
||||
std::vector<AoS> Out;
|
||||
In.resize(Size);
|
||||
Out.resize(Size);
|
||||
|
||||
std::clock_t StartTime = std::clock();
|
||||
|
||||
for(std::size_t i = 0; i < In.size(); ++i)
|
||||
Out[i] = In[i];
|
||||
|
||||
std::clock_t EndTime = std::clock();
|
||||
|
||||
std::printf("AoS: %d\n", static_cast<int>(EndTime - StartTime));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_perf_SoA(std::size_t Size)
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::vector<glm::vec4> InA;
|
||||
std::vector<glm::vec3> InB;
|
||||
std::vector<glm::vec3> InC;
|
||||
std::vector<glm::vec2> InD;
|
||||
std::vector<glm::vec4> OutA;
|
||||
std::vector<glm::vec3> OutB;
|
||||
std::vector<glm::vec3> OutC;
|
||||
std::vector<glm::vec2> OutD;
|
||||
|
||||
InA.resize(Size);
|
||||
InB.resize(Size);
|
||||
InC.resize(Size);
|
||||
InD.resize(Size);
|
||||
OutA.resize(Size);
|
||||
OutB.resize(Size);
|
||||
OutC.resize(Size);
|
||||
OutD.resize(Size);
|
||||
|
||||
std::clock_t StartTime = std::clock();
|
||||
|
||||
for(std::size_t i = 0; i < InA.size(); ++i)
|
||||
{
|
||||
OutA[i] = InA[i];
|
||||
OutB[i] = InB[i];
|
||||
OutC[i] = InC[i];
|
||||
OutD[i] = InD[i];
|
||||
}
|
||||
|
||||
std::clock_t EndTime = std::clock();
|
||||
|
||||
std::printf("SoA: %d\n", static_cast<int>(EndTime - StartTime));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace heap
|
||||
{
|
||||
struct A
|
||||
{
|
||||
float f;
|
||||
};
|
||||
|
||||
struct B : public A
|
||||
{
|
||||
float g;
|
||||
glm::vec4 v;
|
||||
};
|
||||
|
||||
static int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
A* p = new B;
|
||||
p->f = 0.0f;
|
||||
delete p;
|
||||
|
||||
Error += sizeof(B) == sizeof(glm::vec4) + sizeof(float) * 2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace heap
|
||||
|
||||
static int test_simd()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 const a(std::clock(), std::clock(), std::clock(), std::clock());
|
||||
glm::vec4 const b(std::clock(), std::clock(), std::clock(), std::clock());
|
||||
|
||||
glm::vec4 const c(b * a);
|
||||
glm::vec4 const d(a + c);
|
||||
|
||||
Error += glm::all(glm::greaterThanEqual(d, glm::vec4(0))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_inheritance()
|
||||
{
|
||||
struct my_vec4 : public glm::vec4
|
||||
{
|
||||
my_vec4()
|
||||
: glm::vec4(76.f, 75.f, 74.f, 73.f)
|
||||
, member(82)
|
||||
{}
|
||||
|
||||
int member;
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
my_vec4 v;
|
||||
|
||||
Error += v.member == 82 ? 0 : 1;
|
||||
Error += glm::equal(v.x, 76.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
Error += glm::equal(v.y, 75.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
Error += glm::equal(v.z, 74.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
Error += glm::equal(v.w, 73.f, glm::epsilon<float>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::vec4::length() == 4, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec4(1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
|
||||
static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
static int test_simd_gen()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
int const C = static_cast<int>(std::clock());
|
||||
int const D = static_cast<int>(std::clock());
|
||||
|
||||
glm::ivec4 const A(C);
|
||||
glm::ivec4 const B(D);
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
//Error += test_simd_gen();
|
||||
|
||||
/*
|
||||
{
|
||||
glm::ivec4 const a1(2);
|
||||
glm::ivec4 const b1 = a1 >> 1;
|
||||
|
||||
__m128i const e1 = _mm_set1_epi32(2);
|
||||
__m128i const f1 = _mm_srli_epi32(e1, 1);
|
||||
|
||||
glm::ivec4 const g1 = *reinterpret_cast<glm::ivec4 const* const>(&f1);
|
||||
|
||||
glm::ivec4 const a2(-2);
|
||||
glm::ivec4 const b2 = a2 >> 1;
|
||||
|
||||
__m128i const e2 = _mm_set1_epi32(-1);
|
||||
__m128i const f2 = _mm_srli_epi32(e2, 1);
|
||||
|
||||
glm::ivec4 const g2 = *reinterpret_cast<glm::ivec4 const* const>(&f2);
|
||||
|
||||
std::printf("GNI\n");
|
||||
}
|
||||
|
||||
{
|
||||
glm::uvec4 const a1(2);
|
||||
glm::uvec4 const b1 = a1 >> 1u;
|
||||
|
||||
__m128i const e1 = _mm_set1_epi32(2);
|
||||
__m128i const f1 = _mm_srli_epi32(e1, 1);
|
||||
|
||||
glm::uvec4 const g1 = *reinterpret_cast<glm::uvec4 const* const>(&f1);
|
||||
|
||||
glm::uvec4 const a2(-1);
|
||||
glm::uvec4 const b2 = a2 >> 1u;
|
||||
|
||||
__m128i const e2 = _mm_set1_epi32(-1);
|
||||
__m128i const f2 = _mm_srli_epi32(e2, 1);
|
||||
|
||||
glm::uvec4 const g2 = *reinterpret_cast<glm::uvec4 const* const>(&f2);
|
||||
|
||||
std::printf("GNI\n");
|
||||
}
|
||||
*/
|
||||
|
||||
# ifdef NDEBUG
|
||||
std::size_t const Size(1000000);
|
||||
# else
|
||||
std::size_t const Size(1);
|
||||
# endif//NDEBUG
|
||||
|
||||
Error += test_perf_AoS(Size);
|
||||
Error += test_perf_SoA(Size);
|
||||
|
||||
Error += test_vec4_ctor();
|
||||
Error += test_bvec4_ctor();
|
||||
Error += test_size();
|
||||
Error += test_operators();
|
||||
Error += test_equal();
|
||||
Error += test_swizzle();
|
||||
Error += test_swizzle_partial();
|
||||
Error += test_simd();
|
||||
Error += test_operator_increment();
|
||||
Error += heap::test();
|
||||
Error += test_inheritance();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user