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:
Simon Fels 2018-05-13 20:15:36 +02:00
commit 5070880428
846 changed files with 179358 additions and 1 deletions

19
external/glm/test/gtc/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,19 @@
glmCreateTestGTC(gtc_bitfield)
glmCreateTestGTC(gtc_color_space)
glmCreateTestGTC(gtc_constants)
glmCreateTestGTC(gtc_epsilon)
glmCreateTestGTC(gtc_integer)
glmCreateTestGTC(gtc_matrix_access)
glmCreateTestGTC(gtc_matrix_integer)
glmCreateTestGTC(gtc_matrix_inverse)
glmCreateTestGTC(gtc_matrix_transform)
glmCreateTestGTC(gtc_noise)
glmCreateTestGTC(gtc_packing)
glmCreateTestGTC(gtc_quaternion)
glmCreateTestGTC(gtc_random)
glmCreateTestGTC(gtc_round)
glmCreateTestGTC(gtc_reciprocal)
glmCreateTestGTC(gtc_type_precision)
glmCreateTestGTC(gtc_type_ptr)
glmCreateTestGTC(gtc_ulp)
glmCreateTestGTC(gtc_vec1)

675
external/glm/test/gtc/gtc_bitfield.cpp vendored Normal file
View file

@ -0,0 +1,675 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_bitfield.cpp
/// @date 2014-10-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/bitfield.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/vector_relational.hpp>
#if GLM_ARCH != GLM_ARCH_PURE
# include <glm/detail/intrinsic_integer.hpp>
#endif
#include <ctime>
#include <cstdio>
#include <vector>
namespace mask
{
template <typename genType>
struct type
{
genType Value;
genType Return;
};
inline int mask_zero(int Bits)
{
return ~((~0) << Bits);
}
inline int mask_mix(int Bits)
{
return Bits >= sizeof(int) * 8 ? 0xffffffff : (static_cast<int>(1) << Bits) - static_cast<int>(1);
}
inline int mask_half(int Bits)
{
// We do the shift in two steps because 1 << 32 on an int is undefined.
int const Half = Bits >> 1;
int const Fill = ~0;
int const ShiftHaft = (Fill << Half);
int const Rest = Bits - Half;
int const Reversed = ShiftHaft << Rest;
return ~Reversed;
}
inline int mask_loop(int Bits)
{
int Mask = 0;
for(int Bit = 0; Bit < Bits; ++Bit)
Mask |= (static_cast<int>(1) << Bit);
return Mask;
}
int perf()
{
int const Count = 100000000;
std::clock_t Timestamp1 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_mix(i % 32);
}
std::clock_t Timestamp2 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_loop(i % 32);
}
std::clock_t Timestamp3 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = glm::mask(i % 32);
}
std::clock_t Timestamp4 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_zero(i % 32);
}
std::clock_t Timestamp5 = std::clock();
{
std::vector<int> Mask;
Mask.resize(Count);
for(int i = 0; i < Count; ++i)
Mask[i] = mask_half(i % 32);
}
std::clock_t Timestamp6 = std::clock();
std::clock_t TimeMix = Timestamp2 - Timestamp1;
std::clock_t TimeLoop = Timestamp3 - Timestamp2;
std::clock_t TimeDefault = Timestamp4 - Timestamp3;
std::clock_t TimeZero = Timestamp5 - Timestamp4;
std::clock_t TimeHalf = Timestamp6 - Timestamp5;
printf("mask[mix]: %d\n", static_cast<unsigned int>(TimeMix));
printf("mask[loop]: %d\n", static_cast<unsigned int>(TimeLoop));
printf("mask[default]: %d\n", static_cast<unsigned int>(TimeDefault));
printf("mask[zero]: %d\n", static_cast<unsigned int>(TimeZero));
printf("mask[half]: %d\n", static_cast<unsigned int>(TimeHalf));
return TimeDefault < TimeLoop ? 0 : 1;
}
int test_uint()
{
type<glm::uint> const Data[] =
{
{ 0, 0x00000000},
{ 1, 0x00000001},
{ 2, 0x00000003},
{ 3, 0x00000007},
{31, 0x7fffffff},
{32, 0xffffffff}
};
int Error(0);
/* mask_zero is sadly not a correct code
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_zero(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
*/
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_mix(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_half(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_loop(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = glm::mask(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_uvec4()
{
type<glm::ivec4> const Data[] =
{
{glm::ivec4( 0), glm::ivec4(0x00000000)},
{glm::ivec4( 1), glm::ivec4(0x00000001)},
{glm::ivec4( 2), glm::ivec4(0x00000003)},
{glm::ivec4( 3), glm::ivec4(0x00000007)},
{glm::ivec4(31), glm::ivec4(0x7fffffff)},
{glm::ivec4(32), glm::ivec4(0xffffffff)}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::ivec4>); i < n; ++i)
{
glm::ivec4 Result = glm::mask(Data[i].Value);
Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_uint();
Error += test_uvec4();
return Error;
}
}//namespace mask
namespace bitfieldInterleave3
{
template <typename PARAM, typename RET>
inline RET refBitfieldInterleave(PARAM x, PARAM y, PARAM z)
{
RET Result = 0;
for(RET i = 0; i < sizeof(PARAM) * 8; ++i)
{
Result |= ((RET(x) & (RET(1U) << i)) << ((i << 1) + 0));
Result |= ((RET(y) & (RET(1U) << i)) << ((i << 1) + 1));
Result |= ((RET(z) & (RET(1U) << i)) << ((i << 1) + 2));
}
return Result;
}
int test()
{
int Error(0);
glm::uint16 x_max = 1 << 11;
glm::uint16 y_max = 1 << 11;
glm::uint16 z_max = 1 << 11;
for(glm::uint16 z = 0; z < z_max; z += 27)
for(glm::uint16 y = 0; y < y_max; y += 27)
for(glm::uint16 x = 0; x < x_max; x += 27)
{
glm::uint64 ResultA = refBitfieldInterleave<glm::uint16, glm::uint64>(x, y, z);
glm::uint64 ResultB = glm::bitfieldInterleave(x, y, z);
Error += ResultA == ResultB ? 0 : 1;
}
return Error;
}
}
namespace bitfieldInterleave4
{
template <typename PARAM, typename RET>
inline RET loopBitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w)
{
RET const v[4] = {x, y, z, w};
RET Result = 0;
for(RET i = 0; i < sizeof(PARAM) * 8; i++)
{
Result |= ((((v[0] >> i) & 1U)) << ((i << 2) + 0));
Result |= ((((v[1] >> i) & 1U)) << ((i << 2) + 1));
Result |= ((((v[2] >> i) & 1U)) << ((i << 2) + 2));
Result |= ((((v[3] >> i) & 1U)) << ((i << 2) + 3));
}
return Result;
}
int test()
{
int Error(0);
glm::uint16 x_max = 1 << 11;
glm::uint16 y_max = 1 << 11;
glm::uint16 z_max = 1 << 11;
glm::uint16 w_max = 1 << 11;
for(glm::uint16 w = 0; w < w_max; w += 27)
for(glm::uint16 z = 0; z < z_max; z += 27)
for(glm::uint16 y = 0; y < y_max; y += 27)
for(glm::uint16 x = 0; x < x_max; x += 27)
{
glm::uint64 ResultA = loopBitfieldInterleave<glm::uint16, glm::uint64>(x, y, z, w);
glm::uint64 ResultB = glm::bitfieldInterleave(x, y, z, w);
Error += ResultA == ResultB ? 0 : 1;
}
return Error;
}
}
namespace bitfieldInterleave
{
inline glm::uint64 fastBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
glm::uint64 REG1;
glm::uint64 REG2;
REG1 = x;
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
REG2 = y;
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
return REG1 | (REG2 << 1);
}
inline glm::uint64 interleaveBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
glm::uint64 REG1;
glm::uint64 REG2;
REG1 = x;
REG2 = y;
REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
return REG1 | (REG2 << 1);
}
inline glm::uint64 loopBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
static glm::uint64 const Mask[5] =
{
0x5555555555555555,
0x3333333333333333,
0x0F0F0F0F0F0F0F0F,
0x00FF00FF00FF00FF,
0x0000FFFF0000FFFF
};
glm::uint64 REG1 = x;
glm::uint64 REG2 = y;
for(int i = 4; i >= 0; --i)
{
REG1 = ((REG1 << (1 << i)) | REG1) & Mask[i];
REG2 = ((REG2 << (1 << i)) | REG2) & Mask[i];
}
return REG1 | (REG2 << 1);
}
#if(GLM_ARCH != GLM_ARCH_PURE)
inline glm::uint64 sseBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
GLM_ALIGN(16) glm::uint32 const Array[4] = {x, 0, y, 0};
__m128i const Mask4 = _mm_set1_epi32(0x0000FFFF);
__m128i const Mask3 = _mm_set1_epi32(0x00FF00FF);
__m128i const Mask2 = _mm_set1_epi32(0x0F0F0F0F);
__m128i const Mask1 = _mm_set1_epi32(0x33333333);
__m128i const Mask0 = _mm_set1_epi32(0x55555555);
__m128i Reg1;
__m128i Reg2;
// REG1 = x;
// REG2 = y;
Reg1 = _mm_load_si128((__m128i*)Array);
//REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
//REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
Reg2 = _mm_slli_si128(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask4);
//REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
//REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
Reg2 = _mm_slli_si128(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask3);
//REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
//REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
Reg2 = _mm_slli_epi32(Reg1, 4);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask2);
//REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
//REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
Reg2 = _mm_slli_epi32(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask1);
//REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
//REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask0);
//return REG1 | (REG2 << 1);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg2 = _mm_srli_si128(Reg2, 8);
Reg1 = _mm_or_si128(Reg1, Reg2);
GLM_ALIGN(16) glm::uint64 Result[2];
_mm_store_si128((__m128i*)Result, Reg1);
return Result[0];
}
inline glm::uint64 sseUnalignedBitfieldInterleave(glm::uint32 x, glm::uint32 y)
{
glm::uint32 const Array[4] = {x, 0, y, 0};
__m128i const Mask4 = _mm_set1_epi32(0x0000FFFF);
__m128i const Mask3 = _mm_set1_epi32(0x00FF00FF);
__m128i const Mask2 = _mm_set1_epi32(0x0F0F0F0F);
__m128i const Mask1 = _mm_set1_epi32(0x33333333);
__m128i const Mask0 = _mm_set1_epi32(0x55555555);
__m128i Reg1;
__m128i Reg2;
// REG1 = x;
// REG2 = y;
Reg1 = _mm_loadu_si128((__m128i*)Array);
//REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
//REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
Reg2 = _mm_slli_si128(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask4);
//REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
//REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
Reg2 = _mm_slli_si128(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask3);
//REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
//REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
Reg2 = _mm_slli_epi32(Reg1, 4);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask2);
//REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
//REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
Reg2 = _mm_slli_epi32(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask1);
//REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
//REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask0);
//return REG1 | (REG2 << 1);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg2 = _mm_srli_si128(Reg2, 8);
Reg1 = _mm_or_si128(Reg1, Reg2);
glm::uint64 Result[2];
_mm_storeu_si128((__m128i*)Result, Reg1);
return Result[0];
}
#endif//(GLM_ARCH != GLM_ARCH_PURE)
int test()
{
{
for(glm::uint32 y = 0; y < (1 << 10); ++y)
for(glm::uint32 x = 0; x < (1 << 10); ++x)
{
glm::uint64 A = glm::bitfieldInterleave(x, y);
glm::uint64 B = fastBitfieldInterleave(x, y);
glm::uint64 C = loopBitfieldInterleave(x, y);
glm::uint64 D = interleaveBitfieldInterleave(x, y);
assert(A == B);
assert(A == C);
assert(A == D);
# if(GLM_ARCH != GLM_ARCH_PURE)
glm::uint64 E = sseBitfieldInterleave(x, y);
glm::uint64 F = sseUnalignedBitfieldInterleave(x, y);
assert(A == E);
assert(A == F);
__m128i G = glm::detail::_mm_bit_interleave_si128(_mm_set_epi32(0, y, 0, x));
glm::uint64 Result[2];
_mm_storeu_si128((__m128i*)Result, G);
assert(A == Result[0]);
# endif//(GLM_ARCH != GLM_ARCH_PURE)
}
}
{
for(glm::uint8 y = 0; y < 127; ++y)
for(glm::uint8 x = 0; x < 127; ++x)
{
glm::uint64 A(glm::bitfieldInterleave(glm::uint8(x), glm::uint8(y)));
glm::uint64 B(glm::bitfieldInterleave(glm::uint16(x), glm::uint16(y)));
glm::uint64 C(glm::bitfieldInterleave(glm::uint32(x), glm::uint32(y)));
glm::int64 D(glm::bitfieldInterleave(glm::int8(x), glm::int8(y)));
glm::int64 E(glm::bitfieldInterleave(glm::int16(x), glm::int16(y)));
glm::int64 F(glm::bitfieldInterleave(glm::int32(x), glm::int32(y)));
assert(D == E);
assert(D == F);
}
}
return 0;
}
int perf()
{
glm::uint32 x_max = 1 << 11;
glm::uint32 y_max = 1 << 10;
// ALU
std::vector<glm::uint64> Data(x_max * y_max);
std::vector<glm::u32vec2> Param(x_max * y_max);
for(glm::uint32 i = 0; i < Param.size(); ++i)
Param[i] = glm::u32vec2(i % x_max, i / y_max);
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::bitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("glm::bitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = fastBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("fastBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = loopBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("loopBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = interleaveBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("interleaveBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# if(GLM_ARCH != GLM_ARCH_PURE)
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = sseBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("sseBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = sseUnalignedBitfieldInterleave(Param[i].x, Param[i].y);
std::clock_t Time = std::clock() - LastTime;
std::printf("sseUnalignedBitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# endif//(GLM_ARCH != GLM_ARCH_PURE)
{
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::bitfieldInterleave(Param[i].x, Param[i].y, Param[i].x);
std::clock_t Time = std::clock() - LastTime;
std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", static_cast<unsigned int>(Time));
}
# if(GLM_ARCH != GLM_ARCH_PURE && !(GLM_COMPILER & GLM_COMPILER_GCC))
{
// SIMD
std::vector<__m128i> SimdData;
SimdData.resize(x_max * y_max);
std::vector<__m128i> SimdParam;
SimdParam.resize(x_max * y_max);
for(int i = 0; i < SimdParam.size(); ++i)
SimdParam[i] = _mm_set_epi32(i % x_max, 0, i / y_max, 0);
std::clock_t LastTime = std::clock();
for(std::size_t i = 0; i < SimdData.size(); ++i)
SimdData[i] = glm::detail::_mm_bit_interleave_si128(SimdParam[i]);
std::clock_t Time = std::clock() - LastTime;
std::printf("_mm_bit_interleave_si128 Time %d clocks\n", static_cast<unsigned int>(Time));
}
# endif//(GLM_ARCH != GLM_ARCH_PURE)
return 0;
}
}//namespace bitfieldInterleave
int main()
{
int Error(0);
Error += ::mask::test();
Error += ::bitfieldInterleave3::test();
Error += ::bitfieldInterleave4::test();
Error += ::bitfieldInterleave::test();
//Error += ::bitRevert::test();
# ifdef NDEBUG
Error += ::mask::perf();
Error += ::bitfieldInterleave::perf();
# endif//NDEBUG
return Error;
}

View file

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_color.cpp
/// @date 2015-02-10 / 2015-02-10
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/color_space.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/constants.hpp>
namespace srgb
{
int test()
{
int Error(0);
glm::vec3 const ColorSourceRGB(1.0, 0.5, 0.0);
{
glm::vec3 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGB);
glm::vec3 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB);
Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1;
}
{
glm::vec3 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGB, 2.8f);
glm::vec3 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB, 2.8f);
Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1;
}
glm::vec4 const ColorSourceRGBA(1.0, 0.5, 0.0, 1.0);
{
glm::vec4 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGBA);
glm::vec4 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB);
Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1;
}
{
glm::vec4 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGBA, 2.8f);
glm::vec4 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB, 2.8f);
Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1;
}
return Error;
}
}//namespace srgb
int main()
{
int Error(0);
Error += srgb::test();
return Error;
}

59
external/glm/test/gtc/gtc_constants.cpp vendored Normal file
View file

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_constants.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/constants.hpp>
int test_epsilon()
{
int Error(0);
{
float Test = glm::epsilon<float>();
}
{
double Test = glm::epsilon<double>();
}
return Error;
}
int main()
{
int Error(0);
//float MinHalf = 0.0f;
//while (glm::half(MinHalf) == glm::half(0.0f))
// MinHalf += std::numeric_limits<float>::epsilon();
Error += test_epsilon();
return Error;
}

108
external/glm/test/gtc/gtc_epsilon.cpp vendored Normal file
View 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/gtc/gtc_epsilon.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/vector_relational.hpp>
int test_defined()
{
glm::epsilonEqual(glm::vec2(), glm::vec2(), glm::vec2());
glm::epsilonEqual(glm::vec3(), glm::vec3(), glm::vec3());
glm::epsilonEqual(glm::vec4(), glm::vec4(), glm::vec4());
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), glm::vec2());
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), glm::vec3());
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), glm::vec4());
glm::epsilonEqual(glm::vec2(), glm::vec2(), 0.0f);
glm::epsilonEqual(glm::vec3(), glm::vec3(), 0.0f);
glm::epsilonEqual(glm::vec4(), glm::vec4(), 0.0f);
glm::epsilonEqual(glm::quat(), glm::quat(), 0.0f);
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), 0.0f);
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), 0.0f);
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), 0.0f);
glm::epsilonNotEqual(glm::quat(), glm::quat(), 0.0f);
return 0;
}
template <typename T>
int test_equal()
{
int Error(0);
{
T A = glm::epsilon<T>();
T B = glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A(0);
T B = static_cast<T>(0) + glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A(0);
T B = static_cast<T>(0) - glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A = static_cast<T>(0) + glm::epsilon<T>();
T B = static_cast<T>(0);
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
{
T A = static_cast<T>(0) - glm::epsilon<T>();
T B = static_cast<T>(0);
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
}
return Error;
}
int main()
{
int Error(0);
Error += test_defined();
Error += test_equal<float>();
Error += test_equal<double>();
return Error;
}

225
external/glm/test/gtc/gtc_integer.cpp vendored Normal file
View file

@ -0,0 +1,225 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_integer.cpp
/// @date 2014-11-17 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_INLINE
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/integer.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtx/type_aligned.hpp>
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cmath>
namespace log2_
{
int test()
{
int Error = 0;
int A0 = static_cast<int>(glm::log2(16.f));
glm::ivec1 B0(glm::log2(glm::vec1(16.f)));
glm::ivec2 C0(glm::log2(glm::vec2(16.f)));
glm::ivec3 D0(glm::log2(glm::vec3(16.f)));
glm::ivec4 E0(glm::log2(glm::vec4(16.f)));
int A1 = glm::log2(int(16));
glm::ivec1 B1 = glm::log2(glm::ivec1(16));
glm::ivec2 C1 = glm::log2(glm::ivec2(16));
glm::ivec3 D1 = glm::log2(glm::ivec3(16));
glm::ivec4 E1 = glm::log2(glm::ivec4(16));
Error += A0 == A1 ? 0 : 1;
Error += glm::all(glm::equal(B0, B1)) ? 0 : 1;
Error += glm::all(glm::equal(C0, C1)) ? 0 : 1;
Error += glm::all(glm::equal(D0, D1)) ? 0 : 1;
Error += glm::all(glm::equal(E0, E1)) ? 0 : 1;
glm::uint64 A2 = glm::log2(glm::uint64(16));
glm::u64vec1 B2 = glm::log2(glm::u64vec1(16));
glm::u64vec2 C2 = glm::log2(glm::u64vec2(16));
glm::u64vec3 D2 = glm::log2(glm::u64vec3(16));
glm::u64vec4 E2 = glm::log2(glm::u64vec4(16));
Error += A2 == glm::uint64(4) ? 0 : 1;
Error += glm::all(glm::equal(B2, glm::u64vec1(4))) ? 0 : 1;
Error += glm::all(glm::equal(C2, glm::u64vec2(4))) ? 0 : 1;
Error += glm::all(glm::equal(D2, glm::u64vec3(4))) ? 0 : 1;
Error += glm::all(glm::equal(E2, glm::u64vec4(4))) ? 0 : 1;
return Error;
}
int perf(std::size_t Count)
{
int Error = 0;
{
std::vector<int> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(int i = 0; i < static_cast<int>(Count); ++i)
Result[i] = glm::log2(static_cast<int>(i));
std::clock_t End = clock();
printf("glm::log2<int>: %ld clocks\n", End - Begin);
}
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(int i = 0; i < static_cast<int>(Count); ++i)
Result[i] = glm::log2(glm::ivec4(i));
std::clock_t End = clock();
printf("glm::log2<ivec4>: %ld clocks\n", End - Begin);
}
# if GLM_HAS_BITSCAN_WINDOWS
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
{
glm::tvec4<unsigned long, glm::defaultp> Tmp(glm::uninitialize);
_BitScanReverse(&Tmp.x, i);
_BitScanReverse(&Tmp.y, i);
_BitScanReverse(&Tmp.z, i);
_BitScanReverse(&Tmp.w, i);
Result[i] = glm::ivec4(Tmp);
}
std::clock_t End = clock();
printf("glm::log2<ivec4> inlined: %ld clocks\n", End - Begin);
}
{
std::vector<glm::tvec4<unsigned long, glm::defaultp> > Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
{
_BitScanReverse(&Result[i].x, i);
_BitScanReverse(&Result[i].y, i);
_BitScanReverse(&Result[i].z, i);
_BitScanReverse(&Result[i].w, i);
}
std::clock_t End = clock();
printf("glm::log2<ivec4> inlined no cast: %ld clocks\n", End - Begin);
}
{
std::vector<glm::ivec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
{
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].x), i);
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].y), i);
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].z), i);
_BitScanReverse(reinterpret_cast<unsigned long*>(&Result[i].w), i);
}
std::clock_t End = clock();
printf("glm::log2<ivec4> reinterpret: %ld clocks\n", End - Begin);
}
# endif//GLM_HAS_BITSCAN_WINDOWS
{
std::vector<float> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(std::size_t i = 0; i < Count; ++i)
Result[i] = glm::log2(static_cast<float>(i));
std::clock_t End = clock();
printf("glm::log2<float>: %ld clocks\n", End - Begin);
}
{
std::vector<glm::vec4> Result;
Result.resize(Count);
std::clock_t Begin = clock();
for(int i = 0; i < static_cast<int>(Count); ++i)
Result[i] = glm::log2(glm::vec4(i));
std::clock_t End = clock();
printf("glm::log2<vec4>: %ld clocks\n", End - Begin);
}
return Error;
}
}//namespace log2_
int main()
{
int Error(0);
Error += ::log2_::test();
# ifdef NDEBUG
std::size_t const Samples(1000);
Error += ::log2_::perf(Samples);
# endif//NDEBUG
return Error;
}

View file

@ -0,0 +1,412 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_matrix_access.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_access.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>
int test_mat2x2_row_set()
{
int Error = 0;
glm::mat2x2 m(1);
m = glm::row(m, 0, glm::vec2( 0, 1));
m = glm::row(m, 1, glm::vec2( 4, 5));
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
return Error;
}
int test_mat2x2_col_set()
{
int Error = 0;
glm::mat2x2 m(1);
m = glm::column(m, 0, glm::vec2( 0, 1));
m = glm::column(m, 1, glm::vec2( 4, 5));
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
return Error;
}
int test_mat2x3_row_set()
{
int Error = 0;
glm::mat2x3 m(1);
m = glm::row(m, 0, glm::vec2( 0, 1));
m = glm::row(m, 1, glm::vec2( 4, 5));
m = glm::row(m, 2, glm::vec2( 8, 9));
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
return Error;
}
int test_mat2x3_col_set()
{
int Error = 0;
glm::mat2x3 m(1);
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
return Error;
}
int test_mat2x4_row_set()
{
int Error = 0;
glm::mat2x4 m(1);
m = glm::row(m, 0, glm::vec2( 0, 1));
m = glm::row(m, 1, glm::vec2( 4, 5));
m = glm::row(m, 2, glm::vec2( 8, 9));
m = glm::row(m, 3, glm::vec2(12, 13));
Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
Error += glm::row(m, 3) == glm::vec2(12, 13) ? 0 : 1;
return Error;
}
int test_mat2x4_col_set()
{
int Error = 0;
glm::mat2x4 m(1);
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
return Error;
}
int test_mat3x2_row_set()
{
int Error = 0;
glm::mat3x2 m(1);
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
return Error;
}
int test_mat3x2_col_set()
{
int Error = 0;
glm::mat3x2 m(1);
m = glm::column(m, 0, glm::vec2( 0, 1));
m = glm::column(m, 1, glm::vec2( 4, 5));
m = glm::column(m, 2, glm::vec2( 8, 9));
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
return Error;
}
int test_mat3x3_row_set()
{
int Error = 0;
glm::mat3x3 m(1);
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
m = glm::row(m, 2, glm::vec3( 8, 9, 10));
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
return Error;
}
int test_mat3x3_col_set()
{
int Error = 0;
glm::mat3x3 m(1);
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
m = glm::column(m, 2, glm::vec3( 8, 9, 10));
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
return Error;
}
int test_mat3x4_row_set()
{
int Error = 0;
glm::mat3x4 m(1);
m = glm::row(m, 0, glm::vec3( 0, 1, 2));
m = glm::row(m, 1, glm::vec3( 4, 5, 6));
m = glm::row(m, 2, glm::vec3( 8, 9, 10));
m = glm::row(m, 3, glm::vec3(12, 13, 14));
Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
Error += glm::row(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1;
return Error;
}
int test_mat3x4_col_set()
{
int Error = 0;
glm::mat3x4 m(1);
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11));
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
return Error;
}
int test_mat4x2_row_set()
{
int Error = 0;
glm::mat4x2 m(1);
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
return Error;
}
int test_mat4x2_col_set()
{
int Error = 0;
glm::mat4x2 m(1);
m = glm::column(m, 0, glm::vec2( 0, 1));
m = glm::column(m, 1, glm::vec2( 4, 5));
m = glm::column(m, 2, glm::vec2( 8, 9));
m = glm::column(m, 3, glm::vec2(12, 13));
Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1;
Error += glm::column(m, 3) == glm::vec2(12, 13) ? 0 : 1;
return Error;
}
int test_mat4x3_row_set()
{
int Error = 0;
glm::mat4x3 m(1);
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11));
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
return Error;
}
int test_mat4x3_col_set()
{
int Error = 0;
glm::mat4x3 m(1);
m = glm::column(m, 0, glm::vec3( 0, 1, 2));
m = glm::column(m, 1, glm::vec3( 4, 5, 6));
m = glm::column(m, 2, glm::vec3( 8, 9, 10));
m = glm::column(m, 3, glm::vec3(12, 13, 14));
Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1;
Error += glm::column(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1;
return Error;
}
int test_mat4x4_row_set()
{
int Error = 0;
glm::mat4 m(1);
m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11));
m = glm::row(m, 3, glm::vec4(12, 13, 14, 15));
Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
Error += glm::row(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1;
return Error;
}
int test_mat4x4_col_set()
{
int Error = 0;
glm::mat4 m(1);
m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3));
m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7));
m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11));
m = glm::column(m, 3, glm::vec4(12, 13, 14, 15));
Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1;
Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1;
Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1;
Error += glm::column(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1;
return Error;
}
int test_mat4x4_row_get()
{
int Error = 0;
glm::mat4 m(1);
glm::vec4 A = glm::row(m, 0);
Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1;
glm::vec4 B = glm::row(m, 1);
Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1;
glm::vec4 C = glm::row(m, 2);
Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1;
glm::vec4 D = glm::row(m, 3);
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
return Error;
}
int test_mat4x4_col_get()
{
int Error = 0;
glm::mat4 m(1);
glm::vec4 A = glm::column(m, 0);
Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1;
glm::vec4 B = glm::column(m, 1);
Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1;
glm::vec4 C = glm::column(m, 2);
Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1;
glm::vec4 D = glm::column(m, 3);
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_mat2x2_row_set();
Error += test_mat2x2_col_set();
Error += test_mat2x3_row_set();
Error += test_mat2x3_col_set();
Error += test_mat2x4_row_set();
Error += test_mat2x4_col_set();
Error += test_mat3x2_row_set();
Error += test_mat3x2_col_set();
Error += test_mat3x3_row_set();
Error += test_mat3x3_col_set();
Error += test_mat3x4_row_set();
Error += test_mat3x4_col_set();
Error += test_mat4x2_row_set();
Error += test_mat4x2_col_set();
Error += test_mat4x3_row_set();
Error += test_mat4x3_col_set();
Error += test_mat4x4_row_set();
Error += test_mat4x4_col_set();
Error += test_mat4x4_row_get();
Error += test_mat4x4_col_get();
return Error;
}

View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_matrix_integer.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_integer.hpp>
int main()
{
int Error = 0;
return Error;
}

View file

@ -0,0 +1,82 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_matrix_inverse.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/epsilon.hpp>
int test_affine()
{
int Error = 0;
{
glm::mat3 const M(
2.f, 0.f, 0.f,
0.f, 2.f, 0.f,
0.f, 0.f, 1.f);
glm::mat3 const A = glm::affineInverse(M);
glm::mat3 const I = glm::inverse(M);
glm::mat3 const R = glm::affineInverse(A);
for(glm::length_t i = 0; i < A.length(); ++i)
{
Error += glm::all(glm::epsilonEqual(M[i], R[i], 0.01f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(A[i], I[i], 0.01f)) ? 0 : 1;
}
}
{
glm::mat4 const M(
2.f, 0.f, 0.f, 0.f,
0.f, 2.f, 0.f, 0.f,
0.f, 0.f, 2.f, 0.f,
0.f, 0.f, 0.f, 1.f);
glm::mat4 const A = glm::affineInverse(M);
glm::mat4 const I = glm::inverse(M);
glm::mat4 const R = glm::affineInverse(A);
for(glm::length_t i = 0; i < A.length(); ++i)
{
Error += glm::all(glm::epsilonEqual(M[i], R[i], 0.01f)) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(A[i], I[i], 0.01f)) ? 0 : 1;
}
}
return Error;
}
int main()
{
int Error = 0;
Error += test_affine();
return Error;
}

View file

@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_matrix_transform.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/constants.hpp>
int test_perspective()
{
int Error = 0;
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
return Error;
}
int test_pick()
{
int Error = 0;
glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240));
return Error;
}
int test_tweakedInfinitePerspective()
{
int Error = 0;
glm::mat4 ProjectionA = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f);
glm::mat4 ProjectionB = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f, 0.001f);
return Error;
}
int test_translate()
{
int Error = 0;
glm::lowp_vec3 v(1.0);
glm::lowp_mat4 m(0);
glm::lowp_mat4 t = glm::translate(m, v);
return Error;
}
int main()
{
int Error = 0;
Error += test_translate();
Error += test_tweakedInfinitePerspective();
Error += test_pick();
Error += test_perspective();
return Error;
}

219
external/glm/test/gtc/gtc_noise.cpp vendored Normal file
View file

@ -0,0 +1,219 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_noise.cpp
/// @date 2011-04-21 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/noise.hpp>
#include <gli/gli.hpp>
#include <gli/gtx/loader.hpp>
int test_simplex()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex4d_256.dds");
}
return 0;
}
int test_perlin()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin4d_256.dds");
}
return 0;
}
int test_perlin_pedioric()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f), glm::vec2(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f), glm::vec3(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f), glm::vec4(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_4d_256.dds");
}
return 0;
}
int main()
{
int Error = 0;
Error += test_simplex();
Error += test_perlin();
Error += test_perlin_pedioric();
return Error;
}

533
external/glm/test/gtc/gtc_packing.cpp vendored Normal file
View file

@ -0,0 +1,533 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_packing.cpp
/// @date 2013-08-09 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/packing.hpp>
#include <glm/gtc/epsilon.hpp>
#include <cstdio>
#include <vector>
void print_bits(float const & s)
{
union
{
float f;
unsigned int i;
} uif;
uif.f = s;
printf("f32: ");
for(std::size_t j = sizeof(s) * 8; j > 0; --j)
{
if(j == 23 || j == 31)
printf(" ");
printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0);
}
}
void print_10bits(glm::uint const & s)
{
printf("10b: ");
for(std::size_t j = 10; j > 0; --j)
{
if(j == 5)
printf(" ");
printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
}
}
void print_11bits(glm::uint const & s)
{
printf("11b: ");
for(std::size_t j = 11; j > 0; --j)
{
if(j == 6)
printf(" ");
printf("%d", (s & (1 << (j - 1))) ? 1 : 0);
}
}
void print_value(float const & s)
{
printf("%2.5f, ", s);
print_bits(s);
printf(", ");
// print_11bits(detail::floatTo11bit(s));
// printf(", ");
// print_10bits(detail::floatTo10bit(s));
printf("\n");
}
int test_Half1x16()
{
int Error = 0;
std::vector<float> Tests;
Tests.push_back(0.0f);
Tests.push_back(1.0f);
Tests.push_back(-1.0f);
Tests.push_back(2.0f);
Tests.push_back(-2.0f);
Tests.push_back(1.9f);
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
float v0 = glm::unpackHalf1x16(p0);
glm::uint32 p1 = glm::packHalf1x16(v0);
float v1 = glm::unpackHalf1x16(p1);
Error += (v0 == v1) ? 0 : 1;
}
return Error;
}
int test_Half4x16()
{
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(-0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
glm::vec4 v0 = glm::unpackHalf4x16(p0);
glm::uint64 p1 = glm::packHalf4x16(v0);
glm::vec4 v1 = glm::unpackHalf4x16(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_I3x10_1x2()
{
int Error = 0;
std::vector<glm::ivec4> Tests;
Tests.push_back(glm::ivec4(0));
Tests.push_back(glm::ivec4(1));
Tests.push_back(glm::ivec4(-1));
Tests.push_back(glm::ivec4(2));
Tests.push_back(glm::ivec4(-2));
Tests.push_back(glm::ivec4(3));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
glm::uint32 p1 = glm::packI3x10_1x2(v0);
glm::ivec4 v1 = glm::unpackI3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_U3x10_1x2()
{
int Error = 0;
std::vector<glm::uvec4> Tests;
Tests.push_back(glm::uvec4(0));
Tests.push_back(glm::uvec4(1));
Tests.push_back(glm::uvec4(2));
Tests.push_back(glm::uvec4(3));
Tests.push_back(glm::uvec4(4));
Tests.push_back(glm::uvec4(5));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
glm::uint32 p1 = glm::packU3x10_1x2(v0);
glm::uvec4 v1 = glm::unpackU3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_Snorm3x10_1x2()
{
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_Unorm3x10_1x2()
{
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packUnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackUnorm3x10_1x2(p0);
glm::uint32 p1 = glm::packUnorm3x10_1x2(v0);
glm::vec4 v1 = glm::unpackUnorm3x10_1x2(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_F2x11_1x10()
{
int Error = 0;
std::vector<glm::vec3> Tests;
Tests.push_back(glm::vec3(1.0f));
Tests.push_back(glm::vec3(0.0f));
Tests.push_back(glm::vec3(2.0f));
Tests.push_back(glm::vec3(0.1f));
Tests.push_back(glm::vec3(0.5f));
Tests.push_back(glm::vec3(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
glm::uint32 p1 = glm::packF2x11_1x10(v0);
glm::vec3 v1 = glm::unpackF2x11_1x10(p1);
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
}
return Error;
}
int test_packUnorm1x16()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1(1.0f));
A.push_back(glm::vec1(0.5f));
A.push_back(glm::vec1(0.1f));
A.push_back(glm::vec1(0.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint32 C = glm::packUnorm1x16(B.x);
glm::vec1 D(glm::unpackUnorm1x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm1x16()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1( 1.0f));
A.push_back(glm::vec1( 0.0f));
A.push_back(glm::vec1(-0.5f));
A.push_back(glm::vec1(-0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint32 C = glm::packSnorm1x16(B.x);
glm::vec1 D(glm::unpackSnorm1x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
}
return Error;
}
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_packUnorm4x16()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4(1.0f));
A.push_back(glm::vec4(0.5f));
A.push_back(glm::vec4(0.1f));
A.push_back(glm::vec4(0.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint64 C = glm::packUnorm4x16(B);
glm::vec4 D(glm::unpackUnorm4x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm4x16()
{
int Error = 0;
std::vector<glm::vec4> A;
A.push_back(glm::vec4( 1.0f, 0.0f, -0.5f, 0.5f));
A.push_back(glm::vec4(-0.3f,-0.7f, 0.3f, 0.7f));
A.push_back(glm::vec4(-0.1f, 0.1f, -0.2f, 0.2f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec4 B(A[i]);
glm::uint64 C = glm::packSnorm4x16(B);
glm::vec4 D(glm::unpackSnorm4x16(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packUnorm1x8()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1(1.0f));
A.push_back(glm::vec1(0.5f));
A.push_back(glm::vec1(0.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint8 C = glm::packUnorm1x8(B.x);
glm::vec1 D(glm::unpackUnorm1x8(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm1x8()
{
int Error = 0;
std::vector<glm::vec1> A;
A.push_back(glm::vec1( 1.0f));
A.push_back(glm::vec1(-0.7f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec1 B(A[i]);
glm::uint8 C = glm::packSnorm1x8(B.x);
glm::vec1 D(glm::unpackSnorm1x8(C));
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
}
return Error;
}
int test_packUnorm2x8()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2(1.0f, 0.7f));
A.push_back(glm::vec2(0.5f, 0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint16 C = glm::packUnorm2x8(B);
glm::vec2 D = glm::unpackUnorm2x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_packSnorm2x8()
{
int Error = 0;
std::vector<glm::vec2> A;
A.push_back(glm::vec2( 1.0f, 0.0f));
A.push_back(glm::vec2(-0.7f,-0.1f));
for(std::size_t i = 0; i < A.size(); ++i)
{
glm::vec2 B(A[i]);
glm::uint16 C = glm::packSnorm2x8(B);
glm::vec2 D = glm::unpackSnorm2x8(C);
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
}
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 main()
{
int Error(0);
Error += test_packSnorm1x16();
Error += test_packSnorm2x16();
Error += test_packSnorm4x16();
Error += test_packSnorm1x8();
Error += test_packSnorm2x8();
Error += test_packSnorm4x8();
Error += test_packUnorm1x16();
Error += test_packUnorm2x16();
Error += test_packUnorm4x16();
Error += test_packUnorm1x8();
Error += test_packUnorm2x8();
Error += test_packUnorm4x8();
Error += test_F2x11_1x10();
Error += test_Snorm3x10_1x2();
Error += test_Unorm3x10_1x2();
Error += test_I3x10_1x2();
Error += test_U3x10_1x2();
Error += test_Half1x16();
Error += test_U3x10_1x2();
return Error;
}

349
external/glm/test/gtc/gtc_quaternion.cpp vendored Normal file
View file

@ -0,0 +1,349 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_quaternion.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_META_PROG_HELPERS
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp>
#include <vector>
int test_quat_angle()
{
int Error = 0;
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(0, 1, 1)));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::normalize(glm::vec3(1, 2, 3)));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
float A = glm::angle(N);
Error += glm::epsilonEqual(A, glm::pi<float>() * 0.25f, 0.01f) ? 0 : 1;
}
return Error;
}
int test_quat_angleAxis()
{
int Error = 0;
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::quat C = glm::mix(A, B, 0.5f);
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
return Error;
}
int test_quat_mix()
{
int Error = 0;
glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1));
glm::quat B = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::quat C = glm::mix(A, B, 0.5f);
glm::quat D = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
return Error;
}
int test_quat_precision()
{
int Error = 0;
Error += sizeof(glm::lowp_quat) <= sizeof(glm::mediump_quat) ? 0 : 1;
Error += sizeof(glm::mediump_quat) <= sizeof(glm::highp_quat) ? 0 : 1;
return Error;
}
int test_quat_normalize()
{
int Error(0);
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 1));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(0, 0, 2));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
{
glm::quat Q = glm::angleAxis(glm::pi<float>() * 0.25f, glm::vec3(1, 2, 3));
glm::quat N = glm::normalize(Q);
float L = glm::length(N);
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
}
return Error;
}
int test_quat_euler()
{
int Error(0);
{
glm::quat q(1.0f, 0.0f, 0.0f, 1.0f);
float Roll = glm::roll(q);
float Pitch = glm::pitch(q);
float Yaw = glm::yaw(q);
glm::vec3 Angles = glm::eulerAngles(q);
}
{
glm::dquat q(1.0f, 0.0f, 0.0f, 1.0f);
double Roll = glm::roll(q);
double Pitch = glm::pitch(q);
double Yaw = glm::yaw(q);
glm::dvec3 Angles = glm::eulerAngles(q);
}
return Error;
}
int test_quat_slerp()
{
int Error(0);
float const Epsilon = 0.0001f;//glm::epsilon<float>();
float sqrt2 = sqrt(2.0f)/2.0f;
glm::quat id;
glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f);
glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f);
// Testing a == 0
// Must be id
glm::quat id2 = glm::slerp(id, Y90rot, 0.0f);
Error += glm::all(glm::epsilonEqual(id, id2, Epsilon)) ? 0 : 1;
// Testing a == 1
// Must be 90° rotation on Y : 0 0.7 0 0.7
glm::quat Y90rot2 = glm::slerp(id, Y90rot, 1.0f);
Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot2, Epsilon)) ? 0 : 1;
// Testing standard, easy case
// Must be 45° rotation on Y : 0 0.38 0 0.92
glm::quat Y45rot1 = glm::slerp(id, Y90rot, 0.5f);
// Testing reverse case
// Must be 45° rotation on Y : 0 0.38 0 0.92
glm::quat Ym45rot2 = glm::slerp(Y90rot, id, 0.5f);
// Testing against full circle around the sphere instead of shortest path
// Must be 45° rotation on Y
// certainly not a 135° rotation
glm::quat Y45rot3 = glm::slerp(id , -Y90rot, 0.5f);
float Y45angle3 = glm::angle(Y45rot3);
Error += glm::epsilonEqual(Y45angle3, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
Error += glm::all(glm::epsilonEqual(Ym45rot2, Y45rot3, Epsilon)) ? 0 : 1;
// Same, but inverted
// Must also be 45° rotation on Y : 0 0.38 0 0.92
// -0 -0.38 -0 -0.92 is ok too
glm::quat Y45rot4 = glm::slerp(-Y90rot, id, 0.5f);
Error += glm::all(glm::epsilonEqual(Ym45rot2, -Y45rot4, Epsilon)) ? 0 : 1;
// Testing q1 = q2
// Must be 90° rotation on Y : 0 0.7 0 0.7
glm::quat Y90rot3 = glm::slerp(Y90rot, Y90rot, 0.5f);
Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot3, Epsilon)) ? 0 : 1;
// Testing 180° rotation
// Must be 90° rotation on almost any axis that is on the XZ plane
glm::quat XZ90rot = glm::slerp(id, -Y90rot, 0.5f);
float XZ90angle = glm::angle(XZ90rot); // Must be PI/4 = 0.78;
Error += glm::epsilonEqual(XZ90angle, glm::pi<float>() * 0.25f, Epsilon) ? 0 : 1;
// Testing almost equal quaternions (this test should pass through the linear interpolation)
// Must be 0 0.00X 0 0.99999
glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f);
// Testing quaternions with opposite sign
{
glm::quat a(-1, 0, 0, 0);
glm::quat result = glm::slerp(a, id, 0.5f);
Error += glm::epsilonEqual(glm::pow(glm::dot(id, result), 2.f), 1.f, 0.01f) ? 0 : 1;
}
return Error;
}
int test_quat_mul()
{
int Error(0);
glm::quat temp1 = glm::normalize(glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0)));
glm::quat temp2 = glm::normalize(glm::quat(0.5f, glm::vec3(1.0, 0.0, 0.0)));
glm::vec3 transformed0 = (temp1 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp1));
glm::vec3 temp4 = temp2 * transformed0 * glm::inverse(temp2);
glm::quat temp5 = glm::normalize(temp1 * temp2);
glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5);
# ifndef GLM_FORCE_NO_CTOR_INIT
{
glm::quat temp7;
temp7 *= temp5;
temp7 *= glm::inverse(temp5);
Error += temp7 != glm::quat();
}
# endif
return Error;
}
int test_quat_two_axis_ctr()
{
int Error(0);
glm::quat q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
glm::vec3 v1 = q1 * glm::vec3(1, 0, 0);
Error += glm::all(glm::epsilonEqual(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1;
glm::quat q2 = q1 * q1;
glm::vec3 v2 = q2 * glm::vec3(1, 0, 0);
Error += glm::all(glm::epsilonEqual(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
return Error;
}
int test_quat_type()
{
glm::quat A;
glm::dquat B;
return 0;
}
int test_quat_mul_vec()
{
int Error(0);
glm::quat q = glm::angleAxis(glm::pi<float>() * 0.5f, glm::vec3(0, 0, 1));
glm::vec3 v(1, 0, 0);
glm::vec3 u(q * v);
glm::vec3 w(u * q);
Error += glm::all(glm::epsilonEqual(v, w, 0.01f)) ? 0 : 1;
return Error;
}
int test_quat_ctr()
{
int Error(0);
# if GLM_HAS_TRIVIAL_QUERIES
// Error += std::is_trivially_default_constructible<glm::quat>::value ? 0 : 1;
// Error += std::is_trivially_default_constructible<glm::dquat>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::quat>::value ? 0 : 1;
// Error += std::is_trivially_copy_assignable<glm::dquat>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::quat>::value ? 0 : 1;
Error += std::is_trivially_copyable<glm::dquat>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::quat>::value ? 0 : 1;
Error += std::is_copy_constructible<glm::dquat>::value ? 0 : 1;
# endif
# if GLM_HAS_INITIALIZER_LISTS
{
glm::quat A{0, 1, 2, 3};
std::vector<glm::quat> B{
{0, 1, 2, 3},
{0, 1, 2, 3}};
}
# endif//GLM_HAS_INITIALIZER_LISTS
return Error;
}
int main()
{
int Error(0);
#ifdef GLM_META_PROG_HELPERS
assert(glm::quat::components == 4);
assert(glm::quat::components == glm::quat().length());
#endif
Error += test_quat_ctr();
Error += test_quat_mul_vec();
Error += test_quat_two_axis_ctr();
Error += test_quat_mul();
Error += test_quat_precision();
Error += test_quat_type();
Error += test_quat_angle();
Error += test_quat_angleAxis();
Error += test_quat_mix();
Error += test_quat_normalize();
Error += test_quat_euler();
Error += test_quat_slerp();
return Error;
}

408
external/glm/test/gtc/gtc_random.cpp vendored Normal file
View file

@ -0,0 +1,408 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_random.cpp
/// @date 2011-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/random.hpp>
#include <glm/gtc/epsilon.hpp>
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
# include <array>
#endif
int test_linearRand()
{
int Error = 0;
glm::int32 const Min = 16;
glm::int32 const Max = 32;
{
glm::u8vec2 AMin(std::numeric_limits<glm::u8>::max());
glm::u8vec2 AMax(std::numeric_limits<glm::u8>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u8vec2 A = glm::linearRand(glm::u8vec2(Min), glm::u8vec2(Max));
AMin = glm::min(AMin, A);
AMax = glm::max(AMax, A);
if(!glm::all(glm::lessThanEqual(A, glm::u8vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(A, glm::u8vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(AMin, glm::u8vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(AMax, glm::u8vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::u16vec2 BMin(std::numeric_limits<glm::u16>::max());
glm::u16vec2 BMax(std::numeric_limits<glm::u16>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u16vec2 B = glm::linearRand(glm::u16vec2(Min), glm::u16vec2(Max));
BMin = glm::min(BMin, B);
BMax = glm::max(BMax, B);
if(!glm::all(glm::lessThanEqual(B, glm::u16vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(B, glm::u16vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(BMin, glm::u16vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(BMax, glm::u16vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::u32vec2 CMin(std::numeric_limits<glm::u32>::max());
glm::u32vec2 CMax(std::numeric_limits<glm::u32>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u32vec2 C = glm::linearRand(glm::u32vec2(Min), glm::u32vec2(Max));
CMin = glm::min(CMin, C);
CMax = glm::max(CMax, C);
if(!glm::all(glm::lessThanEqual(C, glm::u32vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(C, glm::u32vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(CMin, glm::u32vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(CMax, glm::u32vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::u64vec2 DMin(std::numeric_limits<glm::u64>::max());
glm::u64vec2 DMax(std::numeric_limits<glm::u64>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::u64vec2 D = glm::linearRand(glm::u64vec2(Min), glm::u64vec2(Max));
DMin = glm::min(DMin, D);
DMax = glm::max(DMax, D);
if(!glm::all(glm::lessThanEqual(D, glm::u64vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(D, glm::u64vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(DMin, glm::u64vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(DMax, glm::u64vec2(Max))) ? 0 : 1;
assert(!Error);
}
}
{
glm::i8vec2 AMin(std::numeric_limits<glm::i8>::max());
glm::i8vec2 AMax(std::numeric_limits<glm::i8>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i8vec2 A = glm::linearRand(glm::i8vec2(Min), glm::i8vec2(Max));
AMin = glm::min(AMin, A);
AMax = glm::max(AMax, A);
if(!glm::all(glm::lessThanEqual(A, glm::i8vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(A, glm::i8vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(AMin, glm::i8vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(AMax, glm::i8vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::i16vec2 BMin(std::numeric_limits<glm::i16>::max());
glm::i16vec2 BMax(std::numeric_limits<glm::i16>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i16vec2 B = glm::linearRand(glm::i16vec2(Min), glm::i16vec2(Max));
BMin = glm::min(BMin, B);
BMax = glm::max(BMax, B);
if(!glm::all(glm::lessThanEqual(B, glm::i16vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(B, glm::i16vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(BMin, glm::i16vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(BMax, glm::i16vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::i32vec2 CMin(std::numeric_limits<glm::i32>::max());
glm::i32vec2 CMax(std::numeric_limits<glm::i32>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i32vec2 C = glm::linearRand(glm::i32vec2(Min), glm::i32vec2(Max));
CMin = glm::min(CMin, C);
CMax = glm::max(CMax, C);
if(!glm::all(glm::lessThanEqual(C, glm::i32vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(C, glm::i32vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(CMin, glm::i32vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(CMax, glm::i32vec2(Max))) ? 0 : 1;
assert(!Error);
}
glm::i64vec2 DMin(std::numeric_limits<glm::i64>::max());
glm::i64vec2 DMax(std::numeric_limits<glm::i64>::min());
{
for(std::size_t i = 0; i < 100000; ++i)
{
glm::i64vec2 D = glm::linearRand(glm::i64vec2(Min), glm::i64vec2(Max));
DMin = glm::min(DMin, D);
DMax = glm::max(DMax, D);
if(!glm::all(glm::lessThanEqual(D, glm::i64vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(D, glm::i64vec2(Min))))
++Error;
assert(!Error);
}
Error += glm::all(glm::equal(DMin, glm::i64vec2(Min))) ? 0 : 1;
Error += glm::all(glm::equal(DMax, glm::i64vec2(Max))) ? 0 : 1;
assert(!Error);
}
}
for(std::size_t i = 0; i < 100000; ++i)
{
glm::f32vec2 const A(glm::linearRand(glm::f32vec2(static_cast<float>(Min)), glm::f32vec2(static_cast<float>(Max))));
if(!glm::all(glm::lessThanEqual(A, glm::f32vec2(static_cast<float>(Max)))))
++Error;
if(!glm::all(glm::greaterThanEqual(A, glm::f32vec2(static_cast<float>(Min)))))
++Error;
glm::f64vec2 const B(glm::linearRand(glm::f64vec2(Min), glm::f64vec2(Max)));
if(!glm::all(glm::lessThanEqual(B, glm::f64vec2(Max))))
++Error;
if(!glm::all(glm::greaterThanEqual(B, glm::f64vec2(Min))))
++Error;
assert(!Error);
}
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::linearRand(-1.0f, 1.0f);
ResultDouble += glm::linearRand(-1.0, 1.0);
}
Error += glm::epsilonEqual(ResultFloat, 0.0f, 0.0001f);
Error += glm::epsilonEqual(ResultDouble, 0.0, 0.0001);
assert(!Error);
}
return Error;
}
int test_circularRand()
{
int Error = 0;
{
std::size_t Max = 100000;
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
double Radius = 2.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloat += glm::length(glm::circularRand(1.0f));
ResultDouble += glm::length(glm::circularRand(Radius));
}
Error += glm::epsilonEqual(ResultFloat, float(Max), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_sphericalRand()
{
int Error = 0;
{
std::size_t Max = 100000;
float ResultFloatA = 0.0f;
float ResultFloatB = 0.0f;
float ResultFloatC = 0.0f;
double ResultDoubleA = 0.0f;
double ResultDoubleB = 0.0f;
double ResultDoubleC = 0.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloatA += glm::length(glm::sphericalRand(1.0f));
ResultDoubleA += glm::length(glm::sphericalRand(1.0));
ResultFloatB += glm::length(glm::sphericalRand(2.0f));
ResultDoubleB += glm::length(glm::sphericalRand(2.0));
ResultFloatC += glm::length(glm::sphericalRand(3.0f));
ResultDoubleC += glm::length(glm::sphericalRand(3.0));
}
Error += glm::epsilonEqual(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
Error += glm::epsilonEqual(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
Error += glm::epsilonEqual(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_diskRand()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::length(glm::diskRand(2.0f));
ResultDouble += glm::length(glm::diskRand(2.0));
}
Error += ResultFloat < 200000.f ? 0 : 1;
Error += ResultDouble < 200000.0 ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_ballRand()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::length(glm::ballRand(2.0f));
ResultDouble += glm::length(glm::ballRand(2.0));
}
Error += ResultFloat < 200000.f ? 0 : 1;
Error += ResultDouble < 200000.0 ? 0 : 1;
assert(!Error);
}
return Error;
}
/*
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
int test_grid()
{
int Error = 0;
typedef std::array<int, 8> colors;
typedef std::array<int, 8 * 8> grid;
grid Grid;
colors Colors;
grid GridBest;
colors ColorsBest;
while(true)
{
for(std::size_t i = 0; i < Grid.size(); ++i)
Grid[i] = int(glm::linearRand(0.0, 8.0 * 8.0 * 8.0 - 1.0) / 64.0);
for(std::size_t i = 0; i < Grid.size(); ++i)
++Colors[Grid[i]];
bool Exit = true;
for(std::size_t i = 0; i < Colors.size(); ++i)
{
if(Colors[i] == 8)
continue;
Exit = false;
break;
}
if(Exit == true)
break;
}
return Error;
}
#endif
*/
int main()
{
int Error = 0;
Error += test_linearRand();
Error += test_circularRand();
Error += test_sphericalRand();
Error += test_diskRand();
Error += test_ballRand();
/*
#if(GLM_LANG & GLM_LANG_CXX0X_FLAG)
Error += test_grid();
#endif
*/
return Error;
}

View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_reciprocal.cpp
/// @date 2012-09-19 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/reciprocal.hpp>
#include <ctime>
int main()
{
return 0;
}

392
external/glm/test/gtc/gtc_round.cpp vendored Normal file
View file

@ -0,0 +1,392 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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.
///
/// 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/gtc/gtc_round.cpp
/// @date 2014-11-03 / 2014-11-03
/// @author Christophe Riccio
///
/// @see core (dependence)
/// @see gtc_round (dependence)
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/round.hpp>
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtc/epsilon.hpp>
#include <vector>
#include <ctime>
#include <cstdio>
namespace isPowerOfTwo
{
template <typename genType>
struct type
{
genType Value;
bool Return;
};
int test_int16()
{
type<glm::int16> const Data[] =
{
{0x0001, true},
{0x0002, true},
{0x0004, true},
{0x0080, true},
{0x0000, true},
{0x0003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int16>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_uint16()
{
type<glm::uint16> const Data[] =
{
{0x0001, true},
{0x0002, true},
{0x0004, true},
{0x0000, true},
{0x0000, true},
{0x0003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint16>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_int32()
{
type<int> const Data[] =
{
{0x00000001, true},
{0x00000002, true},
{0x00000004, true},
{0x0000000f, false},
{0x00000000, true},
{0x00000003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec1 Result = glm::isPowerOfTwo(glm::ivec1(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec1(Data[i].Return), Result)) ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec2 Result = glm::isPowerOfTwo(glm::ivec2(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec2(Data[i].Return), Result)) ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec3 Result = glm::isPowerOfTwo(glm::ivec3(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec3(Data[i].Return), Result)) ? 0 : 1;
}
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
glm::bvec4 Result = glm::isPowerOfTwo(glm::ivec4(Data[i].Value));
Error += glm::all(glm::equal(glm::bvec4(Data[i].Return), Result)) ? 0 : 1;
}
return Error;
}
int test_uint32()
{
type<glm::uint> const Data[] =
{
{0x00000001, true},
{0x00000002, true},
{0x00000004, true},
{0x80000000, true},
{0x00000000, true},
{0x00000003, false}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint>); i < n; ++i)
{
bool Result = glm::isPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_int16();
Error += test_uint16();
Error += test_int32();
Error += test_uint32();
return Error;
}
}//isPowerOfTwo
namespace ceilPowerOfTwo
{
template <typename genIUType>
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
{
genIUType tmp = Value;
genIUType result = genIUType(0);
while(tmp)
{
result = (tmp & (~tmp + 1)); // grab lowest bit
tmp &= ~result; // clear lowest bit
}
return result;
}
template <typename genType>
GLM_FUNC_QUALIFIER genType ceilPowerOfTwo_loop(genType value)
{
return glm::isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
}
template <typename genType>
struct type
{
genType Value;
genType Return;
};
int test_int32()
{
type<glm::int32> const Data[] =
{
{0x0000ffff, 0x00010000},
{-3, -4},
{-8, -8},
{0x00000001, 0x00000001},
{0x00000002, 0x00000002},
{0x00000004, 0x00000004},
{0x00000007, 0x00000008},
{0x0000fff0, 0x00010000},
{0x0000f000, 0x00010000},
{0x08000000, 0x08000000},
{0x00000000, 0x00000000},
{0x00000003, 0x00000004}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int32>); i < n; ++i)
{
glm::int32 Result = glm::ceilPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test_uint32()
{
type<glm::uint32> const Data[] =
{
{0x00000001, 0x00000001},
{0x00000002, 0x00000002},
{0x00000004, 0x00000004},
{0x00000007, 0x00000008},
{0x0000ffff, 0x00010000},
{0x0000fff0, 0x00010000},
{0x0000f000, 0x00010000},
{0x80000000, 0x80000000},
{0x00000000, 0x00000000},
{0x00000003, 0x00000004}
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint32>); i < n; ++i)
{
glm::uint32 Result = glm::ceilPowerOfTwo(Data[i].Value);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int perf()
{
int Error(0);
std::vector<glm::uint> v;
v.resize(100000000);
std::clock_t Timestramp0 = std::clock();
for(glm::uint32 i = 0, n = static_cast<glm::uint>(v.size()); i < n; ++i)
v[i] = ceilPowerOfTwo_loop(i);
std::clock_t Timestramp1 = std::clock();
for(glm::uint32 i = 0, n = static_cast<glm::uint>(v.size()); i < n; ++i)
v[i] = glm::ceilPowerOfTwo(i);
std::clock_t Timestramp2 = std::clock();
std::printf("ceilPowerOfTwo_loop: %d clocks\n", static_cast<unsigned int>(Timestramp1 - Timestramp0));
std::printf("glm::ceilPowerOfTwo: %d clocks\n", static_cast<unsigned int>(Timestramp2 - Timestramp1));
return Error;
}
int test()
{
int Error(0);
Error += test_int32();
Error += test_uint32();
return Error;
}
}//namespace ceilPowerOfTwo
namespace floorMultiple
{
template <typename genType>
struct type
{
genType Source;
genType Multiple;
genType Return;
genType Epsilon;
};
int test_float()
{
type<glm::float64> const Data[] =
{
{3.4, 0.3, 3.3, 0.0001},
{-1.4, 0.3, -1.5, 0.0001},
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::float64>); i < n; ++i)
{
glm::float64 Result = glm::floorMultiple(Data[i].Source, Data[i].Multiple);
Error += glm::epsilonEqual(Data[i].Return, Result, Data[i].Epsilon) ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_float();
return Error;
}
}//namespace floorMultiple
namespace ceilMultiple
{
template <typename genType>
struct type
{
genType Source;
genType Multiple;
genType Return;
genType Epsilon;
};
int test_float()
{
type<glm::float64> const Data[] =
{
{3.4, 0.3, 3.6, 0.0001},
{-1.4, 0.3, -1.2, 0.0001},
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::float64>); i < n; ++i)
{
glm::float64 Result = glm::ceilMultiple(Data[i].Source, Data[i].Multiple);
Error += glm::epsilonEqual(Data[i].Return, Result, Data[i].Epsilon) ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_float();
return Error;
}
}//namespace ceilMultiple
int main()
{
int Error(0);
Error += isPowerOfTwo::test();
Error += ceilPowerOfTwo::test();
# ifdef NDEBUG
Error += ceilPowerOfTwo::perf();
# endif//NDEBUG
Error += floorMultiple::test();
Error += ceilMultiple::test();
return Error;
}

View file

@ -0,0 +1,921 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_type_precision.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_precision.hpp>
#include <glm/gtc/quaternion.hpp>
#include <vector>
#if GLM_HAS_OPENMP
# include <omp.h>
#endif
static int test_scalar_size()
{
int Error(0);
Error += sizeof(glm::int8) != 1;
Error += sizeof(glm::int16) != 2;
Error += sizeof(glm::int32) != 4;
Error += sizeof(glm::int64) != 8;
Error += sizeof(glm::uint8) != 1;
Error += sizeof(glm::uint16) != 2;
Error += sizeof(glm::uint32) != 4;
Error += sizeof(glm::uint64) != 8;
Error += sizeof(glm::float32) != 4;
Error += sizeof(glm::float64) != 8;
Error += sizeof(glm::lowp_int8) != 1;
Error += sizeof(glm::lowp_int16) != 2;
Error += sizeof(glm::lowp_int32) != 4;
Error += sizeof(glm::lowp_int64) != 8;
Error += sizeof(glm::lowp_uint8) != 1;
Error += sizeof(glm::lowp_uint16) != 2;
Error += sizeof(glm::lowp_uint32) != 4;
Error += sizeof(glm::lowp_uint64) != 8;
Error += sizeof(glm::lowp_float32) != 4;
Error += sizeof(glm::lowp_float64) != 8;
Error += sizeof(glm::mediump_int8) != 1;
Error += sizeof(glm::mediump_int16) != 2;
Error += sizeof(glm::mediump_int32) != 4;
Error += sizeof(glm::mediump_int64) != 8;
Error += sizeof(glm::mediump_uint8) != 1;
Error += sizeof(glm::mediump_uint16) != 2;
Error += sizeof(glm::mediump_uint32) != 4;
Error += sizeof(glm::mediump_uint64) != 8;
Error += sizeof(glm::mediump_float32) != 4;
Error += sizeof(glm::mediump_float64) != 8;
Error += sizeof(glm::highp_int8) != 1;
Error += sizeof(glm::highp_int16) != 2;
Error += sizeof(glm::highp_int32) != 4;
Error += sizeof(glm::highp_int64) != 8;
Error += sizeof(glm::highp_uint8) != 1;
Error += sizeof(glm::highp_uint16) != 2;
Error += sizeof(glm::highp_uint32) != 4;
Error += sizeof(glm::highp_uint64) != 8;
Error += sizeof(glm::highp_float32) != 4;
Error += sizeof(glm::highp_float64) != 8;
return Error;
}
static int test_fvec_size()
{
int Error(0);
Error += sizeof(glm::f32vec2) != 8;
Error += sizeof(glm::f32vec3) != 12;
Error += sizeof(glm::f32vec4) != 16;
Error += sizeof(glm::f64vec2) != 16;
Error += sizeof(glm::f64vec3) != 24;
Error += sizeof(glm::f64vec4) != 32;
Error += sizeof(glm::lowp_f32vec2) != 8;
Error += sizeof(glm::lowp_f32vec3) != 12;
Error += sizeof(glm::lowp_f32vec4) != 16;
Error += sizeof(glm::lowp_f64vec2) != 16;
Error += sizeof(glm::lowp_f64vec3) != 24;
Error += sizeof(glm::lowp_f64vec4) != 32;
Error += sizeof(glm::mediump_f32vec2) != 8;
Error += sizeof(glm::mediump_f32vec3) != 12;
Error += sizeof(glm::mediump_f32vec4) != 16;
Error += sizeof(glm::mediump_f64vec2) != 16;
Error += sizeof(glm::mediump_f64vec3) != 24;
Error += sizeof(glm::mediump_f64vec4) != 32;
Error += sizeof(glm::highp_f32vec2) != 8;
Error += sizeof(glm::highp_f32vec3) != 12;
Error += sizeof(glm::highp_f32vec4) != 16;
Error += sizeof(glm::highp_f64vec2) != 16;
Error += sizeof(glm::highp_f64vec3) != 24;
Error += sizeof(glm::highp_f64vec4) != 32;
return Error;
}
static int test_fvec_precision()
{
int Error(0);
/*
{
glm::f32vec2 v1;
glm::lowp_f32vec2 v2((glm::f32vec2(v1)));
glm::mediump_f32vec2 v3((glm::f32vec2(v1)));
glm::highp_f32vec2 v4((glm::f32vec2(v1)));
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v4)) ? 0 : 1;
}
*/
{
glm::f32vec2 v1;
glm::lowp_f32vec2 v2(v1);
glm::mediump_f32vec2 v3(v1);
glm::highp_f32vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::f32vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec2(v4))) ? 0 : 1;
}
{
glm::f32vec3 v1;
glm::lowp_f32vec3 v2(v1);
glm::mediump_f32vec3 v3(v1);
glm::highp_f32vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::f32vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec3(v4))) ? 0 : 1;
}
{
glm::f32vec4 v1;
glm::lowp_f32vec4 v2(v1);
glm::mediump_f32vec4 v3(v1);
glm::highp_f32vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::f32vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f32vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_dvec_precision()
{
int Error(0);
{
glm::f64vec2 v1;
glm::lowp_f64vec2 v2(v1);
glm::mediump_f64vec2 v3(v1);
glm::highp_f64vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::f64vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec2(v4))) ? 0 : 1;
}
{
glm::f64vec3 v1;
glm::lowp_f64vec3 v2(v1);
glm::mediump_f64vec3 v3(v1);
glm::highp_f64vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::f64vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec3(v4))) ? 0 : 1;
}
{
glm::f64vec4 v1;
glm::lowp_f64vec4 v2(v1);
glm::mediump_f64vec4 v3(v1);
glm::highp_f64vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::f64vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::f64vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_ivec_size()
{
int Error(0);
Error += sizeof(glm::i8vec2) != 2;
Error += sizeof(glm::i8vec3) != 3;
Error += sizeof(glm::i8vec4) != 4;
Error += sizeof(glm::i16vec2) != 4;
Error += sizeof(glm::i16vec3) != 6;
Error += sizeof(glm::i16vec4) != 8;
Error += sizeof(glm::i32vec2) != 8;
Error += sizeof(glm::i32vec3) != 12;
Error += sizeof(glm::i32vec4) != 16;
Error += sizeof(glm::i64vec2) != 16;
Error += sizeof(glm::i64vec3) != 24;
Error += sizeof(glm::i64vec4) != 32;
Error += sizeof(glm::lowp_i8vec2) != 2;
Error += sizeof(glm::lowp_i8vec3) != 3;
Error += sizeof(glm::lowp_i8vec4) != 4;
Error += sizeof(glm::lowp_i16vec2) != 4;
Error += sizeof(glm::lowp_i16vec3) != 6;
Error += sizeof(glm::lowp_i16vec4) != 8;
Error += sizeof(glm::lowp_i32vec2) != 8;
Error += sizeof(glm::lowp_i32vec3) != 12;
Error += sizeof(glm::lowp_i32vec4) != 16;
Error += sizeof(glm::lowp_i64vec2) != 16;
Error += sizeof(glm::lowp_i64vec3) != 24;
Error += sizeof(glm::lowp_i64vec4) != 32;
Error += sizeof(glm::mediump_i8vec2) != 2;
Error += sizeof(glm::mediump_i8vec3) != 3;
Error += sizeof(glm::mediump_i8vec4) != 4;
Error += sizeof(glm::mediump_i16vec2) != 4;
Error += sizeof(glm::mediump_i16vec3) != 6;
Error += sizeof(glm::mediump_i16vec4) != 8;
Error += sizeof(glm::mediump_i32vec2) != 8;
Error += sizeof(glm::mediump_i32vec3) != 12;
Error += sizeof(glm::mediump_i32vec4) != 16;
Error += sizeof(glm::mediump_i64vec2) != 16;
Error += sizeof(glm::mediump_i64vec3) != 24;
Error += sizeof(glm::mediump_i64vec4) != 32;
Error += sizeof(glm::highp_i8vec2) != 2;
Error += sizeof(glm::highp_i8vec3) != 3;
Error += sizeof(glm::highp_i8vec4) != 4;
Error += sizeof(glm::highp_i16vec2) != 4;
Error += sizeof(glm::highp_i16vec3) != 6;
Error += sizeof(glm::highp_i16vec4) != 8;
Error += sizeof(glm::highp_i32vec2) != 8;
Error += sizeof(glm::highp_i32vec3) != 12;
Error += sizeof(glm::highp_i32vec4) != 16;
Error += sizeof(glm::highp_i64vec2) != 16;
Error += sizeof(glm::highp_i64vec3) != 24;
Error += sizeof(glm::highp_i64vec4) != 32;
return Error;
}
static int test_ivec_precision()
{
int Error(0);
{
glm::i8vec2 v1;
glm::lowp_i8vec2 v2(v1);
glm::mediump_i8vec2 v3(v1);
glm::highp_i8vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i8vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec2(v4))) ? 0 : 1;
}
{
glm::i8vec3 v1;
glm::lowp_i8vec3 v2(v1);
glm::mediump_i8vec3 v3(v1);
glm::highp_i8vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i8vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec3(v4))) ? 0 : 1;
}
{
glm::i8vec4 v1;
glm::lowp_i8vec4 v2(v1);
glm::mediump_i8vec4 v3(v1);
glm::highp_i8vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i8vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i8vec4(v4))) ? 0 : 1;
}
{
glm::i16vec2 v1;
glm::lowp_i16vec2 v2(v1);
glm::mediump_i16vec2 v3(v1);
glm::highp_i16vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i16vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec2(v4))) ? 0 : 1;
}
{
glm::i16vec3 v1;
glm::lowp_i16vec3 v2(v1);
glm::mediump_i16vec3 v3(v1);
glm::highp_i16vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i16vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec3(v4))) ? 0 : 1;
}
{
glm::i16vec4 v1;
glm::lowp_i16vec4 v2(v1);
glm::mediump_i16vec4 v3(v1);
glm::highp_i16vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i16vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i16vec4(v4))) ? 0 : 1;
}
{
glm::i32vec2 v1;
glm::lowp_i32vec2 v2(v1);
glm::mediump_i32vec2 v3(v1);
glm::highp_i32vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i32vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec2(v4))) ? 0 : 1;
}
{
glm::i32vec3 v1;
glm::lowp_i32vec3 v2(v1);
glm::mediump_i32vec3 v3(v1);
glm::highp_i32vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i32vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec3(v4))) ? 0 : 1;
}
{
glm::i32vec4 v1;
glm::lowp_i32vec4 v2(v1);
glm::mediump_i32vec4 v3(v1);
glm::highp_i32vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i32vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i32vec4(v4))) ? 0 : 1;
}
{
glm::i64vec2 v1;
glm::lowp_i64vec2 v2(v1);
glm::mediump_i64vec2 v3(v1);
glm::highp_i64vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::i64vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec2(v4))) ? 0 : 1;
}
{
glm::i64vec3 v1;
glm::lowp_i64vec3 v2(v1);
glm::mediump_i64vec3 v3(v1);
glm::highp_i64vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::i64vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec3(v4))) ? 0 : 1;
}
{
glm::i64vec4 v1;
glm::lowp_i64vec4 v2(v1);
glm::mediump_i64vec4 v3(v1);
glm::highp_i64vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::i64vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::i64vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_uvec_size()
{
int Error(0);
Error += sizeof(glm::u8vec2) != 2;
Error += sizeof(glm::u8vec3) != 3;
Error += sizeof(glm::u8vec4) != 4;
Error += sizeof(glm::u16vec2) != 4;
Error += sizeof(glm::u16vec3) != 6;
Error += sizeof(glm::u16vec4) != 8;
Error += sizeof(glm::u32vec2) != 8;
Error += sizeof(glm::u32vec3) != 12;
Error += sizeof(glm::u32vec4) != 16;
Error += sizeof(glm::u64vec2) != 16;
Error += sizeof(glm::u64vec3) != 24;
Error += sizeof(glm::u64vec4) != 32;
Error += sizeof(glm::lowp_u8vec2) != 2;
Error += sizeof(glm::lowp_u8vec3) != 3;
Error += sizeof(glm::lowp_u8vec4) != 4;
Error += sizeof(glm::lowp_u16vec2) != 4;
Error += sizeof(glm::lowp_u16vec3) != 6;
Error += sizeof(glm::lowp_u16vec4) != 8;
Error += sizeof(glm::lowp_u32vec2) != 8;
Error += sizeof(glm::lowp_u32vec3) != 12;
Error += sizeof(glm::lowp_u32vec4) != 16;
Error += sizeof(glm::lowp_u64vec2) != 16;
Error += sizeof(glm::lowp_u64vec3) != 24;
Error += sizeof(glm::lowp_u64vec4) != 32;
Error += sizeof(glm::mediump_u8vec2) != 2;
Error += sizeof(glm::mediump_u8vec3) != 3;
Error += sizeof(glm::mediump_u8vec4) != 4;
Error += sizeof(glm::mediump_u16vec2) != 4;
Error += sizeof(glm::mediump_u16vec3) != 6;
Error += sizeof(glm::mediump_u16vec4) != 8;
Error += sizeof(glm::mediump_u32vec2) != 8;
Error += sizeof(glm::mediump_u32vec3) != 12;
Error += sizeof(glm::mediump_u32vec4) != 16;
Error += sizeof(glm::mediump_u64vec2) != 16;
Error += sizeof(glm::mediump_u64vec3) != 24;
Error += sizeof(glm::mediump_u64vec4) != 32;
Error += sizeof(glm::highp_u8vec2) != 2;
Error += sizeof(glm::highp_u8vec3) != 3;
Error += sizeof(glm::highp_u8vec4) != 4;
Error += sizeof(glm::highp_u16vec2) != 4;
Error += sizeof(glm::highp_u16vec3) != 6;
Error += sizeof(glm::highp_u16vec4) != 8;
Error += sizeof(glm::highp_u32vec2) != 8;
Error += sizeof(glm::highp_u32vec3) != 12;
Error += sizeof(glm::highp_u32vec4) != 16;
Error += sizeof(glm::highp_u64vec2) != 16;
Error += sizeof(glm::highp_u64vec3) != 24;
Error += sizeof(glm::highp_u64vec4) != 32;
return Error;
}
static int test_uvec_precision()
{
int Error(0);
{
glm::u8vec2 v1;
glm::lowp_u8vec2 v2(v1);
glm::mediump_u8vec2 v3(v1);
glm::highp_u8vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u8vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec2(v4))) ? 0 : 1;
}
{
glm::u8vec3 v1;
glm::lowp_u8vec3 v2(v1);
glm::mediump_u8vec3 v3(v1);
glm::highp_u8vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u8vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec3(v4))) ? 0 : 1;
}
{
glm::u8vec4 v1;
glm::lowp_u8vec4 v2(v1);
glm::mediump_u8vec4 v3(v1);
glm::highp_u8vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u8vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u8vec4(v4))) ? 0 : 1;
}
{
glm::u16vec2 v1;
glm::lowp_u16vec2 v2(v1);
glm::mediump_u16vec2 v3(v1);
glm::highp_u16vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u16vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec2(v4))) ? 0 : 1;
}
{
glm::u16vec3 v1;
glm::lowp_u16vec3 v2(v1);
glm::mediump_u16vec3 v3(v1);
glm::highp_u16vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u16vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec3(v4))) ? 0 : 1;
}
{
glm::u16vec4 v1;
glm::lowp_u16vec4 v2(v1);
glm::mediump_u16vec4 v3(v1);
glm::highp_u16vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u16vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u16vec4(v4))) ? 0 : 1;
}
{
glm::u32vec2 v1;
glm::lowp_u32vec2 v2(v1);
glm::mediump_u32vec2 v3(v1);
glm::highp_u32vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u32vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec2(v4))) ? 0 : 1;
}
{
glm::u32vec3 v1;
glm::lowp_u32vec3 v2(v1);
glm::mediump_u32vec3 v3(v1);
glm::highp_u32vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u32vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec3(v4))) ? 0 : 1;
}
{
glm::u32vec4 v1;
glm::lowp_u32vec4 v2(v1);
glm::mediump_u32vec4 v3(v1);
glm::highp_u32vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u32vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u32vec4(v4))) ? 0 : 1;
}
{
glm::u64vec2 v1;
glm::lowp_u64vec2 v2(v1);
glm::mediump_u64vec2 v3(v1);
glm::highp_u64vec2 v4(v1);
Error += glm::all(glm::equal(v1, glm::u64vec2(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec2(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec2(v4))) ? 0 : 1;
}
{
glm::u64vec3 v1;
glm::lowp_u64vec3 v2(v1);
glm::mediump_u64vec3 v3(v1);
glm::highp_u64vec3 v4(v1);
Error += glm::all(glm::equal(v1, glm::u64vec3(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec3(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec3(v4))) ? 0 : 1;
}
{
glm::u64vec4 v1;
glm::lowp_u64vec4 v2(v1);
glm::mediump_u64vec4 v3(v1);
glm::highp_u64vec4 v4(v1);
Error += glm::all(glm::equal(v1, glm::u64vec4(v2))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec4(v3))) ? 0 : 1;
Error += glm::all(glm::equal(v1, glm::u64vec4(v4))) ? 0 : 1;
}
return Error;
}
static int test_fmat_size()
{
int Error(0);
Error += sizeof(glm::mat2) != 16;
Error += sizeof(glm::mat3) != 36;
Error += sizeof(glm::mat4) != 64;
Error += sizeof(glm::mat2x2) != 16;
Error += sizeof(glm::mat2x3) != 24;
Error += sizeof(glm::mat2x4) != 32;
Error += sizeof(glm::mat3x2) != 24;
Error += sizeof(glm::mat3x3) != 36;
Error += sizeof(glm::mat3x4) != 48;
Error += sizeof(glm::mat4x2) != 32;
Error += sizeof(glm::mat4x3) != 48;
Error += sizeof(glm::mat4x4) != 64;
Error += sizeof(glm::fmat2) != 16;
Error += sizeof(glm::fmat3) != 36;
Error += sizeof(glm::fmat4) != 64;
Error += sizeof(glm::fmat2x2) != 16;
Error += sizeof(glm::fmat2x3) != 24;
Error += sizeof(glm::fmat2x4) != 32;
Error += sizeof(glm::fmat3x2) != 24;
Error += sizeof(glm::fmat3x3) != 36;
Error += sizeof(glm::fmat3x4) != 48;
Error += sizeof(glm::fmat4x2) != 32;
Error += sizeof(glm::fmat4x3) != 48;
Error += sizeof(glm::fmat4x4) != 64;
Error += sizeof(glm::f32mat2) != 16;
Error += sizeof(glm::f32mat3) != 36;
Error += sizeof(glm::f32mat4) != 64;
Error += sizeof(glm::f32mat2x2) != 16;
Error += sizeof(glm::f32mat2x3) != 24;
Error += sizeof(glm::f32mat2x4) != 32;
Error += sizeof(glm::f32mat3x2) != 24;
Error += sizeof(glm::f32mat3x3) != 36;
Error += sizeof(glm::f32mat3x4) != 48;
Error += sizeof(glm::f32mat4x2) != 32;
Error += sizeof(glm::f32mat4x3) != 48;
Error += sizeof(glm::f32mat4x4) != 64;
Error += sizeof(glm::lowp_mat2) != 16;
Error += sizeof(glm::lowp_mat3) != 36;
Error += sizeof(glm::lowp_mat4) != 64;
Error += sizeof(glm::lowp_mat2x2) != 16;
Error += sizeof(glm::lowp_mat2x3) != 24;
Error += sizeof(glm::lowp_mat2x4) != 32;
Error += sizeof(glm::lowp_mat3x2) != 24;
Error += sizeof(glm::lowp_mat3x3) != 36;
Error += sizeof(glm::lowp_mat3x4) != 48;
Error += sizeof(glm::lowp_mat4x2) != 32;
Error += sizeof(glm::lowp_mat4x3) != 48;
Error += sizeof(glm::lowp_mat4x4) != 64;
Error += sizeof(glm::lowp_fmat2) != 16;
Error += sizeof(glm::lowp_fmat3) != 36;
Error += sizeof(glm::lowp_fmat4) != 64;
Error += sizeof(glm::lowp_fmat2x2) != 16;
Error += sizeof(glm::lowp_fmat2x3) != 24;
Error += sizeof(glm::lowp_fmat2x4) != 32;
Error += sizeof(glm::lowp_fmat3x2) != 24;
Error += sizeof(glm::lowp_fmat3x3) != 36;
Error += sizeof(glm::lowp_fmat3x4) != 48;
Error += sizeof(glm::lowp_fmat4x2) != 32;
Error += sizeof(glm::lowp_fmat4x3) != 48;
Error += sizeof(glm::lowp_fmat4x4) != 64;
Error += sizeof(glm::lowp_f32mat2) != 16;
Error += sizeof(glm::lowp_f32mat3) != 36;
Error += sizeof(glm::lowp_f32mat4) != 64;
Error += sizeof(glm::lowp_f32mat2x2) != 16;
Error += sizeof(glm::lowp_f32mat2x3) != 24;
Error += sizeof(glm::lowp_f32mat2x4) != 32;
Error += sizeof(glm::lowp_f32mat3x2) != 24;
Error += sizeof(glm::lowp_f32mat3x3) != 36;
Error += sizeof(glm::lowp_f32mat3x4) != 48;
Error += sizeof(glm::lowp_f32mat4x2) != 32;
Error += sizeof(glm::lowp_f32mat4x3) != 48;
Error += sizeof(glm::lowp_f32mat4x4) != 64;
Error += sizeof(glm::mediump_mat2) != 16;
Error += sizeof(glm::mediump_mat3) != 36;
Error += sizeof(glm::mediump_mat4) != 64;
Error += sizeof(glm::mediump_mat2x2) != 16;
Error += sizeof(glm::mediump_mat2x3) != 24;
Error += sizeof(glm::mediump_mat2x4) != 32;
Error += sizeof(glm::mediump_mat3x2) != 24;
Error += sizeof(glm::mediump_mat3x3) != 36;
Error += sizeof(glm::mediump_mat3x4) != 48;
Error += sizeof(glm::mediump_mat4x2) != 32;
Error += sizeof(glm::mediump_mat4x3) != 48;
Error += sizeof(glm::mediump_mat4x4) != 64;
Error += sizeof(glm::mediump_fmat2) != 16;
Error += sizeof(glm::mediump_fmat3) != 36;
Error += sizeof(glm::mediump_fmat4) != 64;
Error += sizeof(glm::mediump_fmat2x2) != 16;
Error += sizeof(glm::mediump_fmat2x3) != 24;
Error += sizeof(glm::mediump_fmat2x4) != 32;
Error += sizeof(glm::mediump_fmat3x2) != 24;
Error += sizeof(glm::mediump_fmat3x3) != 36;
Error += sizeof(glm::mediump_fmat3x4) != 48;
Error += sizeof(glm::mediump_fmat4x2) != 32;
Error += sizeof(glm::mediump_fmat4x3) != 48;
Error += sizeof(glm::mediump_fmat4x4) != 64;
Error += sizeof(glm::mediump_f32mat2) != 16;
Error += sizeof(glm::mediump_f32mat3) != 36;
Error += sizeof(glm::mediump_f32mat4) != 64;
Error += sizeof(glm::mediump_f32mat2x2) != 16;
Error += sizeof(glm::mediump_f32mat2x3) != 24;
Error += sizeof(glm::mediump_f32mat2x4) != 32;
Error += sizeof(glm::mediump_f32mat3x2) != 24;
Error += sizeof(glm::mediump_f32mat3x3) != 36;
Error += sizeof(glm::mediump_f32mat3x4) != 48;
Error += sizeof(glm::mediump_f32mat4x2) != 32;
Error += sizeof(glm::mediump_f32mat4x3) != 48;
Error += sizeof(glm::mediump_f32mat4x4) != 64;
Error += sizeof(glm::highp_mat2) != 16;
Error += sizeof(glm::highp_mat3) != 36;
Error += sizeof(glm::highp_mat4) != 64;
Error += sizeof(glm::highp_mat2x2) != 16;
Error += sizeof(glm::highp_mat2x3) != 24;
Error += sizeof(glm::highp_mat2x4) != 32;
Error += sizeof(glm::highp_mat3x2) != 24;
Error += sizeof(glm::highp_mat3x3) != 36;
Error += sizeof(glm::highp_mat3x4) != 48;
Error += sizeof(glm::highp_mat4x2) != 32;
Error += sizeof(glm::highp_mat4x3) != 48;
Error += sizeof(glm::highp_mat4x4) != 64;
Error += sizeof(glm::highp_fmat2) != 16;
Error += sizeof(glm::highp_fmat3) != 36;
Error += sizeof(glm::highp_fmat4) != 64;
Error += sizeof(glm::highp_fmat2x2) != 16;
Error += sizeof(glm::highp_fmat2x3) != 24;
Error += sizeof(glm::highp_fmat2x4) != 32;
Error += sizeof(glm::highp_fmat3x2) != 24;
Error += sizeof(glm::highp_fmat3x3) != 36;
Error += sizeof(glm::highp_fmat3x4) != 48;
Error += sizeof(glm::highp_fmat4x2) != 32;
Error += sizeof(glm::highp_fmat4x3) != 48;
Error += sizeof(glm::highp_fmat4x4) != 64;
Error += sizeof(glm::highp_f32mat2) != 16;
Error += sizeof(glm::highp_f32mat3) != 36;
Error += sizeof(glm::highp_f32mat4) != 64;
Error += sizeof(glm::highp_f32mat2x2) != 16;
Error += sizeof(glm::highp_f32mat2x3) != 24;
Error += sizeof(glm::highp_f32mat2x4) != 32;
Error += sizeof(glm::highp_f32mat3x2) != 24;
Error += sizeof(glm::highp_f32mat3x3) != 36;
Error += sizeof(glm::highp_f32mat3x4) != 48;
Error += sizeof(glm::highp_f32mat4x2) != 32;
Error += sizeof(glm::highp_f32mat4x3) != 48;
Error += sizeof(glm::highp_f32mat4x4) != 64;
return Error;
}
static int test_dmat_size()
{
int Error(0);
Error += sizeof(glm::f64mat2) != 32;
Error += sizeof(glm::f64mat3) != 72;
Error += sizeof(glm::f64mat4) != 128;
Error += sizeof(glm::f64mat2x2) != 32;
Error += sizeof(glm::f64mat2x3) != 48;
Error += sizeof(glm::f64mat2x4) != 64;
Error += sizeof(glm::f64mat3x2) != 48;
Error += sizeof(glm::f64mat3x3) != 72;
Error += sizeof(glm::f64mat3x4) != 96;
Error += sizeof(glm::f64mat4x2) != 64;
Error += sizeof(glm::f64mat4x3) != 96;
Error += sizeof(glm::f64mat4x4) != 128;
Error += sizeof(glm::lowp_f64mat2) != 32;
Error += sizeof(glm::lowp_f64mat3) != 72;
Error += sizeof(glm::lowp_f64mat4) != 128;
Error += sizeof(glm::lowp_f64mat2x2) != 32;
Error += sizeof(glm::lowp_f64mat2x3) != 48;
Error += sizeof(glm::lowp_f64mat2x4) != 64;
Error += sizeof(glm::lowp_f64mat3x2) != 48;
Error += sizeof(glm::lowp_f64mat3x3) != 72;
Error += sizeof(glm::lowp_f64mat3x4) != 96;
Error += sizeof(glm::lowp_f64mat4x2) != 64;
Error += sizeof(glm::lowp_f64mat4x3) != 96;
Error += sizeof(glm::lowp_f64mat4x4) != 128;
Error += sizeof(glm::mediump_f64mat2) != 32;
Error += sizeof(glm::mediump_f64mat3) != 72;
Error += sizeof(glm::mediump_f64mat4) != 128;
Error += sizeof(glm::mediump_f64mat2x2) != 32;
Error += sizeof(glm::mediump_f64mat2x3) != 48;
Error += sizeof(glm::mediump_f64mat2x4) != 64;
Error += sizeof(glm::mediump_f64mat3x2) != 48;
Error += sizeof(glm::mediump_f64mat3x3) != 72;
Error += sizeof(glm::mediump_f64mat3x4) != 96;
Error += sizeof(glm::mediump_f64mat4x2) != 64;
Error += sizeof(glm::mediump_f64mat4x3) != 96;
Error += sizeof(glm::mediump_f64mat4x4) != 128;
Error += sizeof(glm::highp_f64mat2) != 32;
Error += sizeof(glm::highp_f64mat3) != 72;
Error += sizeof(glm::highp_f64mat4) != 128;
Error += sizeof(glm::highp_f64mat2x2) != 32;
Error += sizeof(glm::highp_f64mat2x3) != 48;
Error += sizeof(glm::highp_f64mat2x4) != 64;
Error += sizeof(glm::highp_f64mat3x2) != 48;
Error += sizeof(glm::highp_f64mat3x3) != 72;
Error += sizeof(glm::highp_f64mat3x4) != 96;
Error += sizeof(glm::highp_f64mat4x2) != 64;
Error += sizeof(glm::highp_f64mat4x3) != 96;
Error += sizeof(glm::highp_f64mat4x4) != 128;
return Error;
}
static int test_quat_size()
{
int Error = 0;
Error += sizeof(glm::f32quat) != 16;
Error += sizeof(glm::f64quat) != 32;
Error += sizeof(glm::lowp_f32quat) != 16;
Error += sizeof(glm::lowp_f64quat) != 32;
Error += sizeof(glm::mediump_f32quat) != 16;
Error += sizeof(glm::mediump_f64quat) != 32;
Error += sizeof(glm::highp_f32quat) != 16;
Error += sizeof(glm::highp_f64quat) != 32;
return Error;
}
static int test_quat_precision()
{
int Error(0);
{
glm::f32quat q1;
glm::lowp_f32quat qA(q1);
glm::mediump_f32quat qB(q1);
glm::highp_f32quat qC(q1);
glm::f32quat q2(qA);
glm::f32quat q3(qB);
glm::f32quat q4(qC);
Error += glm::all(glm::equal(q1, q2)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q3)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q4)) ? 0 : 1;
}
return Error;
}
static int test_fvec_conversion()
{
int Error(0);
{
glm::highp_vec4 a = glm::vec4(1, 2, 3, 4);
glm::mediump_vec4 b = glm::vec4(1, 2, 3, 4);
glm::lowp_vec4 c = b;
glm::mediump_vec4 d = c;
glm::lowp_ivec4 e = glm::ivec4(d);
glm::lowp_ivec3 f = glm::ivec3(e);
Error += glm::all(glm::equal(b, d)) ? 0 : 1;
}
return Error;
}
static int test_openmp()
{
std::vector<glm::u8vec3> VectorA(1000);
std::vector<glm::u8vec3> VectorB(1000);
std::vector<glm::u8vec3> VectorC(1000);
for (std::size_t i = 0; i < VectorA.size(); ++i)
{
VectorA[i] = glm::u8vec3(1, 1, 1);
VectorB[i] = glm::u8vec3(1, 1, 1);
}
#pragma omp parallel for default(none) shared(VectorA, VectorB, VectorC)
for (int i = 0; i < VectorC.size(); ++i)
{
VectorC[i] = VectorA[i] + VectorB[i];
}
return 0;
}
int main()
{
int Error(0);
Error += test_openmp();
Error += test_scalar_size();
Error += test_fvec_size();
Error += test_fvec_precision();
Error += test_fvec_conversion();
Error += test_dvec_precision();
Error += test_ivec_size();
Error += test_ivec_precision();
Error += test_uvec_size();
Error += test_uvec_precision();
Error += test_fmat_size();
Error += test_dmat_size();
Error += test_quat_size();
Error += test_quat_precision();
return Error;
}

283
external/glm/test/gtc/gtc_type_ptr.cpp vendored Normal file
View file

@ -0,0 +1,283 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_type_ptr.cpp
/// @date 2010-09-16 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/type_ptr.hpp>
int test_value_ptr_vec()
{
int Error = 0;
{
glm::vec2 v(1.0);
float * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec3 v(1.0);
float * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec4 v(1.0);
float * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec2 v(1.0);
double * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec3 v(1.0);
double * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec4 v(1.0);
double * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
return Error;
}
int test_value_ptr_vec_const()
{
int Error = 0;
{
glm::vec2 const v(1.0);
float const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec3 const v(1.0);
float const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::vec4 const v(1.0);
float const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec2 const v(1.0);
double const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec3 const v(1.0);
double const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
{
glm::dvec4 const v(1.0);
double const * p = glm::value_ptr(v);
Error += p == &v[0] ? 0 : 1;
}
return Error;
}
int test_value_ptr_mat()
{
int Error = 0;
{
glm::mat2x2 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x3 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x4 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x2 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x3 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x4 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x2 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x3 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x4 m(1.0);
float * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
return Error;
}
int test_value_ptr_mat_const()
{
int Error = 0;
{
glm::mat2x2 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x3 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat2x4 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x2 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x3 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat3x4 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x2 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x3 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
{
glm::mat4x4 const m(1.0);
float const * p = glm::value_ptr(m);
Error += p == &m[0][0] ? 0 : 1;
}
return Error;
}
int test_make_pointer_mat()
{
int Error = 0;
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
double ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
glm::mat2x2 Mat2x2A = glm::make_mat2x2(ArrayA);
glm::mat2x3 Mat2x3A = glm::make_mat2x3(ArrayA);
glm::mat2x4 Mat2x4A = glm::make_mat2x4(ArrayA);
glm::mat3x2 Mat3x2A = glm::make_mat3x2(ArrayA);
glm::mat3x3 Mat3x3A = glm::make_mat3x3(ArrayA);
glm::mat3x4 Mat3x4A = glm::make_mat3x4(ArrayA);
glm::mat4x2 Mat4x2A = glm::make_mat4x2(ArrayA);
glm::mat4x3 Mat4x3A = glm::make_mat4x3(ArrayA);
glm::mat4x4 Mat4x4A = glm::make_mat4x4(ArrayA);
glm::dmat2x2 Mat2x2B = glm::make_mat2x2(ArrayB);
glm::dmat2x3 Mat2x3B = glm::make_mat2x3(ArrayB);
glm::dmat2x4 Mat2x4B = glm::make_mat2x4(ArrayB);
glm::dmat3x2 Mat3x2B = glm::make_mat3x2(ArrayB);
glm::dmat3x3 Mat3x3B = glm::make_mat3x3(ArrayB);
glm::dmat3x4 Mat3x4B = glm::make_mat3x4(ArrayB);
glm::dmat4x2 Mat4x2B = glm::make_mat4x2(ArrayB);
glm::dmat4x3 Mat4x3B = glm::make_mat4x3(ArrayB);
glm::dmat4x4 Mat4x4B = glm::make_mat4x4(ArrayB);
return Error;
}
int test_make_pointer_vec()
{
int Error = 0;
float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
bool ArrayC[] = {true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false};
glm::vec2 Vec2A = glm::make_vec2(ArrayA);
glm::vec3 Vec3A = glm::make_vec3(ArrayA);
glm::vec4 Vec4A = glm::make_vec4(ArrayA);
glm::ivec2 Vec2B = glm::make_vec2(ArrayB);
glm::ivec3 Vec3B = glm::make_vec3(ArrayB);
glm::ivec4 Vec4B = glm::make_vec4(ArrayB);
glm::bvec2 Vec2C = glm::make_vec2(ArrayC);
glm::bvec3 Vec3C = glm::make_vec3(ArrayC);
glm::bvec4 Vec4C = glm::make_vec4(ArrayC);
return Error;
}
int main()
{
int Error = 0;
Error += test_make_pointer_vec();
Error += test_make_pointer_mat();
Error += test_value_ptr_vec();
Error += test_value_ptr_vec_const();
Error += test_value_ptr_mat();
Error += test_value_ptr_mat_const();
return Error;
}

127
external/glm/test/gtc/gtc_ulp.cpp vendored Normal file
View file

@ -0,0 +1,127 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_ulp.cpp
/// @date 2011-04-26 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/ulp.hpp>
#include <limits>
int test_ulp_float_dist()
{
int Error = 0;
float A = 1.0f;
float B = glm::next_float(A);
Error += A != B ? 0 : 1;
float C = glm::prev_float(B);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == 1 ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
return Error;
}
int test_ulp_float_step()
{
int Error = 0;
float A = 1.0f;
for(int i = 10; i < 1000; i *= 10)
{
float B = glm::next_float(A, i);
Error += A != B ? 0 : 1;
float C = glm::prev_float(B, i);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == i ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
}
return Error;
}
int test_ulp_double_dist()
{
int Error = 0;
double A = 1.0;
double B = glm::next_float(A);
Error += A != B ? 0 : 1;
double C = glm::prev_float(B);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == 1 ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
return Error;
}
int test_ulp_double_step()
{
int Error = 0;
double A = 1.0;
for(int i = 10; i < 1000; i *= 10)
{
double B = glm::next_float(A, i);
Error += A != B ? 0 : 1;
double C = glm::prev_float(B, i);
Error += A == C ? 0 : 1;
int D = glm::float_distance(A, B);
Error += D == i ? 0 : 1;
int E = glm::float_distance(A, C);
Error += E == 0 ? 0 : 1;
}
return Error;
}
int main()
{
int Error = 0;
Error += test_ulp_float_dist();
Error += test_ulp_float_step();
Error += test_ulp_double_dist();
Error += test_ulp_double_step();
return Error;
}

View file

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-16
// Updated : 2011-05-27
// Licence : This source is under MIT licence
// File : test/gtc/type_ptr.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_RADIANS
#include <glm/gtc/user_defined_type.hpp>
int test_make_pointer_vec()
{
int Error = 0;
glm::func();
//func();
return Error;
}
int main()
{
int Error = 0;
Error += test_make_pointer_vec();
return Error;
}

39
external/glm/test/gtc/gtc_vec1.cpp vendored Normal file
View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////
/// 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/gtc/gtc_vec1.cpp
/// @date 2014-10-11 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtc/vec1.hpp>
int main()
{
int Error = 0;
return Error;
}