Sync up to branch 0.9.3

This commit is contained in:
athile
2011-09-21 11:25:30 -04:00
287 changed files with 21246 additions and 14361 deletions

View File

@@ -1,6 +1,7 @@
glmCreateTestGTC(core_type_float)
glmCreateTestGTC(core_type_half)
glmCreateTestGTC(core_type_int)
glmCreateTestGTC(core_type_length)
glmCreateTestGTC(core_type_mat2x2)
glmCreateTestGTC(core_type_mat2x3)
glmCreateTestGTC(core_type_mat2x4)

View File

@@ -2,145 +2,251 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/core/func_common.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
int test_static_assert()
int test_floatBitsToInt()
{
//glm::lessThan(glm::mat4(0), glm::mat4(4));
int Error = 0;
{
float A = 1.0f;
int B = glm::floatBitsToInt(A);
float C = glm::intBitsToFloat(B);
int D = *(int*)&A;
Error += B == D ? 0 : 1;
Error += A == C ? 0 : 1;
}
return 0;
{
glm::vec2 A(1.0f, 2.0f);
glm::ivec2 B = glm::floatBitsToInt(A);
glm::vec2 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::ivec3 B = glm::floatBitsToInt(A);
glm::vec3 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += B.z == *(int*)&(A.z) ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::ivec4 B = glm::floatBitsToInt(A);
glm::vec4 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += B.z == *(int*)&(A.z) ? 0 : 1;
Error += B.w == *(int*)&(A.w) ? 0 : 1;
Error += A == C? 0 : 1;
}
return Error;
}
int test_lessThan_vec2()
int test_floatBitsToUint()
{
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 Error = 0;
{
float A = 1.0f;
glm::uint B = glm::floatBitsToUint(A);
float C = glm::intBitsToFloat(B);
Error += B == *(glm::uint*)&A ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::uvec2 B = glm::floatBitsToUint(A);
glm::vec2 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += A == C ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::uvec3 B = glm::floatBitsToUint(A);
glm::vec3 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
Error += A == C? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::uvec4 B = glm::floatBitsToUint(A);
glm::vec4 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1;
Error += A == C? 0 : 1;
}
return Error;
}
int test_lessThan_vec3()
int test_mix()
{
glm::bvec3 O = glm::bvec3(true, true, false);
int Error = 0;
glm::bvec3 A = glm::lessThan(glm::vec3(0, 1, 6), glm::vec3(4, 5, 2));
assert(glm::all(glm::equal(O, A)));
{
float A = glm::mix(0.f, 1.f, true);
Error += A == 1.f ? 0 : 1;
float B = glm::mix(0.f, 1.f, false);
Error += B == 0.f ? 0 : 1;
}
glm::bvec3 B = glm::lessThan(glm::ivec3(0, 1, 6), glm::ivec3(4, 5, 2));
assert(glm::all(glm::equal(O, B)));
{
float A = glm::mix(0.f, 1.f, 1.f);
Error += A == 1.f ? 0 : 1;
float B = glm::mix(0.f, 1.f, 0.f);
Error += B == 0.f ? 0 : 1;
}
glm::bvec3 C = glm::lessThan(glm::uvec3(0, 1, 6), glm::uvec3(4, 5, 2));
assert(glm::all(glm::equal(O, C)));
return 0;
return Error;
}
int test_lessThan_vec4()
int test_round()
{
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 Error = 0;
{
float A = glm::round(0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(0.5f);
Error += B == 1.0f ? 0 : 1;
float C = glm::round(1.0f);
Error += C == 1.0f ? 0 : 1;
float D = glm::round(0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(0.9f);
Error += E == 1.0f ? 0 : 1;
float F = glm::round(1.5f);
Error += F == 2.0f ? 0 : 1;
float G = glm::round(1.9f);
Error += G == 2.0f ? 0 : 1;
}
{
float A = glm::round(-0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(-0.5f);
Error += B == -1.0f ? 0 : 1;
float C = glm::round(-1.0f);
Error += C == -1.0f ? 0 : 1;
float D = glm::round(-0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(-0.9f);
Error += E == -1.0f ? 0 : 1;
float F = glm::round(-1.5f);
Error += F == -2.0f ? 0 : 1;
float G = glm::round(-1.9f);
Error += G == -2.0f ? 0 : 1;
}
return Error;
}
int test_greaterThanEqual_vec2()
int test_roundEven()
{
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 Error = 0;
{
float A = glm::round(0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(0.5f);
Error += B == 0.0f ? 0 : 1;
float C = glm::round(1.0f);
Error += C == 1.0f ? 0 : 1;
float D = glm::round(0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(0.9f);
Error += E == 1.0f ? 0 : 1;
float F = glm::round(1.5f);
Error += F == 2.0f ? 0 : 1;
float G = glm::round(1.9f);
Error += G == 2.0f ? 0 : 1;
}
{
float A = glm::round(-0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(-0.5f);
Error += B == -0.0f ? 0 : 1;
float C = glm::round(-1.0f);
Error += C == -1.0f ? 0 : 1;
float D = glm::round(-0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(-0.9f);
Error += E == -1.0f ? 0 : 1;
float F = glm::round(-1.5f);
Error += F == -2.0f ? 0 : 1;
float G = glm::round(-1.9f);
Error += G == -2.0f ? 0 : 1;
}
{
float A = glm::round(1.5f);
Error += A == 2.0f ? 0 : 1;
float B = glm::round(2.5f);
Error += B == 2.0f ? 0 : 1;
float C = glm::round(3.5f);
Error += C == 4.0f ? 0 : 1;
float D = glm::round(4.5f);
Error += D == 4.0f ? 0 : 1;
float E = glm::round(5.5f);
Error += E == 6.0f ? 0 : 1;
float F = glm::round(6.5f);
Error += F == 6.0f ? 0 : 1;
float G = glm::round(7.5f);
Error += G == 8.0f ? 0 : 1;
}
{
float A = glm::round(-1.5f);
Error += A == -2.0f ? 0 : 1;
float B = glm::round(-2.5f);
Error += B == -2.0f ? 0 : 1;
float C = glm::round(-3.5f);
Error += C == -4.0f ? 0 : 1;
float D = glm::round(-4.5f);
Error += D == -4.0f ? 0 : 1;
float E = glm::round(-5.5f);
Error += E == -6.0f ? 0 : 1;
float F = glm::round(-6.5f);
Error += F == -6.0f ? 0 : 1;
float G = glm::round(-7.5f);
Error += G == -8.0f ? 0 : 1;
}
return Error;
}
int main()
{
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();
int Error = 0;
return Failed;
Error += test_floatBitsToInt();
Error += test_floatBitsToUint();
Error += test_mix();
Error += test_round();
Error += test_roundEven();
return Error;
}

View File

@@ -2,146 +2,16 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/core/func_exponential.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
#include <glm/glm.hpp>
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 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;
}

View File

@@ -2,146 +2,16 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/gtx/func_geometric.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
#include <glm/glm.hpp>
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 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;
}

View File

@@ -31,7 +31,7 @@ namespace extractField
result Result;
};
typedef type<glm::uint64, glm::uint> typeU64;
typedef type<glm::uint64, glm::uint32> typeU64;
typeU64 const Data64[] =
{

View File

@@ -2,147 +2,17 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/gtx/func_noise.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
#include <glm/glm.hpp>
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 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;
}

View File

@@ -2,147 +2,168 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/core/func_packing.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
#include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtx/epsilon.hpp>
#include <vector>
int test_static_assert()
int test_packUnorm2x16()
{
//glm::lessThan(glm::mat4(0), glm::mat4(4));
int Error = 0;
/*
std::vector<glm::hvec2> A;
A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 0.0f)));
A.push_back(glm::hvec2(glm::half( 0.5f), glm::half( 0.7f)));
A.push_back(glm::hvec2(glm::half( 0.1f), glm::half( 0.2f)));
*/
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));
return 0;
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::equalEpsilon(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_lessThan_vec2()
int test_packSnorm2x16()
{
glm::bvec2 O = glm::bvec2(true, false);
int Error = 0;
/*
std::vector<glm::hvec2> A;
A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 0.0f)));
A.push_back(glm::hvec2(glm::half(-0.5f), glm::half(-0.7f)));
A.push_back(glm::hvec2(glm::half(-0.1f), glm::half( 0.1f)));
*/
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));
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;
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::equalEpsilon(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_lessThan_vec3()
int test_packUnorm4x8()
{
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 Error = 0;
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::equalEpsilon(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_lessThan_vec4()
int test_packSnorm4x8()
{
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 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::equalEpsilon(B, D, 1.0f / 127.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_greaterThanEqual_vec2()
int test_packHalf2x16()
{
glm::bvec2 O = glm::bvec2(false, true);
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));
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;
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::equalEpsilon(B, D, 1.0f / 127.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_greaterThanEqual_vec3()
int test_packDouble2x32()
{
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 Error = 0;
std::vector<glm::u32vec2> A;
A.push_back(glm::u32vec2( 1, 2));
A.push_back(glm::u32vec2(-1,-2));
A.push_back(glm::u32vec2(-1000, 1100));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::u32vec2 B(A[i]);
double C = glm::packDouble2x32(B);
glm::u32vec2 D = glm::unpackDouble2x32(C);
Error += B == D ? 0 : 1;
assert(!Error);
}
return Error;
}
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 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();
int Error = 0;
Error += test_packSnorm4x8();
Error += test_packUnorm4x8();
Error += test_packSnorm2x16();
Error += test_packUnorm2x16();
Error += test_packHalf2x16();
Error += test_packDouble2x32();
return Failed;
return Error;
}

View File

@@ -2,145 +2,16 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/core/func_trigonometric.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
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 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;
}

View File

@@ -2,144 +2,16 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-01-15
// Updated : 2011-01-15
// Updated : 2011-09-13
// Licence : This source is under MIT licence
// File : test/gtx/simd-mat4.cpp
// File : test/core/vector_relational.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
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 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;
}

View File

@@ -9,8 +9,156 @@
#define GLM_MESSAGES
#include <glm/glm.hpp>
#include <iostream>
static int test_operators()
int test_compiler()
{
int Error = 0;
switch(GLM_COMPILER)
{
case GLM_COMPILER_VC:
std::cout << "GLM_COMPILER_VC" << std::endl;
break;
case GLM_COMPILER_VC2:
std::cout << "GLM_COMPILER_VC2" << std::endl;
break;
case GLM_COMPILER_VC4:
std::cout << "GLM_COMPILER_VC4" << std::endl;
break;
case GLM_COMPILER_VC5:
std::cout << "GLM_COMPILER_VC5" << std::endl;
break;
case GLM_COMPILER_VC6:
std::cout << "GLM_COMPILER_VC6" << std::endl;
break;
case GLM_COMPILER_VC2002:
std::cout << "GLM_COMPILER_VC2002" << std::endl;
break;
case GLM_COMPILER_VC2003:
std::cout << "GLM_COMPILER_VC2003" << std::endl;
break;
case GLM_COMPILER_VC2005:
std::cout << "GLM_COMPILER_VC2005" << std::endl;
break;
case GLM_COMPILER_VC2008:
std::cout << "GLM_COMPILER_VC2008" << std::endl;
break;
case GLM_COMPILER_VC2010:
std::cout << "GLM_COMPILER_VC2010" << std::endl;
break;
case GLM_COMPILER_VC2011:
std::cout << "GLM_COMPILER_VC2011" << std::endl;
break;
case GLM_COMPILER_GCC:
std::cout << "GLM_COMPILER_GCC" << std::endl;
break;
case GLM_COMPILER_GCC30:
std::cout << "GLM_COMPILER_GCC30" << std::endl;
break;
case GLM_COMPILER_GCC31:
std::cout << "GLM_COMPILER_GCC31" << std::endl;
break;
case GLM_COMPILER_GCC32:
std::cout << "GLM_COMPILER_GCC32" << std::endl;
break;
case GLM_COMPILER_GCC33:
std::cout << "GLM_COMPILER_GCC33" << std::endl;
break;
case GLM_COMPILER_GCC34:
std::cout << "GLM_COMPILER_GCC34" << std::endl;
break;
case GLM_COMPILER_GCC35:
std::cout << "GLM_COMPILER_GCC35" << std::endl;
break;
case GLM_COMPILER_GCC40:
std::cout << "GLM_COMPILER_GCC40" << std::endl;
break;
case GLM_COMPILER_GCC41:
std::cout << "GLM_COMPILER_GCC41" << std::endl;
break;
case GLM_COMPILER_GCC42:
std::cout << "GLM_COMPILER_GCC42" << std::endl;
break;
case GLM_COMPILER_GCC43:
std::cout << "GLM_COMPILER_GCC43" << std::endl;
break;
case GLM_COMPILER_GCC44:
std::cout << "GLM_COMPILER_GCC44" << std::endl;
break;
case GLM_COMPILER_GCC45:
std::cout << "GLM_COMPILER_GCC45" << std::endl;
break;
case GLM_COMPILER_GCC46:
std::cout << "GLM_COMPILER_GCC46" << std::endl;
break;
case GLM_COMPILER_GCC47:
std::cout << "GLM_COMPILER_GCC47" << std::endl;
break;
case GLM_COMPILER_BC:
std::cout << "GLM_COMPILER_BC" << std::endl;
break;
case GLM_COMPILER_BCB4:
std::cout << "GLM_COMPILER_BCB4" << std::endl;
break;
case GLM_COMPILER_BCB5:
std::cout << "GLM_COMPILER_BCB5" << std::endl;
break;
case GLM_COMPILER_BCB6:
std::cout << "GLM_COMPILER_BCB6" << std::endl;
break;
case GLM_COMPILER_BCB2009:
std::cout << "GLM_COMPILER_BCB2009" << std::endl;
break;
case GLM_COMPILER_CODEWARRIOR:
std::cout << "GLM_COMPILER_CODEWARRIOR" << std::endl;
break;
case GLM_COMPILER_CUDA:
std::cout << "GLM_COMPILER_CUDA" << std::endl;
break;
case GLM_COMPILER_CLANG:
std::cout << "GLM_COMPILER_CLANG" << std::endl;
break;
case GLM_COMPILER_CLANG26:
std::cout << "GLM_COMPILER_CLANG26" << std::endl;
break;
case GLM_COMPILER_CLANG27:
std::cout << "GLM_COMPILER_CLANG27" << std::endl;
break;
case GLM_COMPILER_CLANG28:
std::cout << "GLM_COMPILER_CLANG28" << std::endl;
break;
case GLM_COMPILER_CLANG29:
std::cout << "GLM_COMPILER_CLANG29" << std::endl;
break;
case GLM_COMPILER_LLVM_GCC:
std::cout << "GLM_COMPILER_LLVM_GCC" << std::endl;
break;
default:
std::cout << "Undetected compiler" << std::endl;
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::cout << "GLM_MODEL_32" << std::endl;
else if(GLM_MODEL == GLM_MODEL_64)
std::cout << "GLM_MODEL_64" << std::endl;
return Error;
}
int test_operators()
{
glm::vec3 A(1.0f);
glm::vec3 B(1.0f);
@@ -24,6 +172,8 @@ int main()
{
int Error = 0;
Error += test_compiler();
Error += test_model();
Error += test_operators();
return Error;

View File

@@ -20,8 +20,8 @@ int test_float_size()
int test_float_precision()
{
return (
sizeof(glm::lowp_float) <= sizeof(glm::mediump_float) &&
sizeof(glm::mediump_float) <= sizeof(glm::highp_float)) ? 0 : 1;
sizeof(glm::lowp_float) <= sizeof(glm::mediump_float) &&
sizeof(glm::mediump_float) <= sizeof(glm::highp_float)) ? 0 : 1;
}
int test_vec2()
@@ -35,7 +35,6 @@ int main()
Error += test_float_size();
Error += test_float_precision();
Error += test_vec2();
return Error;
}

View File

@@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-08-31
// Updated : 2010-08-25
// Updated : 2011-09-20
// Licence : This source is under MIT licence
// File : test/core/type_half.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -10,23 +10,182 @@
#include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
int test_half_ctor()
{
int Error = 0;
glm::half A(1.0f);
Error += A.toFloat() == 1.0f ? 0 : 1;
glm::half B = glm::half(1.0f);
Error += B.toFloat() == 1.0f ? 0 : 1;
glm::half C = B;
Error += C.toFloat() == 1.0f ? 0 : 1;
return Error;
}
int test_half_cast()
{
int Error = 0;
glm::half A(2.0f);
Error += A.toFloat() == 2.0f ? 0 : 1;
glm::half B(2.0);
Error += B.toFloat() == 2.0f ? 0 : 1;
glm::half C(2);
Error += C.toFloat() == 2.0f ? 0 : 1;
float D(A);
Error += D == 2.0f ? 0 : 1;
double E(A);
Error += E == 2.0 ? 0 : 1;
int F(A);
Error += F == 2.0 ? 0 : 1;
return Error;
}
int test_half_relational()
{
int Error = 0;
glm::half A(1.0f);
glm::half B(2.0f);
Error += !(A == B) ? 0 : 1;
Error += (A != B) ? 0 : 1;
Error += (A <= B) ? 0 : 1;
Error += (A < B) ? 0 : 1;
Error += !(A >= B) ? 0 : 1;
Error += !(A > B) ? 0 : 1;
return Error;
}
int test_half_arithmetic_unary_ops()
{
int Error = 0;
{
glm::half A(2.0f);
glm::half B(3.0f);
A += B;
Error += (A == glm::half( 5.0f) ? 0 : 1);
}
{
glm::half A(2.0f);
glm::half B(3.0f);
A -= B;
Error += (A == glm::half(-1.0f) ? 0 : 1);
}
{
glm::half A(2.0f);
glm::half B(3.0f);
B -= A;
Error += (B == glm::half( 1.0f) ? 0 : 1);
}
{
glm::half A(2.0f);
glm::half B(3.0f);
A *= B;
Error += (A == glm::half(6.0f) ? 0 : 1);
}
{
glm::half A(2.0f);
glm::half B(3.0f);
A /= B;
Error += (A == glm::half(2.0f / 3.0f) ? 0 : 1);
}
{
glm::half A(2.0f);
glm::half B(3.0f);
B /= A;
Error += (B == glm::half(3.0f / 2.0f) ? 0 : 1);
}
return Error;
}
int test_half_arithmetic_binary_ops()
{
int Error = 0;
glm::half A(2.0f);
glm::half B(3.0f);
Error += A + B == glm::half( 5.0f) ? 0 : 1;
Error += A - B == glm::half(-1.0f) ? 0 : 1;
Error += B - A == glm::half( 1.0f) ? 0 : 1;
Error += A * B == glm::half( 6.0f) ? 0 : 1;
Error += A / B == glm::half(2.0f / 3.0f) ? 0 : 1;
Error += B / A == glm::half(3.0f / 2.0f) ? 0 : 1;
return Error;
}
int test_half_arithmetic_counter_ops()
{
int Error = 0;
{
glm::half A(2.0f);
Error += A == glm::half(2.0f) ? 0 : 1;
}
{
glm::half A(2.0f);
glm::half B = A++;
Error += B == glm::half(3.0f) ? 0 : 1;
}
{
glm::half A(2.0f);
glm::half B = A--;
Error += B == glm::half(1.0f) ? 0 : 1;
}
{
glm::half A(2.0f);
glm::half B = ++A;
Error += B == glm::half(3.0f) ? 0 : 1;
}
{
glm::half A(2.0f);
glm::half B = --A;
Error += B == glm::half(1.0f) ? 0 : 1;
}
{
glm::half A(2.0f);
glm::half B = -A;
Error += B == glm::half(-2.0f) ? 0 : 1;
}
return Error;
}
int main()
{
int Result = 0;
glm::half A(1.0f);
glm::half B(2.0f);
glm::half C = A + B;
glm::half D(C);
float E = D;
int F = float(C);
glm::half G = B * C;
glm::half H = G / C;
H += glm::half(1.0f);
double J = H;
int I = float(H);
Result = Result && J == 3.0;
Result += test_half_ctor();
Result += test_half_cast();
Result += test_half_relational();
Result += test_half_arithmetic_unary_ops();
Result += test_half_arithmetic_binary_ops();
Result += test_half_arithmetic_counter_ops();
return Result != 0;
return Result;
}

View File

@@ -0,0 +1,107 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-05-25
// Updated : 2011-05-25
// Licence : This source is under MIT License
// File : test/core/type_length.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
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;
Error += glm::hmat2x3().length() == 2 ? 0 : 1;
Error += glm::hmat2x4().length() == 2 ? 0 : 1;
Error += glm::hmat3x2().length() == 3 ? 0 : 1;
Error += glm::hmat3x4().length() == 3 ? 0 : 1;
Error += glm::hmat4x2().length() == 4 ? 0 : 1;
Error += glm::hmat4x3().length() == 4 ? 0 : 1;
return Error;
}
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;
Error += glm::hmat2().length() == 2 ? 0 : 1;
Error += glm::hmat3().length() == 3 ? 0 : 1;
Error += glm::hmat4().length() == 4 ? 0 : 1;
Error += glm::hmat2x2().length() == 2 ? 0 : 1;
Error += glm::hmat3x3().length() == 3 ? 0 : 1;
Error += glm::hmat4x4().length() == 4 ? 0 : 1;
return Error;
}
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::hvec2().length() == 2 ? 0 : 1;
Error += glm::hvec3().length() == 3 ? 0 : 1;
Error += glm::hvec4().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;
}