external: import local copy of GLM 0.9.7.2
This allows building against the same version of GLM across all targets and not deal with API changes of newer GLM versions which introduce regressions. Long term we want to migrate away from GLM and stick to a minimal self-written subset.
This commit is contained in:
parent
01ef1d23de
commit
5070880428
846 changed files with 179358 additions and 1 deletions
38
external/glm/test/core/CMakeLists.txt
vendored
Normal file
38
external/glm/test/core/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
glmCreateTestGTC(core_type_cast)
|
||||
glmCreateTestGTC(core_type_ctor)
|
||||
glmCreateTestGTC(core_type_float)
|
||||
glmCreateTestGTC(core_type_int)
|
||||
glmCreateTestGTC(core_type_length)
|
||||
glmCreateTestGTC(core_type_length_size)
|
||||
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_message)
|
||||
glmCreateTestGTC(core_setup_precision)
|
||||
|
||||
|
||||
|
||||
1264
external/glm/test/core/core_func_common.cpp
vendored
Normal file
1264
external/glm/test/core/core_func_common.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
149
external/glm/test/core/core_func_exponential.cpp
vendored
Normal file
149
external/glm/test/core/core_func_exponential.cpp
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_exponential.cpp
|
||||
/// @date 2011-01-15 / 2011-09-13
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/common.hpp>
|
||||
#include <glm/exponential.hpp>
|
||||
#include <glm/gtc/ulp.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
|
||||
int test_pow()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::pow(10.f, 10.f);
|
||||
glm::vec1 B = glm::pow(glm::vec1(10.f), glm::vec1(10.f));
|
||||
glm::vec2 C = glm::pow(glm::vec2(10.f), glm::vec2(10.f));
|
||||
glm::vec3 D = glm::pow(glm::vec3(10.f), glm::vec3(10.f));
|
||||
glm::vec4 E = glm::pow(glm::vec4(10.f), glm::vec4(10.f));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_exp()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::exp(10.f);
|
||||
glm::vec1 B = glm::exp(glm::vec1(10.f));
|
||||
glm::vec2 C = glm::exp(glm::vec2(10.f));
|
||||
glm::vec3 D = glm::exp(glm::vec3(10.f));
|
||||
glm::vec4 E = glm::exp(glm::vec4(10.f));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_log()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::log(10.f);
|
||||
glm::vec1 B = glm::log(glm::vec1(10.f));
|
||||
glm::vec2 C = glm::log(glm::vec2(10.f));
|
||||
glm::vec3 D = glm::log(glm::vec3(10.f));
|
||||
glm::vec4 E = glm::log(glm::vec4(10.f));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_exp2()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::exp2(10.f);
|
||||
glm::vec1 B = glm::exp2(glm::vec1(10.f));
|
||||
glm::vec2 C = glm::exp2(glm::vec2(10.f));
|
||||
glm::vec3 D = glm::exp2(glm::vec3(10.f));
|
||||
glm::vec4 E = glm::exp2(glm::vec4(10.f));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_log2()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::log2(10.f);
|
||||
glm::vec1 B = glm::log2(glm::vec1(10.f));
|
||||
glm::vec2 C = glm::log2(glm::vec2(10.f));
|
||||
glm::vec3 D = glm::log2(glm::vec3(10.f));
|
||||
glm::vec4 E = glm::log2(glm::vec4(10.f));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_sqrt()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
float A = glm::sqrt(10.f);
|
||||
glm::vec1 B = glm::sqrt(glm::vec1(10.f));
|
||||
glm::vec2 C = glm::sqrt(glm::vec2(10.f));
|
||||
glm::vec3 D = glm::sqrt(glm::vec3(10.f));
|
||||
glm::vec4 E = glm::sqrt(glm::vec4(10.f));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_inversesqrt()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::uint ulp(0);
|
||||
float diff(0.0f);
|
||||
|
||||
for(float f = 0.001f; f < 10.f; f *= 1.001f)
|
||||
{
|
||||
glm::lowp_fvec1 u(f);
|
||||
glm::lowp_fvec1 lowp_v = glm::inversesqrt(u);
|
||||
float defaultp_v = glm::inversesqrt(f);
|
||||
|
||||
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
|
||||
diff = glm::abs(lowp_v.x - defaultp_v);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += test_pow();
|
||||
Error += test_exp();
|
||||
Error += test_log();
|
||||
Error += test_exp2();
|
||||
Error += test_log2();
|
||||
Error += test_sqrt();
|
||||
Error += test_inversesqrt();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
217
external/glm/test/core/core_func_geometric.cpp
vendored
Normal file
217
external/glm/test/core/core_func_geometric.cpp
vendored
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_geometric.cpp
|
||||
/// @date 2011-01-15 / 2011-09-13
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/geometric.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtc/vec1.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));
|
||||
|
||||
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 += C == glm::vec2(1.0, 1.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dvec2 A(1.0f,-1.0f);
|
||||
glm::dvec2 B(0.0f, 1.0f);
|
||||
glm::dvec2 C = glm::reflect(A, B);
|
||||
Error += C == glm::dvec2(1.0, 1.0) ? 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 += C == -1.0f ? 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::epsilonEqual(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 += C == glm::dvec2(0.0, -1.0) ? 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;
|
||||
}
|
||||
|
||||
1585
external/glm/test/core/core_func_integer.cpp
vendored
Normal file
1585
external/glm/test/core/core_func_integer.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
322
external/glm/test/core/core_func_integer_bit_count.cpp
vendored
Normal file
322
external/glm/test/core/core_func_integer_bit_count.cpp
vendored
Normal file
|
|
@ -0,0 +1,322 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_integer_bit_count.cpp
|
||||
/// @date 2011-01-15 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 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 <stdio.h>
|
||||
#include <stdlib.h> //To define "exit", req'd by XLC.
|
||||
#include <ctime>
|
||||
|
||||
unsigned rotatel(unsigned x, int n)
|
||||
{
|
||||
if ((unsigned)n > 63) {printf("rotatel, n out of range.\n"); 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 y;
|
||||
}
|
||||
|
||||
int errors;
|
||||
void error(int x, int y)
|
||||
{
|
||||
errors = errors + 1;
|
||||
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();
|
||||
|
||||
printf("pop0: %ld clocks\n", 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();
|
||||
|
||||
printf("pop1: %ld clocks\n", 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();
|
||||
|
||||
printf("pop2: %ld clocks\n", 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();
|
||||
|
||||
printf("pop3: %ld clocks\n", 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();
|
||||
|
||||
printf("pop4: %ld clocks\n", 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();
|
||||
|
||||
printf("pop5: %ld clocks\n", 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();
|
||||
|
||||
printf("pop5a: %ld clocks\n", 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();
|
||||
|
||||
printf("pop6: %ld clocks\n", 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();
|
||||
|
||||
printf("pop7: %ld clocks\n", 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();
|
||||
|
||||
printf("pop8: %ld clocks\n", 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();
|
||||
|
||||
printf("pop9: %ld clocks\n", TimestampEnd - TimestampBeg);
|
||||
|
||||
if (errors == 0)
|
||||
printf("Passed all %d cases.\n", sizeof(test)/8);
|
||||
|
||||
# endif//NDEBUG
|
||||
}
|
||||
431
external/glm/test/core/core_func_integer_find_lsb.cpp
vendored
Normal file
431
external/glm/test/core/core_func_integer_find_lsb.cpp
vendored
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_integer_find_lsb.cpp
|
||||
/// @date 2014-10-27 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This has the programs for computing the number of trailing zeros
|
||||
// in a word.
|
||||
// Max line length is 57, to fit in hacker.book.
|
||||
#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;
|
||||
}
|
||||
|
||||
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;
|
||||
printf("Error for x = %08x, got %d\n", x, y);
|
||||
}
|
||||
|
||||
/* ------------------------------ main ------------------------------ */
|
||||
|
||||
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();
|
||||
|
||||
printf("ntz1: %d clocks\n", 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();
|
||||
|
||||
printf("ntz2: %d clocks\n", 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();
|
||||
|
||||
printf("ntz3: %d clocks\n", 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();
|
||||
|
||||
printf("ntz4: %d clocks\n", 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();
|
||||
|
||||
printf("ntz4a: %d clocks\n", 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(test[i]) != m) error(test[i], ntz5(test[i]));}
|
||||
TimestampEnd = std::clock();
|
||||
|
||||
printf("ntz5: %d clocks\n", 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();
|
||||
|
||||
printf("ntz6: %d clocks\n", 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();
|
||||
|
||||
printf("ntz6a: %d clocks\n", 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();
|
||||
|
||||
printf("ntz7: %d clocks\n", 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();
|
||||
|
||||
printf("ntz7_christophe: %d clocks\n", 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();
|
||||
|
||||
printf("ntz8: %d clocks\n", 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();
|
||||
|
||||
printf("ntz8a: %d clocks\n", 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();
|
||||
|
||||
printf("ntz9: %d clocks\n", 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();
|
||||
|
||||
printf("ntz10: %d clocks\n", TimestampEnd - TimestampBeg);
|
||||
|
||||
if (errors == 0)
|
||||
printf("Passed all %d cases.\n", sizeof(test)/8);
|
||||
|
||||
# endif//NDEBUG
|
||||
}
|
||||
468
external/glm/test/core/core_func_integer_find_msb.cpp
vendored
Normal file
468
external/glm/test/core/core_func_integer_find_msb.cpp
vendored
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_integer_find_msb.cpp
|
||||
/// @date 2014-10-27 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// This has the programs for computing the number of leading zeros
|
||||
// in a word.
|
||||
// Max line length is 57, to fit in hacker.book.
|
||||
// Compile with g++, not gcc.
|
||||
#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 ((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 = (double)k + 0.5;
|
||||
n = 1054 - (asInt[LE] >> 20);
|
||||
return n;
|
||||
}
|
||||
|
||||
int nlz7(unsigned k) {
|
||||
union {
|
||||
unsigned asInt[2];
|
||||
double asDouble;
|
||||
};
|
||||
int n;
|
||||
|
||||
asDouble = (double)k;
|
||||
n = 1054 - (asInt[LE] >> 20);
|
||||
n = (n & 31) + (n >> 9);
|
||||
return n;
|
||||
}
|
||||
|
||||
/* In single precision, 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 = (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 = (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;
|
||||
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();
|
||||
|
||||
printf("nlz1: %d clocks\n", 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();
|
||||
|
||||
printf("nlz1a: %d clocks\n", 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();
|
||||
|
||||
printf("nlz2: %d clocks\n", 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();
|
||||
|
||||
printf("nlz2a: %d clocks\n", 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();
|
||||
|
||||
printf("nlz3: %d clocks\n", 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();
|
||||
|
||||
printf("nlz4: %d clocks\n", 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();
|
||||
|
||||
printf("nlz5: %d clocks\n", 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();
|
||||
|
||||
printf("nlz6: %d clocks\n", 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();
|
||||
|
||||
printf("nlz7: %d clocks\n", 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();
|
||||
|
||||
printf("nlz8: %d clocks\n", 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();
|
||||
|
||||
printf("nlz9: %d clocks\n", 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();
|
||||
|
||||
printf("nlz10: %d clocks\n", 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();
|
||||
|
||||
printf("nlz10a: %d clocks\n", 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();
|
||||
|
||||
printf("nlz10b: %d clocks\n", TimestampEnd - TimestampBeg);
|
||||
|
||||
if (errors == 0)
|
||||
printf("Passed all %d cases.\n", sizeof(test)/8);
|
||||
|
||||
# endif//NDEBUG
|
||||
}
|
||||
275
external/glm/test/core/core_func_matrix.cpp
vendored
Normal file
275
external/glm/test/core/core_func_matrix.cpp
vendored
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_matrix.cpp
|
||||
/// @date 2007-01-25 / 2011-06-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/matrix.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/ulp.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);
|
||||
Error += n == mat2(0, 1, 4, 9) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x3 m(0, 1, 2, 3, 4, 5);
|
||||
mat2x3 n = matrixCompMult(m, m);
|
||||
Error += n == mat2x3(0, 1, 4, 9, 16, 25) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat2x4 n = matrixCompMult(m, m);
|
||||
Error += n == mat2x4(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mat3 n = matrixCompMult(m, m);
|
||||
Error += n == mat3(0, 1, 4, 9, 16, 25, 36, 49, 64) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x2 m(0, 1, 2, 3, 4, 5);
|
||||
mat3x2 n = matrixCompMult(m, m);
|
||||
Error += n == mat3x2(0, 1, 4, 9, 16, 25) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat3x4 n = matrixCompMult(m, m);
|
||||
Error += n == mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 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);
|
||||
Error += n == mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat4x2 n = matrixCompMult(m, m);
|
||||
Error += n == mat4x2(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat4x3 n = matrixCompMult(m, m);
|
||||
Error += n == mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_outerProduct()
|
||||
{
|
||||
glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_transpose()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
mat2 m(0, 1, 2, 3);
|
||||
mat2 t = transpose(m);
|
||||
Error += t == mat2(0, 2, 1, 3) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x3 m(0, 1, 2, 3, 4, 5);
|
||||
mat3x2 t = transpose(m);
|
||||
Error += t == mat3x2(0, 3, 1, 4, 2, 5) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat4x2 t = transpose(m);
|
||||
Error += t == mat4x2(0, 4, 1, 5, 2, 6, 3, 7) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
mat3 t = transpose(m);
|
||||
Error += t == mat3(0, 3, 6, 1, 4, 7, 2, 5, 8) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x2 m(0, 1, 2, 3, 4, 5);
|
||||
mat2x3 t = transpose(m);
|
||||
Error += t == mat2x3(0, 2, 4, 1, 3, 5) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat4x3 t = transpose(m);
|
||||
Error += t == mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
||||
mat4 t = transpose(m);
|
||||
Error += t == mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
|
||||
mat2x4 t = transpose(m);
|
||||
Error += t == mat2x4(0, 2, 4, 6, 1, 3, 5, 7) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
mat3x4 t = transpose(m);
|
||||
Error += t == mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_determinant()
|
||||
{
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_inverse()
|
||||
{
|
||||
int Failed(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;
|
||||
Failed += I4x4 == glm::mat4x4(1) ? 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;
|
||||
Failed += I3x3 == glm::mat3x3(1) ? 0 : 1;
|
||||
|
||||
glm::mat2x2 A2x2(
|
||||
glm::vec2(1, 1),
|
||||
glm::vec2(0, 1));
|
||||
glm::mat2x2 B2x2 = glm::inverse(A2x2);
|
||||
glm::mat2x2 I2x2 = A2x2 * B2x2;
|
||||
Failed += I2x2 == glm::mat2x2(1) ? 0 : 1;
|
||||
|
||||
|
||||
|
||||
return Failed;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
printf("inverse<%s>(%f): %lu\n", Message, 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();
|
||||
|
||||
# ifdef NDEBUG
|
||||
std::size_t const Samples(1000);
|
||||
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");
|
||||
}
|
||||
# endif//NDEBUG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
38
external/glm/test/core/core_func_noise.cpp
vendored
Normal file
38
external/glm/test/core/core_func_noise.cpp
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_noise.cpp
|
||||
/// @date 2011-01-15 / 2011-09-13
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main()
|
||||
{
|
||||
int Failed = 0;
|
||||
|
||||
return Failed;
|
||||
}
|
||||
|
||||
181
external/glm/test/core/core_func_packing.cpp
vendored
Normal file
181
external/glm/test/core/core_func_packing.cpp
vendored
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/func_packing.cpp
|
||||
/// @date 2011-01-15 / 2011-09-13
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
108
external/glm/test/core/core_func_swizzle.cpp
vendored
Normal file
108
external/glm/test/core/core_func_swizzle.cpp
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_func_swizzle.cpp
|
||||
/// @date 2011-10-16 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_MESSAGES
|
||||
#define GLM_SWIZZLE
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
int test_ivec2_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
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;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_ivec3_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
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;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_ivec4_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
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;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec4_swizzle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
glm::vec4 B = A.wzyx();
|
||||
glm::vec4 C = B.wzyx();
|
||||
|
||||
float f = glm::dot(C.wzyx(), C.xyzw());
|
||||
|
||||
Error += A != B ? 0 : 1;
|
||||
Error += A == C ? 0 : 1;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
41
external/glm/test/core/core_func_trigonometric.cpp
vendored
Normal file
41
external/glm/test/core/core_func_trigonometric.cpp
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_func_trigonometric.cpp
|
||||
/// @date 2011-01-15 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/trigonometric.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
73
external/glm/test/core/core_func_vector_relational.cpp
vendored
Normal file
73
external/glm/test/core/core_func_vector_relational.cpp
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_vector_relational.cpp
|
||||
/// @date 2011-01-15 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += test_not();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
42
external/glm/test/core/core_setup_force_cxx98.cpp
vendored
Normal file
42
external/glm/test/core/core_setup_force_cxx98.cpp
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref test
|
||||
/// @file test/core/core_setup_force_cxx98.cpp
|
||||
/// @date 2014-11-15 / 2014-11-15
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_FORCE_CXX98
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
272
external/glm/test/core/core_setup_message.cpp
vendored
Normal file
272
external/glm/test/core/core_setup_message.cpp
vendored
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-05-31
|
||||
// Updated : 2013-08-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : test/core/setup_message.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_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_VC2010:
|
||||
std::printf("GLM_COMPILER_VC2010\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC2012:
|
||||
std::printf("GLM_COMPILER_VC2012\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC2013:
|
||||
std::printf("GLM_COMPILER_VC2013\n");
|
||||
break;
|
||||
case GLM_COMPILER_VC2015:
|
||||
std::printf("GLM_COMPILER_VC2015\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_GCC44:
|
||||
std::printf("GLM_COMPILER_GCC44\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC45:
|
||||
std::printf("GLM_COMPILER_GCC45\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC46:
|
||||
std::printf("GLM_COMPILER_GCC46\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC47:
|
||||
std::printf("GLM_COMPILER_GCC47\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC48:
|
||||
std::printf("GLM_COMPILER_GCC48\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC49:
|
||||
std::printf("GLM_COMPILER_GCC49\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC50:
|
||||
std::printf("GLM_COMPILER_GCC50\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC51:
|
||||
std::printf("GLM_COMPILER_GCC51\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC52:
|
||||
std::printf("GLM_COMPILER_GCC52\n");
|
||||
break;
|
||||
case GLM_COMPILER_GCC53:
|
||||
std::printf("GLM_COMPILER_GCC53\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("GCC version not detected\n");
|
||||
Error += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_CUDA)
|
||||
{
|
||||
std::printf("GLM_COMPILER_CUDA\n");
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_APPLE_CLANG)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_APPLE_CLANG40:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG40\n");
|
||||
break;
|
||||
case GLM_COMPILER_APPLE_CLANG41:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG41\n");
|
||||
break;
|
||||
case GLM_COMPILER_APPLE_CLANG42:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG42\n");
|
||||
break;
|
||||
case GLM_COMPILER_APPLE_CLANG50:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG50\n");
|
||||
break;
|
||||
case GLM_COMPILER_APPLE_CLANG51:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG51\n");
|
||||
break;
|
||||
case GLM_COMPILER_APPLE_CLANG60:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG60\n");
|
||||
break;
|
||||
case GLM_COMPILER_APPLE_CLANG61:
|
||||
std::printf("GLM_COMPILER_APPLE_CLANG61\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("Apple Clang version not detected\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_LLVM)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_LLVM32:
|
||||
std::printf("GLM_COMPILER_LLVM32\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM33:
|
||||
std::printf("GLM_COMPILER_LLVM33\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM34:
|
||||
std::printf("GLM_COMPILER_LLVM34\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM35:
|
||||
std::printf("GLM_COMPILER_LLVM35\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM36:
|
||||
std::printf("GLM_COMPILER_LLVM36\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM37:
|
||||
std::printf("GLM_COMPILER_LLVM37\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM38:
|
||||
std::printf("GLM_COMPILER_LLVM38\n");
|
||||
break;
|
||||
case GLM_COMPILER_LLVM39:
|
||||
std::printf("GLM_COMPILER_LLVM39\n");
|
||||
break;
|
||||
default:
|
||||
std::printf("LLVM version not detected\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(GLM_COMPILER & GLM_COMPILER_INTEL)
|
||||
{
|
||||
switch(GLM_COMPILER)
|
||||
{
|
||||
case GLM_COMPILER_INTEL12:
|
||||
std::printf("GLM_COMPILER_INTEL12\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL12_1:
|
||||
std::printf("GLM_COMPILER_INTEL12_1\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL13:
|
||||
std::printf("GLM_COMPILER_INTEL13\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL14:
|
||||
std::printf("GLM_COMPILER_INTEL14\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL15:
|
||||
std::printf("GLM_COMPILER_INTEL15\n");
|
||||
break;
|
||||
case GLM_COMPILER_INTEL16:
|
||||
std::printf("GLM_COMPILER_INTEL16\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_PURE)
|
||||
std::printf("GLM_ARCH_PURE ");
|
||||
if(GLM_ARCH & GLM_ARCH_ARM)
|
||||
std::printf("GLM_ARCH_ARM ");
|
||||
if(GLM_ARCH & GLM_ARCH_AVX2)
|
||||
std::printf("GLM_ARCH_AVX2 ");
|
||||
if(GLM_ARCH & GLM_ARCH_AVX)
|
||||
std::printf("GLM_ARCH_AVX ");
|
||||
if(GLM_ARCH & GLM_ARCH_AVX)
|
||||
std::printf("GLM_ARCH_SSE4 ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSE3)
|
||||
std::printf("GLM_ARCH_SSE3 ");
|
||||
if(GLM_ARCH & GLM_ARCH_SSE2)
|
||||
std::printf("GLM_ARCH_SSE2 ");
|
||||
|
||||
std::printf("\n");
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_cpp_version()
|
||||
{
|
||||
std::printf("__cplusplus: %ld\n", __cplusplus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_operators()
|
||||
{
|
||||
glm::vec3 A(1.0f);
|
||||
glm::vec3 B(1.0f);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct vec
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
template <template <typename> class C, typename T>
|
||||
struct Class
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Class<vec, T>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
//Class<vec, float> C;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += test_cpp_version();
|
||||
Error += test_compiler();
|
||||
Error += test_model();
|
||||
Error += test_instruction_set();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
89
external/glm/test/core/core_setup_precision.cpp
vendored
Normal file
89
external/glm/test/core/core_setup_precision.cpp
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_setup_precision.cpp
|
||||
/// @date 2011-05-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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;
|
||||
}
|
||||
175
external/glm/test/core/core_type_cast.cpp
vendored
Normal file
175
external/glm/test/core/core_type_cast.cpp
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_cast.cpp
|
||||
/// @date 2013-05-06 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(D, H)) ? 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)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(D, H)) ? 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)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(D, H)) ? 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;
|
||||
}
|
||||
387
external/glm/test/core/core_type_ctor.cpp
vendored
Normal file
387
external/glm/test/core/core_type_ctor.cpp
vendored
Normal file
|
|
@ -0,0 +1,387 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_ctor.cpp
|
||||
/// @date 2015-07-25 / 2015-07-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_FORCE_NO_CTOR_INIT
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
int test_vec1_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# ifndef GLM_FORCE_NO_CTOR_INIT
|
||||
{
|
||||
glm::vec4 A;
|
||||
glm::vec4 B(0);
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_FORCE_NO_CTOR_INIT
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat2x2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat2x2(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec2(1, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat2x3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat2x3(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec3(1, 0, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat2x4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
union pack
|
||||
{
|
||||
glm::mat2x4 f;
|
||||
glm::mat2x4 i;
|
||||
} A, B;
|
||||
|
||||
A.f = glm::mat2x4(0);
|
||||
Error += glm::all(glm::equal(A.i[0], glm::vec4(0))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat2x4(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec4(1, 0, 0, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat3x2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat3x2(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec2(1, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat3x3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat3x3(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec3(1, 0, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat3x4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat3x4(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec4(1, 0, 0, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat4x2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat4x2(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec2(1, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat4x3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat4x3(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec3(1, 0, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_mat4x4_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::mat4(1);
|
||||
Error += glm::all(glm::equal(B.i[0], glm::vec4(1, 0, 0, 0))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_quat_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_DEFAULTED_FUNCTIONS && defined(GLM_FORCE_NO_CTOR_INIT)
|
||||
{
|
||||
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))) ? 0 : 1;
|
||||
|
||||
B.f = glm::quat(1, 1, 1, 1);
|
||||
Error += glm::all(glm::equal(B.i, glm::quat(1, 1, 1, 1))) ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_HAS_DEFAULTED_FUNCTIONS
|
||||
|
||||
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;
|
||||
}
|
||||
62
external/glm/test/core/core_type_float.cpp
vendored
Normal file
62
external/glm/test/core/core_type_float.cpp
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_float.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
int test_float_size()
|
||||
{
|
||||
return
|
||||
sizeof(glm::float_t) != sizeof(glm::lowp_float) &&
|
||||
sizeof(glm::float_t) != sizeof(glm::mediump_float) &&
|
||||
sizeof(glm::float_t) != sizeof(glm::highp_float);
|
||||
}
|
||||
|
||||
int test_float_precision()
|
||||
{
|
||||
return (
|
||||
sizeof(glm::lowp_float) <= sizeof(glm::mediump_float) &&
|
||||
sizeof(glm::mediump_float) <= sizeof(glm::highp_float)) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_vec2()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_float_size();
|
||||
Error += test_float_precision();
|
||||
|
||||
return Error;
|
||||
}
|
||||
74
external/glm/test/core/core_type_int.cpp
vendored
Normal file
74
external/glm/test/core/core_type_int.cpp
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_int.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
int test_int_size()
|
||||
{
|
||||
return
|
||||
sizeof(glm::int_t) != sizeof(glm::lowp_int) &&
|
||||
sizeof(glm::int_t) != sizeof(glm::mediump_int) &&
|
||||
sizeof(glm::int_t) != sizeof(glm::highp_int);
|
||||
}
|
||||
|
||||
int test_uint_size()
|
||||
{
|
||||
return
|
||||
sizeof(glm::uint_t) != sizeof(glm::lowp_uint) &&
|
||||
sizeof(glm::uint_t) != sizeof(glm::mediump_uint) &&
|
||||
sizeof(glm::uint_t) != sizeof(glm::highp_uint);
|
||||
}
|
||||
|
||||
int test_int_precision()
|
||||
{
|
||||
return (
|
||||
sizeof(glm::lowp_int) <= sizeof(glm::mediump_int) &&
|
||||
sizeof(glm::mediump_int) <= sizeof(glm::highp_int)) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_uint_precision()
|
||||
{
|
||||
return (
|
||||
sizeof(glm::lowp_uint) <= sizeof(glm::mediump_uint) &&
|
||||
sizeof(glm::mediump_uint) <= sizeof(glm::highp_uint)) ? 0 : 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_int_size();
|
||||
Error += test_int_precision();
|
||||
Error += test_uint_size();
|
||||
Error += test_uint_precision();
|
||||
|
||||
return Error;
|
||||
}
|
||||
110
external/glm/test/core/core_type_length.cpp
vendored
Normal file
110
external/glm/test/core/core_type_length.cpp
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_length.cpp
|
||||
/// @date 2011-05-25 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.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;
|
||||
|
||||
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;
|
||||
|
||||
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::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;
|
||||
}
|
||||
|
||||
116
external/glm/test/core/core_type_length_size.cpp
vendored
Normal file
116
external/glm/test/core/core_type_length_size.cpp
vendored
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_length_size.cpp
|
||||
/// @date 2011-05-25 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_FORCE_SIZE_FUNC
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
|
||||
int test_length_mat_non_squared()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::mat2x3().size() == 2 ? 0 : 1;
|
||||
Error += glm::mat2x4().size() == 2 ? 0 : 1;
|
||||
Error += glm::mat3x2().size() == 3 ? 0 : 1;
|
||||
Error += glm::mat3x4().size() == 3 ? 0 : 1;
|
||||
Error += glm::mat4x2().size() == 4 ? 0 : 1;
|
||||
Error += glm::mat4x3().size() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::dmat2x3().size() == 2 ? 0 : 1;
|
||||
Error += glm::dmat2x4().size() == 2 ? 0 : 1;
|
||||
Error += glm::dmat3x2().size() == 3 ? 0 : 1;
|
||||
Error += glm::dmat3x4().size() == 3 ? 0 : 1;
|
||||
Error += glm::dmat4x2().size() == 4 ? 0 : 1;
|
||||
Error += glm::dmat4x3().size() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_length_mat()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::mat2().size() == 2 ? 0 : 1;
|
||||
Error += glm::mat3().size() == 3 ? 0 : 1;
|
||||
Error += glm::mat4().size() == 4 ? 0 : 1;
|
||||
Error += glm::mat2x2().size() == 2 ? 0 : 1;
|
||||
Error += glm::mat3x3().size() == 3 ? 0 : 1;
|
||||
Error += glm::mat4x4().size() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::dmat2().size() == 2 ? 0 : 1;
|
||||
Error += glm::dmat3().size() == 3 ? 0 : 1;
|
||||
Error += glm::dmat4().size() == 4 ? 0 : 1;
|
||||
Error += glm::dmat2x2().size() == 2 ? 0 : 1;
|
||||
Error += glm::dmat3x3().size() == 3 ? 0 : 1;
|
||||
Error += glm::dmat4x4().size() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_length_vec()
|
||||
{
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::vec1().size() == 1 ? 0 : 1;
|
||||
Error += glm::vec2().size() == 2 ? 0 : 1;
|
||||
Error += glm::vec3().size() == 3 ? 0 : 1;
|
||||
Error += glm::vec4().size() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::ivec1().size() == 1 ? 0 : 1;
|
||||
Error += glm::ivec2().size() == 2 ? 0 : 1;
|
||||
Error += glm::ivec3().size() == 3 ? 0 : 1;
|
||||
Error += glm::ivec4().size() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::uvec1().size() == 1 ? 0 : 1;
|
||||
Error += glm::uvec2().size() == 2 ? 0 : 1;
|
||||
Error += glm::uvec3().size() == 3 ? 0 : 1;
|
||||
Error += glm::uvec4().size() == 4 ? 0 : 1;
|
||||
|
||||
Error += glm::dvec1().size() == 1 ? 0 : 1;
|
||||
Error += glm::dvec2().size() == 2 ? 0 : 1;
|
||||
Error += glm::dvec3().size() == 3 ? 0 : 1;
|
||||
Error += glm::dvec4().size() == 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;
|
||||
}
|
||||
|
||||
181
external/glm/test/core/core_type_mat2x2.cpp
vendored
Normal file
181
external/glm/test/core/core_type_mat2x2.cpp
vendored
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat2x2.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/gtc/epsilon.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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(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::epsilonEqual(Identity[0], glm::vec2(1.0f, 0.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec2(0.0f, 1.0f), glm::vec2(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat2::rows == glm::mat2::row_type::components);
|
||||
assert(glm::mat2::cols == glm::mat2::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
Error += test_inverse();
|
||||
|
||||
return Error;
|
||||
}
|
||||
154
external/glm/test/core/core_type_mat2x3.cpp
vendored
Normal file
154
external/glm/test/core/core_type_mat2x3.cpp
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat2x3.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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_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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat2x3::rows == glm::mat2x3::row_type::components);
|
||||
assert(glm::mat2x3::cols == glm::mat2x3::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
157
external/glm/test/core/core_type_mat2x4.cpp
vendored
Normal file
157
external/glm/test/core/core_type_mat2x4.cpp
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat2x4.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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_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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat2x4::rows == glm::mat2x4::row_type::components);
|
||||
assert(glm::mat2x4::cols == glm::mat2x4::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
160
external/glm/test/core/core_type_mat3x2.cpp
vendored
Normal file
160
external/glm/test/core/core_type_mat3x2.cpp
vendored
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat3x2.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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 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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat3x2::rows == glm::mat3x2::row_type::components);
|
||||
assert(glm::mat3x2::cols == glm::mat3x2::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
220
external/glm/test/core/core_type_mat3x3.cpp
vendored
Normal file
220
external/glm/test/core/core_type_mat3x3.cpp
vendored
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat3x3.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/gtc/epsilon.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 <cstdio>
|
||||
#include <vector>
|
||||
|
||||
void print(glm::dmat3 const & Mat0)
|
||||
{
|
||||
printf("mat3(\n");
|
||||
printf("\tvec3(%2.3f, %2.3f, %2.3f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2]);
|
||||
printf("\tvec3(%2.3f, %2.3f, %2.3f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2]);
|
||||
printf("\tvec3(%2.3f, %2.3f, %2.3f))\n\n", Mat0[2][0], Mat0[2][1], Mat0[2][2]);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
print(Mat0);
|
||||
print(Inv0);
|
||||
print(Res0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
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::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(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::epsilonEqual(Identity[0], glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat3::rows == glm::mat3::row_type::components);
|
||||
assert(glm::mat3::cols == glm::mat3::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_mat3x3();
|
||||
Error += test_operators();
|
||||
Error += test_inverse();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
159
external/glm/test/core/core_type_mat3x4.cpp
vendored
Normal file
159
external/glm/test/core/core_type_mat3x4.cpp
vendored
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat3x4.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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 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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat3x4::rows == glm::mat3x4::row_type::components);
|
||||
assert(glm::mat3x4::cols == glm::mat3x4::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
163
external/glm/test/core/core_type_mat4x2.cpp
vendored
Normal file
163
external/glm/test/core/core_type_mat4x2.cpp
vendored
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat4x2.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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_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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat4x2::rows == glm::mat4x2::row_type::components);
|
||||
assert(glm::mat4x2::cols == glm::mat4x2::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
164
external/glm/test/core/core_type_mat4x3.cpp
vendored
Normal file
164
external/glm/test/core/core_type_mat4x3.cpp
vendored
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat4x3.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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_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 = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
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}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 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);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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 main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat4x3::rows == glm::mat4x3::row_type::components);
|
||||
assert(glm::mat4x3::cols == glm::mat4x3::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_operators();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
350
external/glm/test/core/core_type_mat4x4.cpp
vendored
Normal file
350
external/glm/test/core/core_type_mat4x4.cpp
vendored
Normal file
|
|
@ -0,0 +1,350 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_mat4x4.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_SIMD
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/matrix.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 <cstdio>
|
||||
#include <vector>
|
||||
|
||||
|
||||
template <typename genType>
|
||||
void print(genType const & Mat0)
|
||||
{
|
||||
printf("mat4(\n");
|
||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]);
|
||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]);
|
||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]);
|
||||
printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]);
|
||||
}
|
||||
|
||||
int test_inverse_mat4x4()
|
||||
{
|
||||
glm::mat4 Mat0(
|
||||
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));
|
||||
glm::mat4 Inv0 = glm::inverse(Mat0);
|
||||
glm::mat4 Res0 = Mat0 * Inv0;
|
||||
|
||||
print(Mat0);
|
||||
print(Inv0);
|
||||
print(Res0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_inverse_dmat4x4()
|
||||
{
|
||||
glm::dmat4 Mat0(
|
||||
glm::dvec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||
glm::dvec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||
glm::dvec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||
glm::dvec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||
glm::dmat4 Inv0 = glm::inverse(Mat0);
|
||||
glm::dmat4 Res0 = Mat0 * Inv0;
|
||||
|
||||
print(Mat0);
|
||||
print(Inv0);
|
||||
print(Res0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool test_operators()
|
||||
{
|
||||
glm::mat4x4 l(1.0f);
|
||||
glm::mat4x4 m(1.0f);
|
||||
glm::vec4 u(1.0f);
|
||||
glm::vec4 v(1.0f);
|
||||
float x = 1.0f;
|
||||
glm::vec4 a = m * u;
|
||||
glm::vec4 b = v * m;
|
||||
glm::mat4x4 n = x / m;
|
||||
glm::mat4x4 o = m / x;
|
||||
glm::mat4x4 p = x * m;
|
||||
glm::mat4x4 q = m * x;
|
||||
bool R = m != q;
|
||||
bool S = m == l;
|
||||
|
||||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
int test_inverse()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
{
|
||||
glm::mat4 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));
|
||||
glm::mat4 const Inverse = glm::inverse(Matrix);
|
||||
glm::mat4 const Identity = Matrix * Inverse;
|
||||
|
||||
print(Matrix);
|
||||
print(Inverse);
|
||||
print(Identity);
|
||||
|
||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::highp_mat4 const Matrix(
|
||||
glm::highp_vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||
glm::highp_vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||
glm::highp_vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||
glm::highp_vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||
glm::highp_mat4 const Inverse = glm::inverse(Matrix);
|
||||
glm::highp_mat4 const Identity = Matrix * Inverse;
|
||||
|
||||
printf("highp_mat4 inverse\n");
|
||||
print(Matrix);
|
||||
print(Inverse);
|
||||
print(Identity);
|
||||
|
||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::highp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::highp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::highp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::highp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::highp_vec4(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mediump_mat4 const Matrix(
|
||||
glm::mediump_vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||
glm::mediump_vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||
glm::mediump_vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||
glm::mediump_vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||
glm::mediump_mat4 const Inverse = glm::inverse(Matrix);
|
||||
glm::mediump_mat4 const Identity = Matrix * Inverse;
|
||||
|
||||
printf("mediump_mat4 inverse\n");
|
||||
print(Matrix);
|
||||
print(Inverse);
|
||||
print(Identity);
|
||||
|
||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::mediump_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::mediump_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::mediump_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::mediump_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::mediump_vec4(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::lowp_mat4 const Matrix(
|
||||
glm::lowp_vec4(0.6f, 0.2f, 0.3f, 0.4f),
|
||||
glm::lowp_vec4(0.2f, 0.7f, 0.5f, 0.3f),
|
||||
glm::lowp_vec4(0.3f, 0.5f, 0.7f, 0.2f),
|
||||
glm::lowp_vec4(0.4f, 0.3f, 0.2f, 0.6f));
|
||||
glm::lowp_mat4 const Inverse = glm::inverse(Matrix);
|
||||
glm::lowp_mat4 const Identity = Matrix * Inverse;
|
||||
|
||||
printf("lowp_mat4 inverse\n");
|
||||
print(Matrix);
|
||||
print(Inverse);
|
||||
print(Identity);
|
||||
|
||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::lowp_vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::lowp_vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::lowp_vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::lowp_vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::lowp_vec4(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4 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));
|
||||
glm::mat4 const Identity = Matrix / Matrix;
|
||||
|
||||
Error += glm::all(glm::epsilonEqual(Identity[0], glm::vec4(1.0f, 0.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[1], glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[2], glm::vec4(0.0f, 0.0f, 1.0f, 0.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(Identity[3], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.01f))) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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 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 V{0, 1, 2, 3};
|
||||
|
||||
glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
|
||||
glm::mat4 m2{
|
||||
{0, 1, 2, 3},
|
||||
{4, 5, 6, 7},
|
||||
{8, 9, 10, 11},
|
||||
{12, 13, 14, 15}};
|
||||
|
||||
for(glm::length_t i = 0; i < m0.length(); ++i)
|
||||
Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1;
|
||||
|
||||
for(glm::length_t i = 0; i < m1.length(); ++i)
|
||||
Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1;
|
||||
|
||||
std::vector<glm::mat4> 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}};
|
||||
|
||||
std::vector<glm::mat4> 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> 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;
|
||||
}
|
||||
|
||||
int perf_mul()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template <typename genType>
|
||||
int entry()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType A(1.0f);
|
||||
glm::mat4x4 B(A);
|
||||
glm::mat4x4 Identity(1.0f);
|
||||
|
||||
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
|
||||
Error += glm::all(glm::equal(B[i], Identity[i])) ? 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
|
||||
|
||||
struct repro
|
||||
{
|
||||
repro(){ this->matrix = new glm::mat4(); }
|
||||
~repro(){delete this->matrix;}
|
||||
|
||||
glm::mat4* matrix;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
repro Repro;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::mat4::rows == glm::mat4::row_type::components);
|
||||
assert(glm::mat4::cols == glm::mat4::col_type::components);
|
||||
#endif
|
||||
|
||||
Error += cast::test();
|
||||
Error += test_ctr();
|
||||
Error += test_inverse_dmat4x4();
|
||||
Error += test_inverse_mat4x4();
|
||||
Error += test_operators();
|
||||
Error += test_inverse();
|
||||
|
||||
Error += perf_mul();
|
||||
|
||||
return Error;
|
||||
}
|
||||
187
external/glm/test/core/core_type_vec1.cpp
vendored
Normal file
187
external/glm/test/core/core_type_vec1.cpp
vendored
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_vec1.cpp
|
||||
/// @date 2014-10-11 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
# define GLM_META_PROG_HELPERS
|
||||
#endif
|
||||
#define GLM_SWIZZLE
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <vector>
|
||||
|
||||
int test_vec1_operators()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::vec1 A(1.0f);
|
||||
glm::vec1 B(1.0f);
|
||||
{
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
A *= 1.0f;
|
||||
B *= 1.0;
|
||||
A += 1.0f;
|
||||
B += 1.0;
|
||||
|
||||
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
|
||||
*/
|
||||
#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
{
|
||||
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 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
}
|
||||
#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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::components == 1 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec1 v;
|
||||
assert(v.length() == 1);
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::vec1::components == glm::vec1().length());
|
||||
assert(glm::vec1::components == 1);
|
||||
# endif
|
||||
|
||||
Error += test_vec1_size();
|
||||
Error += test_vec1_ctor();
|
||||
Error += test_vec1_operators();
|
||||
Error += test_vec1_operator_increment();
|
||||
|
||||
return Error;
|
||||
}
|
||||
352
external/glm/test/core/core_type_vec2.cpp
vendored
Normal file
352
external/glm/test/core/core_type_vec2.cpp
vendored
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_vec2.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
# define GLM_META_PROG_HELPERS
|
||||
#endif
|
||||
#define GLM_SWIZZLE
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <vector>
|
||||
#if GLM_HAS_TRIVIAL_QUERIES
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
int test_vec2_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 B(1.0f);
|
||||
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 += A.x == 2.0f && A.y == 2.0f ? 0 : 1;
|
||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 B(2.0f,-1.0f);
|
||||
glm::vec2 C = A + B;
|
||||
A += B;
|
||||
Error += A.x == 3.0f && A.y == 0.0f ? 0 : 1;
|
||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 C = A - 1.0f;
|
||||
A -= 1.0f;
|
||||
Error += A.x == 0.0f && A.y == 0.0f ? 0 : 1;
|
||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 B(2.0f,-1.0f);
|
||||
glm::vec2 C = A - B;
|
||||
A -= B;
|
||||
Error += A.x == -1.0f && A.y == 2.0f ? 0 : 1;
|
||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f);
|
||||
glm::vec2 C = A * 2.0f;
|
||||
A *= 2.0f;
|
||||
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1;
|
||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(2.0f);
|
||||
glm::vec2 B(2.0f);
|
||||
glm::vec2 C = A / B;
|
||||
A /= B;
|
||||
Error += A.x == 1.0f && A.y == 1.0f ? 0 : 1;
|
||||
Error += A.x == C.x && A.y == C.y ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
glm::vec2 C = A + B;
|
||||
Error += C == glm::vec2(5, 7) ? 0 : 1;
|
||||
|
||||
glm::vec2 D = B - A;
|
||||
Error += D == glm::vec2(3, 3) ? 0 : 1;
|
||||
|
||||
glm::vec2 E = A * B;
|
||||
Error += E == glm::vec2(4, 10) ? 0 : 1;
|
||||
|
||||
glm::vec2 F = B / A;
|
||||
Error += F == glm::vec2(4, 2.5) ? 0 : 1;
|
||||
|
||||
glm::vec2 G = A + 1.0f;
|
||||
Error += G == glm::vec2(2, 3) ? 0 : 1;
|
||||
|
||||
glm::vec2 H = B - 1.0f;
|
||||
Error += H == glm::vec2(3, 4) ? 0 : 1;
|
||||
|
||||
glm::vec2 I = A * 2.0f;
|
||||
Error += I == glm::vec2(2, 4) ? 0 : 1;
|
||||
|
||||
glm::vec2 J = B / 2.0f;
|
||||
Error += J == glm::vec2(2, 2.5) ? 0 : 1;
|
||||
|
||||
glm::vec2 K = 1.0f + A;
|
||||
Error += K == glm::vec2(2, 3) ? 0 : 1;
|
||||
|
||||
glm::vec2 L = 1.0f - B;
|
||||
Error += L == glm::vec2(-3, -4) ? 0 : 1;
|
||||
|
||||
glm::vec2 M = 2.0f * A;
|
||||
Error += M == glm::vec2(2, 4) ? 0 : 1;
|
||||
|
||||
glm::vec2 N = 2.0f / B;
|
||||
Error += N == glm::vec2(0.5, 2.0 / 5.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
A += B;
|
||||
Error += A == glm::vec2(5, 7) ? 0 : 1;
|
||||
|
||||
A += 1.0f;
|
||||
Error += A == glm::vec2(6, 8) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::vec2(3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1.0f;
|
||||
Error += B == glm::vec2(2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::vec2(4, 10) ? 0 : 1;
|
||||
|
||||
A *= 2.0f;
|
||||
Error += A == glm::vec2(8, 20) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B(4.0f, 5.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::vec2(4, 2.5) ? 0 : 1;
|
||||
|
||||
B /= 2.0f;
|
||||
Error += B == glm::vec2(2, 1.25) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec2 B(2.0f);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::vec2(1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B = -A;
|
||||
Error += B == glm::vec2(-1.0f, -2.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B = --A;
|
||||
Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B = A--;
|
||||
Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1;
|
||||
Error += A == glm::vec2(0.0f, 1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B = ++A;
|
||||
Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec2 A(1.0f, 2.0f);
|
||||
glm::vec2 B = A++;
|
||||
Error += B == glm::vec2(1.0f, 2.0f) ? 0 : 1;
|
||||
Error += A == glm::vec2(2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec2_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec2 A(1);
|
||||
glm::vec2 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
|
||||
|
||||
#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
{
|
||||
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 : 1;
|
||||
Error += glm::all(glm::equal(A, C)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(A, D)) ? 0 : 1;
|
||||
}
|
||||
#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int test_vec2_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::components == 2 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec2 v;
|
||||
assert(v.length() == 2);
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::vec2::components == glm::vec2().length());
|
||||
assert(glm::vec2::components == 2);
|
||||
# endif
|
||||
|
||||
Error += test_vec2_size();
|
||||
Error += test_vec2_ctor();
|
||||
Error += test_vec2_operators();
|
||||
Error += test_operator_increment();
|
||||
|
||||
return Error;
|
||||
}
|
||||
519
external/glm/test/core/core_type_vec3.cpp
vendored
Normal file
519
external/glm/test/core/core_type_vec3.cpp
vendored
Normal file
|
|
@ -0,0 +1,519 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_vec3.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
# define GLM_META_PROG_HELPERS
|
||||
#endif
|
||||
#define GLM_SWIZZLE
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/geometric.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
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
|
||||
|
||||
#if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
|
||||
{
|
||||
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)) ? 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;
|
||||
}
|
||||
#endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE))
|
||||
|
||||
{
|
||||
glm::vec3 A(1);
|
||||
glm::vec3 B(1, 1, 1);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::vec3> Tests;
|
||||
Tests.push_back(glm::vec3(glm::vec2(1, 2), 3));
|
||||
Tests.push_back(glm::vec3(1, glm::vec2(2, 3)));
|
||||
Tests.push_back(glm::vec3(1, 2, 3));
|
||||
Tests.push_back(glm::vec3(glm::vec4(1, 2, 3, 4)));
|
||||
|
||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
||||
Error += Tests[i] == glm::vec3(1, 2, 3) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f);
|
||||
glm::vec3 B(1.0f);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
glm::vec3 C = A + B;
|
||||
Error += C == glm::vec3(5, 7, 9) ? 0 : 1;
|
||||
|
||||
glm::vec3 D = B - A;
|
||||
Error += D == glm::vec3(3, 3, 3) ? 0 : 1;
|
||||
|
||||
glm::vec3 E = A * B;
|
||||
Error += E == glm::vec3(4, 10, 18) ? 0 : 1;
|
||||
|
||||
glm::vec3 F = B / A;
|
||||
Error += F == glm::vec3(4, 2.5, 2) ? 0 : 1;
|
||||
|
||||
glm::vec3 G = A + 1.0f;
|
||||
Error += G == glm::vec3(2, 3, 4) ? 0 : 1;
|
||||
|
||||
glm::vec3 H = B - 1.0f;
|
||||
Error += H == glm::vec3(3, 4, 5) ? 0 : 1;
|
||||
|
||||
glm::vec3 I = A * 2.0f;
|
||||
Error += I == glm::vec3(2, 4, 6) ? 0 : 1;
|
||||
|
||||
glm::vec3 J = B / 2.0f;
|
||||
Error += J == glm::vec3(2, 2.5, 3) ? 0 : 1;
|
||||
|
||||
glm::vec3 K = 1.0f + A;
|
||||
Error += K == glm::vec3(2, 3, 4) ? 0 : 1;
|
||||
|
||||
glm::vec3 L = 1.0f - B;
|
||||
Error += L == glm::vec3(-3, -4, -5) ? 0 : 1;
|
||||
|
||||
glm::vec3 M = 2.0f * A;
|
||||
Error += M == glm::vec3(2, 4, 6) ? 0 : 1;
|
||||
|
||||
glm::vec3 N = 2.0f / B;
|
||||
Error += N == glm::vec3(0.5, 2.0 / 5.0, 2.0 / 6.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
A += B;
|
||||
Error += A == glm::vec3(5, 7, 9) ? 0 : 1;
|
||||
|
||||
A += 1.0f;
|
||||
Error += A == glm::vec3(6, 8, 10) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::vec3(3, 3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1.0f;
|
||||
Error += B == glm::vec3(2, 2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::vec3(4, 10, 18) ? 0 : 1;
|
||||
|
||||
A *= 2.0f;
|
||||
Error += A == glm::vec3(8, 20, 36) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B(4.0f, 5.0f, 6.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::vec3(4, 2.5, 2) ? 0 : 1;
|
||||
|
||||
B /= 2.0f;
|
||||
Error += B == glm::vec3(2, 1.25, 1) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec3 B(2.0f);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::vec3(1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = -A;
|
||||
Error += B == glm::vec3(-1.0f, -2.0f, -3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = --A;
|
||||
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A--;
|
||||
Error += B == glm::vec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
Error += A == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = ++A;
|
||||
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 A(1.0f, 2.0f, 3.0f);
|
||||
glm::vec3 B = A++;
|
||||
Error += B == glm::vec3(1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
Error += A == glm::vec3(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::components == 3 ? 0 : 1;
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle3_2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec2 u;
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
// 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.0f && u.y == 1.0f) ? 0 : 1;
|
||||
u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1;
|
||||
u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1;
|
||||
u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1;
|
||||
u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1;
|
||||
u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1;
|
||||
u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1;
|
||||
u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1;
|
||||
u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1;
|
||||
|
||||
u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1;
|
||||
u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1;
|
||||
u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1;
|
||||
u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1;
|
||||
u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1;
|
||||
u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1;
|
||||
u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1;
|
||||
u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1;
|
||||
u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1;
|
||||
|
||||
u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1;
|
||||
u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1;
|
||||
u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1;
|
||||
u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1;
|
||||
u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1;
|
||||
u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1;
|
||||
u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1;
|
||||
u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1;
|
||||
u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1;
|
||||
// Mixed member aliases are not valid
|
||||
//u = v.rx; //Illegal
|
||||
//u = v.sy; //Illegal
|
||||
|
||||
u = glm::vec2(1, 2);
|
||||
v = glm::vec3(1, 2, 3);
|
||||
//v.xx = u; //Illegal
|
||||
v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1;
|
||||
v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1;
|
||||
v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
|
||||
//v.yy = u; //Illegal
|
||||
v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1;
|
||||
v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1;
|
||||
v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1;
|
||||
//v.zz = u; //Illegal
|
||||
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle3_3()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec3 u;
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
|
||||
u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
|
||||
u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1;
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 q, u, v;
|
||||
|
||||
u = glm::vec3(1, 2, 3);
|
||||
v = glm::vec3(10, 20, 30);
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
// 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::vec3(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;
|
||||
|
||||
// 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 q, u, v;
|
||||
u = glm::vec3(1, 2, 3);
|
||||
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, t;
|
||||
s = glm::vec4(1, 2, 3, 4);
|
||||
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;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 A(1, 2, 3);
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
{
|
||||
glm::vec3 B(A.xy, 3.0f);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 B(1.0f, A.yz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec3 B(A.xyz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 v;
|
||||
assert(v.length() == 3);
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::vec3::components == glm::vec3().length());
|
||||
assert(glm::vec3::components == 3);
|
||||
# endif
|
||||
|
||||
Error += test_vec3_ctor();
|
||||
Error += test_vec3_operators();
|
||||
Error += test_vec3_size();
|
||||
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();
|
||||
Error += test_operator_increment();
|
||||
|
||||
return Error;
|
||||
}
|
||||
498
external/glm/test/core/core_type_vec4.cpp
vendored
Normal file
498
external/glm/test/core/core_type_vec4.cpp
vendored
Normal file
|
|
@ -0,0 +1,498 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// OpenGL Mathematics (glm.g-truc.net)
|
||||
///
|
||||
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
|
||||
/// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
/// of this software and associated documentation files (the "Software"), to deal
|
||||
/// in the Software without restriction, including without limitation the rights
|
||||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
/// copies of the Software, and to permit persons to whom the Software is
|
||||
/// furnished to do so, subject to the following conditions:
|
||||
///
|
||||
/// The above copyright notice and this permission notice shall be included in
|
||||
/// all copies or substantial portions of the Software.
|
||||
///
|
||||
/// Restrictions:
|
||||
/// By making use of the Software for military purposes, you choose to make
|
||||
/// a Bunny unhappy.
|
||||
///
|
||||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @file test/core/core_type_vec4.cpp
|
||||
/// @date 2008-08-31 / 2014-11-25
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
# define GLM_META_PROG_HELPERS
|
||||
#endif
|
||||
#define GLM_SWIZZLE
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <glm/vec4.hpp>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
|
||||
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);
|
||||
//}
|
||||
|
||||
|
||||
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_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
{
|
||||
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)) ? 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_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
|
||||
{
|
||||
glm::vec4 A(1);
|
||||
glm::vec4 B(1, 1, 1, 1);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<glm::vec4> Tests;
|
||||
Tests.push_back(glm::vec4(glm::vec2(1, 2), 3, 4));
|
||||
Tests.push_back(glm::vec4(1, glm::vec2(2, 3), 4));
|
||||
Tests.push_back(glm::vec4(1, 2, glm::vec2(3, 4)));
|
||||
Tests.push_back(glm::vec4(glm::vec3(1, 2, 3), 4));
|
||||
Tests.push_back(glm::vec4(1, glm::vec3(2, 3, 4)));
|
||||
Tests.push_back(glm::vec4(glm::vec2(1, 2), glm::vec2(3, 4)));
|
||||
Tests.push_back(glm::vec4(1, 2, 3, 4));
|
||||
Tests.push_back(glm::vec4(glm::vec4(1, 2, 3, 4)));
|
||||
|
||||
for(std::size_t i = 0; i < Tests.size(); ++i)
|
||||
Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec4_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f);
|
||||
glm::vec4 B(1.0f);
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
glm::vec4 C = A + B;
|
||||
Error += C == glm::vec4(5, 7, 9, 11) ? 0 : 1;
|
||||
|
||||
glm::vec4 D = B - A;
|
||||
Error += D == glm::vec4(3, 3, 3, 3) ? 0 : 1;
|
||||
|
||||
glm::vec4 E = A * B;
|
||||
Error += E == glm::vec4(4, 10, 18, 28) ? 0 : 1;
|
||||
|
||||
glm::vec4 F = B / A;
|
||||
Error += F == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
|
||||
|
||||
glm::vec4 G = A + 1.0f;
|
||||
Error += G == glm::vec4(2, 3, 4, 5) ? 0 : 1;
|
||||
|
||||
glm::vec4 H = B - 1.0f;
|
||||
Error += H == glm::vec4(3, 4, 5, 6) ? 0 : 1;
|
||||
|
||||
glm::vec4 I = A * 2.0f;
|
||||
Error += I == glm::vec4(2, 4, 6, 8) ? 0 : 1;
|
||||
|
||||
glm::vec4 J = B / 2.0f;
|
||||
Error += J == glm::vec4(2, 2.5, 3, 3.5) ? 0 : 1;
|
||||
|
||||
glm::vec4 K = 1.0f + A;
|
||||
Error += K == glm::vec4(2, 3, 4, 5) ? 0 : 1;
|
||||
|
||||
glm::vec4 L = 1.0f - B;
|
||||
Error += L == glm::vec4(-3, -4, -5, -6) ? 0 : 1;
|
||||
|
||||
glm::vec4 M = 2.0f * A;
|
||||
Error += M == glm::vec4(2, 4, 6, 8) ? 0 : 1;
|
||||
|
||||
glm::vec4 N = 2.0f / B;
|
||||
Error += N == glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
A += B;
|
||||
Error += A == glm::vec4(5, 7, 9, 11) ? 0 : 1;
|
||||
|
||||
A += 1.0f;
|
||||
Error += A == glm::vec4(6, 8, 10, 12) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
B -= A;
|
||||
Error += B == glm::vec4(3, 3, 3, 3) ? 0 : 1;
|
||||
|
||||
B -= 1.0f;
|
||||
Error += B == glm::vec4(2, 2, 2, 2) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
A *= B;
|
||||
Error += A == glm::vec4(4, 10, 18, 28) ? 0 : 1;
|
||||
|
||||
A *= 2.0f;
|
||||
Error += A == glm::vec4(8, 20, 36, 56) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
|
||||
|
||||
B /= A;
|
||||
Error += B == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
|
||||
|
||||
B /= 2.0f;
|
||||
Error += B == glm::vec4(2, 1.25, 1, 7.0f / 4.0f / 2.0f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(2.0f);
|
||||
|
||||
B /= B.y;
|
||||
Error += B == glm::vec4(1.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = -A;
|
||||
Error += B == glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = --A;
|
||||
Error += B == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A--;
|
||||
Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
Error += A == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = ++A;
|
||||
Error += B == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
|
||||
glm::vec4 B = A++;
|
||||
Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1;
|
||||
Error += A == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int test_vec4_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
|
||||
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE_RELAX)
|
||||
{
|
||||
glm::vec4 B(A.xy, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(A.xy, 3.0f, 4.0f);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(1.0f, A.yz, 4.0f);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(1.0f, 2.0f, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::vec4 B(A.xyz, 4.0f);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::vec4 B(1.0f, A.yzw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
int test_vec4_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: %ld\n", EndTime - StartTime);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec4_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: %ld\n", EndTime - StartTime);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
namespace heap
|
||||
{
|
||||
class A
|
||||
{
|
||||
float f;
|
||||
};
|
||||
|
||||
class B : public A
|
||||
{
|
||||
float g;
|
||||
glm::vec4 v;
|
||||
};
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
A* p = new B;
|
||||
delete p;
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace heap
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::vec4 v;
|
||||
assert(v.length() == 4);
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::vec4::components == glm::vec4().length());
|
||||
assert(glm::vec4::components == 4);
|
||||
# endif
|
||||
|
||||
# ifdef NDEBUG
|
||||
std::size_t const Size(1000000);
|
||||
Error += test_vec4_perf_AoS(Size);
|
||||
Error += test_vec4_perf_SoA(Size);
|
||||
# endif//NDEBUG
|
||||
|
||||
Error += test_vec4_ctor();
|
||||
Error += test_vec4_size();
|
||||
Error += test_vec4_operators();
|
||||
Error += test_vec4_swizzle_partial();
|
||||
Error += test_operator_increment();
|
||||
Error += heap::test();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue