diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt new file mode 100644 index 00000000..3ec521ef --- /dev/null +++ b/bench/CMakeLists.txt @@ -0,0 +1,11 @@ +function(glmCreateBenchGTC NAME) + set(SAMPLE_NAME bench-${NAME}) + + add_executable(${SAMPLE_NAME} ${NAME}.cpp) +endfunction(glmCreateBenchGTC) + +add_subdirectory(core) +add_subdirectory(gtc) +add_subdirectory(gtx) + + diff --git a/bench/core/CMakeLists.txt b/bench/core/CMakeLists.txt new file mode 100644 index 00000000..e69de29b diff --git a/bench/gtc/CMakeLists.txt b/bench/gtc/CMakeLists.txt new file mode 100644 index 00000000..e69de29b diff --git a/bench/gtx/CMakeLists.txt b/bench/gtx/CMakeLists.txt new file mode 100644 index 00000000..e69de29b diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 47c32fab..c41aeb62 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,5 +8,5 @@ add_subdirectory(bug) add_subdirectory(core) add_subdirectory(gtc) add_subdirectory(gtx) -add_subdirectory(img) + diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index e36c0502..d851ac7d 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -14,7 +14,15 @@ glmCreateTestGTC(core_type_vec1) glmCreateTestGTC(core_type_vec2) glmCreateTestGTC(core_type_vec3) glmCreateTestGTC(core_type_vec4) -glmCreateTestGTC(core_vector_relational) +glmCreateTestGTC(core_func_common) +glmCreateTestGTC(core_func_exponential) +glmCreateTestGTC(core_func_geometric) +glmCreateTestGTC(core_func_integer) +glmCreateTestGTC(core_func_matrix) +glmCreateTestGTC(core_func_noise) +glmCreateTestGTC(core_func_packing) +glmCreateTestGTC(core_func_trigonometric) +glmCreateTestGTC(core_func_vector_relational) diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_common.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_exponential.cpp b/test/core/core_func_exponential.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_exponential.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_geometric.cpp b/test/core/core_func_geometric.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_geometric.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_integer.cpp b/test/core/core_func_integer.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_integer.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_matrix.cpp b/test/core/core_func_matrix.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_matrix.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_noise.cpp b/test/core/core_func_noise.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_noise.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_packing.cpp b/test/core/core_func_packing.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_packing.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_trigonometric.cpp b/test/core/core_func_trigonometric.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_trigonometric.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} + diff --git a/test/core/core_func_vector_relational.cpp b/test/core/core_func_vector_relational.cpp new file mode 100644 index 00000000..8e25e51d --- /dev/null +++ b/test/core/core_func_vector_relational.cpp @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-01-15 +// Updated : 2011-01-15 +// Licence : This source is under MIT licence +// File : test/gtx/simd-mat4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2 +#include + +int test_static_assert() +{ + //glm::lessThan(glm::mat4(0), glm::mat4(4)); + + return 0; +} + +int test_lessThan_vec2() +{ + glm::bvec2 O = glm::bvec2(true, false); + + glm::bvec2 A = glm::lessThan(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::lessThan(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::lessThan(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec3() +{ + glm::bvec3 O = glm::bvec3(true, true, false); + + glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_lessThan_vec4() +{ + glm::bvec4 O = glm::bvec4(true, true, false, false); + + glm::bvec4 A = glm::lessThan(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::lessThan(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::lessThan(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec2() +{ + glm::bvec2 O = glm::bvec2(false, true); + + glm::bvec2 A = glm::greaterThanEqual(glm::vec2(0, 6), glm::vec2(4, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec2 B = glm::greaterThanEqual(glm::ivec2(0, 6), glm::ivec2(4, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec2 C = glm::greaterThanEqual(glm::uvec2(0, 6), glm::uvec2(4, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec3() +{ + glm::bvec3 O = glm::bvec3(false, false, true); + + glm::bvec3 A = glm::greaterThanEqual(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec3 B = glm::greaterThanEqual(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec3 C = glm::greaterThanEqual(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_greaterThanEqual_vec4() +{ + glm::bvec4 O = glm::bvec4(false, false, true, true); + + glm::bvec4 A = glm::greaterThanEqual(glm::vec4(0, 1, 6, 7), glm::vec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, A))); + + glm::bvec4 B = glm::greaterThanEqual(glm::ivec4(0, 1, 6, 7), glm::ivec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, B))); + + glm::bvec4 C = glm::greaterThanEqual(glm::uvec4(0, 1, 6, 7), glm::uvec4(4, 5, 2, 3)); + assert(glm::all(glm::equal(O, C))); + + return 0; +} + +int test_all() +{ + assert(glm::all(glm::bvec2(true, true))); + assert(!glm::all(glm::bvec2(true, false))); + assert(!glm::all(glm::bvec2(false, false))); + + assert(glm::all(glm::bvec3(true, true, true))); + assert(!glm::all(glm::bvec3(true, false, true))); + assert(!glm::all(glm::bvec3(false, false, false))); + + assert(glm::all(glm::bvec4(true, true, true, true))); + assert(!glm::all(glm::bvec4(true, false, true, false))); + assert(!glm::all(glm::bvec4(false, false, false, false))); + + return 0; +} + + +int main(int argc, void* argv[]) +{ + int Failed = 0; + Failed += test_static_assert(); + Failed += test_lessThan_vec2(); + Failed += test_lessThan_vec3(); + Failed += test_lessThan_vec4(); + Failed += test_greaterThanEqual_vec2(); + Failed += test_greaterThanEqual_vec3(); + Failed += test_greaterThanEqual_vec4(); + Failed += test_all(); + + return Failed; +} +