Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jan p springer
2016-03-14 12:35:35 +00:00
85 changed files with 1263 additions and 1815 deletions

View File

@@ -3,7 +3,6 @@ glmCreateTestGTC(core_type_ctor)
glmCreateTestGTC(core_type_float)
glmCreateTestGTC(core_type_int)
glmCreateTestGTC(core_type_length)
glmCreateTestGTC(core_type_length_size)
glmCreateTestGTC(core_type_mat2x2)
glmCreateTestGTC(core_type_mat2x3)
glmCreateTestGTC(core_type_mat2x4)

View File

@@ -599,7 +599,7 @@ namespace round_
int test()
{
int Error = 0;
{
float A = glm::round(0.0f);
Error += A == 0.0f ? 0 : 1;
@@ -1153,6 +1153,86 @@ namespace sign
}
}//namespace sign
namespace frexp_
{
int test()
{
int Error(0);
{
glm::vec1 x(1024);
glm::ivec1 exp;
glm::vec1 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec1(0.5), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec1(11))) ? 0 : 1;
}
{
glm::vec2 x(1024, 0.24);
glm::ivec2 exp;
glm::vec2 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec2(0.5, 0.96), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec2(11, -2))) ? 0 : 1;
}
{
glm::vec3 x(1024, 0.24, 0);
glm::ivec3 exp;
glm::vec3 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec3(0.5, 0.96, 0.0), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec3(11, -2, 0))) ? 0 : 1;
}
{
glm::vec4 x(1024, 0.24, 0, -1.33);
glm::ivec4 exp;
glm::vec4 A = glm::frexp(x, exp);
Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.5, 0.96, 0.0, -0.665), 0.00001f)) ? 0 : 1;
Error += glm::all(glm::equal(exp, glm::ivec4(11, -2, 0, 1))) ? 0 : 1;
}
return Error;
}
}//namespace frexp_
namespace ldexp_
{
int test()
{
int Error(0);
{
glm::vec1 A = glm::vec1(0.5);
glm::ivec1 exp = glm::ivec1(11);
glm::vec1 x = glm::ldexp(A, exp);
Error += glm::all(glm::epsilonEqual(x, glm::vec1(1024),0.00001f)) ? 0 : 1;
}
{
glm::vec2 A = glm::vec2(0.5, 0.96);
glm::ivec2 exp = glm::ivec2(11, -2);
glm::vec2 x = glm::ldexp(A, exp);
Error += glm::all(glm::epsilonEqual(x, glm::vec2(1024, .24),0.00001f)) ? 0 : 1;
}
{
glm::vec3 A = glm::vec3(0.5, 0.96, 0.0);
glm::ivec3 exp = glm::ivec3(11, -2, 0);
glm::vec3 x = glm::ldexp(A, exp);
Error += glm::all(glm::epsilonEqual(x, glm::vec3(1024, .24, 0),0.00001f)) ? 0 : 1;
}
{
glm::vec4 A = glm::vec4(0.5, 0.96, 0.0, -0.665);
glm::ivec4 exp = glm::ivec4(11, -2, 0, 1);
glm::vec4 x = glm::ldexp(A, exp);
Error += glm::all(glm::epsilonEqual(x, glm::vec4(1024, .24, 0, -1.33),0.00001f)) ? 0 : 1;
}
return Error;
}
}//namespace ldexp_
int main()
{
int Error(0);
@@ -1171,6 +1251,8 @@ int main()
Error += roundEven::test();
Error += isnan_::test();
Error += isinf_::test();
Error += frexp_::test();
Error += ldexp_::test();
# ifdef NDEBUG
std::size_t Samples = 1000;

View File

@@ -101,7 +101,18 @@ int test_matrixCompMult()
int test_outerProduct()
{
glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f));
{ glm::mat2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec2(1.0f)); }
{ glm::mat3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec3(1.0f)); }
{ glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f)); }
{ glm::mat2x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec2(1.0f)); }
{ glm::mat2x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec2(1.0f)); }
{ glm::mat3x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec3(1.0f)); }
{ glm::mat3x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec3(1.0f)); }
{ glm::mat4x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec4(1.0f)); }
{ glm::mat4x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec4(1.0f)); }
return 0;
}

View File

@@ -80,7 +80,13 @@ int test_packSnorm2x16()
int test_packUnorm4x8()
{
int Error = 0;
glm::uint32 Packed = glm::packUnorm4x8(glm::vec4(1.0f, 0.5f, 0.0f, 1.0f));
glm::u8vec4 Vec(255, 128, 0, 255);
glm::uint32 & Ref = *reinterpret_cast<glm::uint32*>(&Vec[0]);
Error += Packed == Ref ? 0 : 1;
std::vector<glm::vec4> A;
A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f));
A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f));

View File

@@ -71,6 +71,9 @@ int test_compiler()
case GLM_COMPILER_GCC53:
std::printf("GLM_COMPILER_GCC53\n");
break;
case GLM_COMPILER_GCC60:
std::printf("GLM_COMPILER_GCC60\n");
break;
default:
std::printf("GCC version not detected\n");
Error += 1;

View File

@@ -1,116 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
/// OpenGL Mathematics (glm.g-truc.net)
///
/// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net)
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// Restrictions:
/// By making use of the Software for military purposes, you choose to make
/// a Bunny unhappy.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
///
/// @file test/core/core_type_length_size.cpp
/// @date 2011-05-25 / 2014-11-25
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_FORCE_SIZE_FUNC
#include <glm/glm.hpp>
#include <glm/gtc/vec1.hpp>
int test_length_mat_non_squared()
{
int Error = 0;
Error += glm::mat2x3().size() == 2 ? 0 : 1;
Error += glm::mat2x4().size() == 2 ? 0 : 1;
Error += glm::mat3x2().size() == 3 ? 0 : 1;
Error += glm::mat3x4().size() == 3 ? 0 : 1;
Error += glm::mat4x2().size() == 4 ? 0 : 1;
Error += glm::mat4x3().size() == 4 ? 0 : 1;
Error += glm::dmat2x3().size() == 2 ? 0 : 1;
Error += glm::dmat2x4().size() == 2 ? 0 : 1;
Error += glm::dmat3x2().size() == 3 ? 0 : 1;
Error += glm::dmat3x4().size() == 3 ? 0 : 1;
Error += glm::dmat4x2().size() == 4 ? 0 : 1;
Error += glm::dmat4x3().size() == 4 ? 0 : 1;
return Error;
}
int test_length_mat()
{
int Error = 0;
Error += glm::mat2().size() == 2 ? 0 : 1;
Error += glm::mat3().size() == 3 ? 0 : 1;
Error += glm::mat4().size() == 4 ? 0 : 1;
Error += glm::mat2x2().size() == 2 ? 0 : 1;
Error += glm::mat3x3().size() == 3 ? 0 : 1;
Error += glm::mat4x4().size() == 4 ? 0 : 1;
Error += glm::dmat2().size() == 2 ? 0 : 1;
Error += glm::dmat3().size() == 3 ? 0 : 1;
Error += glm::dmat4().size() == 4 ? 0 : 1;
Error += glm::dmat2x2().size() == 2 ? 0 : 1;
Error += glm::dmat3x3().size() == 3 ? 0 : 1;
Error += glm::dmat4x4().size() == 4 ? 0 : 1;
return Error;
}
int test_length_vec()
{
int Error = 0;
Error += glm::vec1().size() == 1 ? 0 : 1;
Error += glm::vec2().size() == 2 ? 0 : 1;
Error += glm::vec3().size() == 3 ? 0 : 1;
Error += glm::vec4().size() == 4 ? 0 : 1;
Error += glm::ivec1().size() == 1 ? 0 : 1;
Error += glm::ivec2().size() == 2 ? 0 : 1;
Error += glm::ivec3().size() == 3 ? 0 : 1;
Error += glm::ivec4().size() == 4 ? 0 : 1;
Error += glm::uvec1().size() == 1 ? 0 : 1;
Error += glm::uvec2().size() == 2 ? 0 : 1;
Error += glm::uvec3().size() == 3 ? 0 : 1;
Error += glm::uvec4().size() == 4 ? 0 : 1;
Error += glm::dvec1().size() == 1 ? 0 : 1;
Error += glm::dvec2().size() == 2 ? 0 : 1;
Error += glm::dvec3().size() == 3 ? 0 : 1;
Error += glm::dvec4().size() == 4 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_length_vec();
Error += test_length_mat();
Error += test_length_mat_non_squared();
return Error;
}

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
@@ -87,15 +86,6 @@ int test_inverse()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat2x2(1) == glm::mat2x2::IDENTITY ? 0 : 1;
Error += glm::mat2x2(0) == glm::mat2x2::ZERO ? 0 : 1;
return Error;
}
int test_ctr()
{
int Error(0);
@@ -177,13 +167,7 @@ int main()
{
int Error(0);
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat2::rows == glm::mat2::row_type::components);
assert(glm::mat2::cols == glm::mat2::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_operators();
Error += test_inverse();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
@@ -103,16 +102,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat2x3(1) == glm::mat2x3::IDENTITY ? 0 : 1;
Error += glm::mat2x3(0) == glm::mat2x3::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -152,13 +141,7 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat2x3::rows == glm::mat2x3::row_type::components);
assert(glm::mat2x3::cols == glm::mat2x3::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_operators();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
@@ -103,15 +102,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat2x4(1) == glm::mat2x4::IDENTITY ? 0 : 1;
Error += glm::mat2x4(0) == glm::mat2x4::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -151,13 +141,7 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat2x4::rows == glm::mat2x4::row_type::components);
assert(glm::mat2x4::cols == glm::mat2x4::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_operators();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
@@ -107,16 +106,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat3x2(1) == glm::mat3x2::IDENTITY ? 0 : 1;
Error += glm::mat3x2(0) == glm::mat3x2::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -156,14 +145,8 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat3x2::rows == glm::mat3x2::row_type::components);
assert(glm::mat3x2::cols == glm::mat3x2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_static_const();
Error += test_operators();
return Error;

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
@@ -166,15 +165,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat3x3(1) == glm::mat3x3::IDENTITY ? 0 : 1;
Error += glm::mat3x3(0) == glm::mat3x3::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -214,13 +204,7 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat3::rows == glm::mat3::row_type::components);
assert(glm::mat3::cols == glm::mat3::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_mat3x3();
Error += test_operators();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
@@ -107,15 +106,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat3x4(1) == glm::mat3x4::IDENTITY ? 0 : 1;
Error += glm::mat3x4(0) == glm::mat3x4::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -155,13 +145,7 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat3x4::rows == glm::mat3x4::row_type::components);
assert(glm::mat3x4::cols == glm::mat3x4::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_operators();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
@@ -111,15 +110,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat4x2(1) == glm::mat4x2::IDENTITY ? 0 : 1;
Error += glm::mat4x2(0) == glm::mat4x2::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -159,13 +149,7 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat4x2::rows == glm::mat4x2::row_type::components);
assert(glm::mat4x2::cols == glm::mat4x2::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_operators();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
@@ -111,15 +110,6 @@ int test_ctr()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat4x3(1) == glm::mat4x3::IDENTITY ? 0 : 1;
Error += glm::mat4x3(0) == glm::mat4x3::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -159,13 +149,7 @@ int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat4x3::rows == glm::mat4x3::row_type::components);
assert(glm::mat4x3::cols == glm::mat4x3::col_type::components);
#endif
Error += cast::test();
Error += test_static_const();
Error += test_ctr();
Error += test_operators();

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#define GLM_SIMD
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
@@ -284,15 +283,6 @@ int perf_mul()
return Error;
}
int test_static_const() {
int Error(0);
Error += glm::mat4x4(1) == glm::mat4x4::IDENTITY ? 0 : 1;
Error += glm::mat4x4(0) == glm::mat4x4::ZERO ? 0 : 1;
return Error;
}
namespace cast
{
template <typename genType>
@@ -342,14 +332,8 @@ int main()
repro Repro;
#ifdef GLM_META_PROG_HELPERS
assert(glm::mat4::rows == glm::mat4::row_type::components);
assert(glm::mat4::cols == glm::mat4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_static_const();
Error += test_inverse_dmat4x4();
Error += test_inverse_mat4x4();
Error += test_operators();

View File

@@ -29,10 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
# define GLM_META_PROG_HELPERS
#endif
#define GLM_STATIC_CONST_MEMBERS
#define GLM_SWIZZLE
#include <glm/vector_relational.hpp>
#include <glm/gtc/vec1.hpp>
@@ -135,7 +131,6 @@ int test_vec1_size()
Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1;
Error += glm::vec1().length() == 1 ? 0 : 1;
Error += glm::dvec1().length() == 1 ? 0 : 1;
Error += glm::vec1::components == 1 ? 0 : 1;
return Error;
}
@@ -167,18 +162,6 @@ int test_vec1_operator_increment()
return Error;
}
int test_vec1_static_const() {
int Error = 0;
Error += (glm::vec1(1.0f) == glm::vec1::X) ? 0 : 1;
Error += (glm::ivec1(1) == glm::ivec1::X) ? 0 : 1;
Error += (glm::dvec1(1.0) == glm::dvec1::X) ? 0 : 1;
Error += (glm::bvec1(false) == glm::bvec1::ZERO) ? 0 : 1;
Error += (glm::uvec1(0) == glm::uvec1::ZERO) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@@ -186,12 +169,6 @@ int main()
glm::vec1 v;
assert(v.length() == 1);
# ifdef GLM_META_PROG_HELPERS
assert(glm::vec1::components == glm::vec1().length());
assert(glm::vec1::components == 1);
# endif
Error += test_vec1_static_const();
Error += test_vec1_size();
Error += test_vec1_ctor();
Error += test_vec1_operators();

View File

@@ -29,10 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
# define GLM_META_PROG_HELPERS
#endif
#define GLM_SWIZZLE
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
@@ -301,7 +297,6 @@ int test_vec2_size()
Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1;
Error += glm::vec2().length() == 2 ? 0 : 1;
Error += glm::dvec2().length() == 2 ? 0 : 1;
Error += glm::vec2::components == 2 ? 0 : 1;
return Error;
}
@@ -333,17 +328,6 @@ int test_operator_increment()
return Error;
}
int test_vec2_static_const() {
int Error(0);
Error += (glm::ivec2(0, 0) == glm::ivec2::ZERO) ? 0 : 1;
Error += (glm::vec2(1, 0) == glm::vec2::X) ? 0 : 1;
Error += (glm::bvec2(false, true) == glm::bvec2::Y) ? 0 : 1;
Error += (glm::dvec2(1, 1) == glm::dvec2::XY) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@@ -351,12 +335,6 @@ int main()
glm::vec2 v;
assert(v.length() == 2);
# ifdef GLM_META_PROG_HELPERS
assert(glm::vec2::components == glm::vec2().length());
assert(glm::vec2::components == 2);
# endif
Error += test_vec2_static_const();
Error += test_vec2_size();
Error += test_vec2_ctor();
Error += test_vec2_operators();

View File

@@ -29,11 +29,7 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
# define GLM_META_PROG_HELPERS
#endif
#define GLM_SWIZZLE
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/geometric.hpp>
#include <glm/vec2.hpp>
@@ -267,7 +263,6 @@ int test_vec3_size()
Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1;
Error += glm::vec3().length() == 3 ? 0 : 1;
Error += glm::dvec3().length() == 3 ? 0 : 1;
Error += glm::vec3::components == 3 ? 0 : 1;
return Error;
}
@@ -494,21 +489,6 @@ int test_operator_increment()
return Error;
}
int test_vec3_static_const() {
int Error(0);
Error += (glm::ivec3(0, 0, 0) == glm::ivec3::ZERO) ? 0 : 1;
Error += (glm::vec3(1, 0, 0) == glm::vec3::X) ? 0 : 1;
Error += (glm::bvec3(false, true, false) == glm::bvec3::Y) ? 0 : 1;
Error += (glm::bvec3(false, false, true) == glm::bvec3::Z) ? 0 : 1;
Error += (glm::dvec3(1, 1, 0) == glm::dvec3::XY) ? 0 : 1;
Error += (glm::vec3(1, 0, 1) == glm::vec3::XZ) ? 0 : 1;
Error += (glm::uvec3(0u, 1u, 1u) == glm::uvec3::YZ) ? 0 : 1;
Error += (glm::dvec3(1, 1, 1) == glm::dvec3::XYZ) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@@ -516,12 +496,6 @@ int main()
glm::vec3 v;
assert(v.length() == 3);
# ifdef GLM_META_PROG_HELPERS
assert(glm::vec3::components == glm::vec3().length());
assert(glm::vec3::components == 3);
# endif
Error += test_vec3_static_const();
Error += test_vec3_ctor();
Error += test_vec3_operators();
Error += test_vec3_size();

View File

@@ -29,11 +29,7 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#if !(GLM_COMPILER & GLM_COMPILER_GCC)
# define GLM_META_PROG_HELPERS
#endif
#define GLM_SWIZZLE
#define GLM_STATIC_CONST_MEMBERS
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
@@ -397,28 +393,6 @@ int test_operator_increment()
return Error;
}
int test_vec4_static_const() {
int Error(0);
Error += (glm::ivec4(0, 0, 0, 0) == glm::ivec4::ZERO) ? 0 : 1;
Error += (glm::vec4(1, 0, 0, 0) == glm::vec4::X) ? 0 : 1;
Error += (glm::bvec4(false, true, false, false) == glm::bvec4::Y) ? 0 : 1;
Error += (glm::bvec4(false, false, true, false) == glm::bvec4::Z) ? 0 : 1;
Error += (glm::uvec4(0u, 0u, 0u, 1u) == glm::uvec4::W) ? 0 : 1;
Error += (glm::dvec4(1, 1, 0, 0) == glm::dvec4::XY) ? 0 : 1;
Error += (glm::vec4(1, 0, 1, 0) == glm::vec4::XZ) ? 0 : 1;
Error += (glm::vec4(1, 0, 0, 1) == glm::vec4::XW) ? 0 : 1;
Error += (glm::uvec4(0u, 1u, 1u, 0u) == glm::uvec4::YZ) ? 0 : 1;
Error += (glm::vec4(0, 1, 0, 1) == glm::vec4::YW) ? 0 : 1;
Error += (glm::dvec4(1, 1, 1, 0) == glm::dvec4::XYZ) ? 0 : 1;
Error += (glm::vec4(1, 1, 0, 1) == glm::vec4::XYW) ? 0 : 1;
Error += (glm::vec4(1, 0, 1, 1) == glm::vec4::XZW) ? 0 : 1;
Error += (glm::vec4(0, 1, 1, 1) == glm::vec4::YZW) ? 0 : 1;
Error += (glm::vec4(1, 1, 1, 1) == glm::vec4::XYZW) ? 0 : 1;
return Error;
}
struct AoS
{
glm::vec4 A;
@@ -518,18 +492,12 @@ int main()
glm::vec4 v;
assert(v.length() == 4);
# ifdef GLM_META_PROG_HELPERS
assert(glm::vec4::components == glm::vec4().length());
assert(glm::vec4::components == 4);
# endif
# ifdef NDEBUG
std::size_t const Size(1000000);
Error += test_vec4_perf_AoS(Size);
Error += test_vec4_perf_SoA(Size);
# endif//NDEBUG
Error += test_vec4_static_const();
Error += test_vec4_ctor();
Error += test_bvec4_ctor();
Error += test_vec4_size();

View File

@@ -210,11 +210,49 @@ namespace log2_
}
}//namespace log2_
namespace iround
{
int test()
{
int Error = 0;
for(float f = 0.0f; f < 3.1f; f += 0.05f)
{
int RoundFast = glm::iround(f);
int RoundSTD = glm::round(f);
Error += RoundFast == RoundSTD ? 0 : 1;
assert(!Error);
}
return Error;
}
}//namespace iround
namespace uround
{
int test()
{
int Error = 0;
for(float f = 0.0f; f < 3.1f; f += 0.05f)
{
int RoundFast = glm::uround(f);
int RoundSTD = glm::round(f);
Error += RoundFast == RoundSTD ? 0 : 1;
assert(!Error);
}
return Error;
}
}//namespace uround
int main()
{
int Error(0);
Error += ::log2_::test();
Error += ::iround::test();
Error += ::uround::test();
# ifdef NDEBUG
std::size_t const Samples(1000);

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_META_PROG_HELPERS
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp>
@@ -327,11 +326,6 @@ 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();

View File

@@ -354,7 +354,7 @@ namespace ceilMultiple
};
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);
@@ -364,10 +364,37 @@ namespace ceilMultiple
return Error;
}
int test_int()
{
type<int> const Data[] =
{
{3, 4, 4, 0},
{7, 4, 8, 0},
{5, 4, 8, 0},
{1, 4, 4, 0},
{1, 3, 3, 0},
{4, 3, 6, 0},
{4, 1, 4, 0},
{1, 1, 1, 0},
{7, 1, 7, 0},
};
int Error(0);
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
{
int Result = glm::ceilMultiple(Data[i].Source, Data[i].Multiple);
Error += Data[i].Return == Result ? 0 : 1;
}
return Error;
}
int test()
{
int Error(0);
Error += test_int();
Error += test_float();
return Error;

View File

@@ -45,6 +45,7 @@ glmCreateTestGTC(gtx_simd_mat4)
glmCreateTestGTC(gtx_spline)
glmCreateTestGTC(gtx_string_cast)
glmCreateTestGTC(gtx_type_aligned)
glmCreateTestGTC(gtx_type_trait)
glmCreateTestGTC(gtx_vector_angle)
glmCreateTestGTC(gtx_vector_query)
glmCreateTestGTC(gtx_wrap)

View File

@@ -209,10 +209,6 @@ int main()
{
int Error(0);
#ifdef GLM_META_PROG_HELPERS
assert(glm::dualquat::components == glm::dualquat().length());
#endif
Error += test_dual_quat_ctr();
Error += test_dquat_type();
Error += test_scalars();

View File

@@ -30,10 +30,55 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/gtx/log_base.hpp>
#include <glm/gtc/vec1.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/exponential.hpp>
namespace test_log
{
int run()
{
int Error = 0;
{
float A = glm::log(10.f, 2.0f);
float B = glm::log2(10.f);
Error += glm::epsilonEqual(A, B, 0.00001f) ? 0 : 1;
}
{
glm::vec1 A = glm::log(glm::vec1(10.f), glm::vec1(2.0f));
glm::vec1 B = glm::log2(glm::vec1(10.f));
Error += glm::all(glm::epsilonEqual(A, B, glm::vec1(0.00001f))) ? 0 : 1;
}
{
glm::vec2 A = glm::log(glm::vec2(10.f), glm::vec2(2.0f));
glm::vec2 B = glm::log2(glm::vec2(10.f));
Error += glm::all(glm::epsilonEqual(A, B, glm::vec2(0.00001f))) ? 0 : 1;
}
{
glm::vec3 A = glm::log(glm::vec3(10.f), glm::vec3(2.0f));
glm::vec3 B = glm::log2(glm::vec3(10.f));
Error += glm::all(glm::epsilonEqual(A, B, glm::vec3(0.00001f))) ? 0 : 1;
}
{
glm::vec4 A = glm::log(glm::vec4(10.f), glm::vec4(2.0f));
glm::vec4 B = glm::log2(glm::vec4(10.f));
Error += glm::all(glm::epsilonEqual(A, B, glm::vec4(0.00001f))) ? 0 : 1;
}
return Error;
}
}//namespace test_log
int main()
{
int Error(0);
Error += test_log::run();
return Error;
}

View File

@@ -29,7 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
@@ -253,28 +252,10 @@ int test_compute_gtx()
return 0;
}
int test_static_const() {
int Error(0);
Error += glm::mat4_cast(glm::simdMat4(static_cast<float>(1))) == glm::mat4_cast(glm::simdMat4::IDENTITY) ? 0 : 1;
Error += glm::mat4_cast(glm::simdMat4(static_cast<float>(0))) == glm::mat4_cast(glm::simdMat4::ZERO) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
#ifdef GLM_META_PROG_HELPERS
assert(glm::simdMat4::rows == glm::simdMat4::row_type::components);
assert(glm::simdMat4::cols == glm::simdMat4::col_type::components);
assert(glm::simdMat4::components == glm::simdMat4::pure_type::components);
assert(glm::simdMat4::rows == glm::simdMat4::pure_row_type::components);
assert(glm::simdMat4::cols == glm::simdMat4::pure_col_type::components);
#endif
std::vector<glm::mat4> Data(64 * 64 * 1);
for(std::size_t i = 0; i < Data.size(); ++i)
Data[i] = glm::mat4(
@@ -323,7 +304,6 @@ int main()
Error += test_compute_glm();
Error += test_compute_gtx();
Error += test_static_const();
float Det = glm::determinant(glm::simdMat4(1.0));
Error += Det == 1.0f ? 0 : 1;

View File

@@ -29,8 +29,6 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
#define GLM_STATIC_CONST_MEMBERS
#include <glm/glm.hpp>
#include <glm/gtx/simd_vec4.hpp>
#include <cstdio>
@@ -39,11 +37,6 @@
int main()
{
#ifdef GLM_META_PROG_HELPERS
assert(glm::simdVec4::components == glm::simdVec4::pure_type::components);
#endif
glm::simdVec4 A1(0.0f, 0.1f, 0.2f, 0.3f);
glm::simdVec4 B1(0.4f, 0.5f, 0.6f, 0.7f);
glm::simdVec4 C1 = A1 + B1;

View File

@@ -0,0 +1,79 @@
#include <glm/vec4.hpp>
#include <glm/gtx/type_trait.hpp>
template <typename genType>
struct type_gni
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
/*
template <template <class, glm::precision> class vecType, typename T, glm::precision P>
struct type_gni<vecType, T, P>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
};
*/
namespace detail
{
template <template <typename, glm::precision> class vec_type>
struct compute_vec_type
{
static bool const is_vec = false;
static GLM_RELAXED_CONSTEXPR glm::length_t components = 0;
};
template <>
struct compute_vec_type<glm::tvec1>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 1;
};
template <>
struct compute_vec_type<glm::tvec2>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 2;
};
template <>
struct compute_vec_type<glm::tvec3>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 3;
};
template <>
struct compute_vec_type<glm::tvec4>
{
static bool const is_vec = false;
//static GLM_RELAXED_CONSTEXPR glm::length_t components = 4;
};
}//namespace detail
/*
template <class gen_type>
struct vec_type
{
static bool const is_vec = detail::compute_vec_type<typename gen_type::vec_type>::is_vec;
//static GLM_RELAXED_CONSTEXPR glm::length_t const components = detail::compute_vec_type<typename gen_type::vec_type>::components;
};
*/
int main()
{
int Error = 0;
//typedef vec_type;
//bool const is_vec = detail::compute_vec_type<>::is_vec;
//Error += vec_type<glm::vec4>::is_vec ? 0 : 1;
//Error += vec_type<glm::vec4>::components == 4 ? 0 : 1;
return Error;
}