From 6a4677c30e07e3df49f9ccf81a05f242853c9cbc Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 7 Apr 2012 02:30:26 +0100 Subject: [PATCH] Promoted GTX_epsilon, GTX_ulp, fixed build, removed deprecation warning at build time --- glm/ext.hpp | 11 +- glm/gtc/epsilon.hpp | 78 ++++++++++++ glm/{gtx => gtc}/epsilon.inl | 35 ++++-- glm/gtc/noise.inl | 40 ++++-- glm/gtc/random.inl | 35 ++++-- glm/gtc/reciprocal.inl | 35 ++++-- glm/gtc/ulp.inl | 53 +++++--- glm/gtx/constants.hpp | 2 +- glm/gtx/epsilon.hpp | 57 +-------- glm/gtx/vector_angle.hpp | 2 +- test/core/core_func_common.cpp | 3 +- test/core/core_func_geometric.cpp | 4 +- test/core/core_func_noise.cpp | 2 +- test/core/core_func_packing.cpp | 2 +- test/gtc/gtc_noise.cpp | 4 +- test/gtc/gtc_quaternion.cpp | 98 ++++++++++++++- test/gtc/gtc_random.cpp | 2 +- test/gtc/gtc_ulp.cpp | 4 +- test/gtx/CMakeLists.txt | 1 - test/gtx/gtx_bit.cpp | 2 +- test/gtx/gtx_integer.cpp | 2 +- test/gtx/gtx_noise.cpp | 199 ------------------------------ test/gtx/gtx_quaternion.cpp | 101 +-------------- 23 files changed, 344 insertions(+), 428 deletions(-) create mode 100644 glm/gtc/epsilon.hpp rename glm/{gtx => gtc}/epsilon.inl (79%) delete mode 100644 test/gtx/gtx_noise.cpp diff --git a/glm/ext.hpp b/glm/ext.hpp index be7b2176..b0c4f72d 100644 --- a/glm/ext.hpp +++ b/glm/ext.hpp @@ -63,15 +63,21 @@ # pragma message("GLM: All extensions included (not recommanded)") #endif//GLM_MESSAGES +#include "./gtc/constants.hpp" +#include "./gtc/epsilon.hpp" #include "./gtc/half_float.hpp" #include "./gtc/matrix_access.hpp" #include "./gtc/matrix_integer.hpp" #include "./gtc/matrix_inverse.hpp" #include "./gtc/matrix_transform.hpp" +#include "./gtc/noise.hpp" #include "./gtc/quaternion.hpp" +#include "./gtc/random.hpp" +#include "./gtc/reciprocal.hpp" #include "./gtc/swizzle.hpp" #include "./gtc/type_precision.hpp" #include "./gtc/type_ptr.hpp" +#include "./gtc/ulp.hpp" #include "./gtx/associated_min_max.hpp" #include "./gtx/bit.hpp" @@ -81,7 +87,6 @@ #include "./gtx/color_space_YCoCg.hpp" #include "./gtx/compatibility.hpp" #include "./gtx/component_wise.hpp" -#include "./gtx/epsilon.hpp" #include "./gtx/euler_angles.hpp" #include "./gtx/extend.hpp" #include "./gtx/extented_min_max.hpp" @@ -102,7 +107,6 @@ #include "./gtx/matrix_query.hpp" #include "./gtx/mixed_product.hpp" #include "./gtx/multiple.hpp" -#include "./gtx/noise.hpp" #include "./gtx/norm.hpp" #include "./gtx/normal.hpp" #include "./gtx/normalize_dot.hpp" @@ -114,16 +118,13 @@ #include "./gtx/polar_coordinates.hpp" #include "./gtx/projection.hpp" #include "./gtx/quaternion.hpp" -#include "./gtx/random.hpp" #include "./gtx/raw_data.hpp" -#include "./gtx/reciprocal.hpp" #include "./gtx/rotate_vector.hpp" #include "./gtx/spline.hpp" #include "./gtx/std_based_type.hpp" #include "./gtx/string_cast.hpp" #include "./gtx/transform.hpp" #include "./gtx/transform2.hpp" -#include "./gtx/ulp.hpp" #include "./gtx/vec1.hpp" #include "./gtx/vector_access.hpp" #include "./gtx/vector_angle.hpp" diff --git a/glm/gtc/epsilon.hpp b/glm/gtc/epsilon.hpp new file mode 100644 index 00000000..b113848c --- /dev/null +++ b/glm/gtc/epsilon.hpp @@ -0,0 +1,78 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 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. +/// +/// @ref gtc_epsilon +/// @file glm/gtc/epsilon.hpp +/// @date 2012-04-07 / 2012-04-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtc_quaternion (dependence) +/// +/// @defgroup gtc_epsilon GLM_GTC_epsilon: Epsilon comparison +/// @ingroup gtc +/// +/// @brief Comparison functions for a user defined epsilon values. +/// +/// need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTC_epsilon +#define GLM_GTC_epsilon GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtc/quaternion.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTC_epsilon extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_epsilon + /// @{ + + /// Returns the component-wise compare of |x - y| < epsilon. + /// @see gtc_epsilon + template + bool equalEpsilon( + genTypeT const & x, + genTypeT const & y, + genTypeU const & epsilon); + + /// Returns the component-wise compare of |x - y| >= epsilon. + /// @see gtc_epsilon + template + bool notEqualEpsilon( + genTypeT const & x, + genTypeT const & y, + genTypeU const & epsilon); + + /// @} +}//namespace glm + +#include "epsilon.inl" + +#endif//GLM_GTC_epsilon diff --git a/glm/gtx/epsilon.inl b/glm/gtc/epsilon.inl similarity index 79% rename from glm/gtx/epsilon.inl rename to glm/gtc/epsilon.inl index 7a82f7cd..175eef1a 100644 --- a/glm/gtx/epsilon.inl +++ b/glm/gtc/epsilon.inl @@ -1,11 +1,30 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2005-12-21 -// Updated : 2011-06-07 -// Licence : This source is under MIT License -// File : glm/gtx/epsilon.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 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. +/// +/// @ref gtc_epsilon +/// @file glm/gtc/epsilon.inl +/// @date 2012-04-07 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// namespace glm { diff --git a/glm/gtc/noise.inl b/glm/gtc/noise.inl index 25b96b53..740b1599 100644 --- a/glm/gtc/noise.inl +++ b/glm/gtc/noise.inl @@ -1,19 +1,35 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 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. +/// +/// @ref gtc_noise +/// @file glm/gtc/noise.inl +/// @date 2011-04-21 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// // Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise": // https://github.com/ashima/webgl-noise // Following Stefan Gustavson's paper "Simplex noise demystified": // http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2011-04-21 -// Updated : 2011-09-27 -// Licence : This source is under MIT License -// File : glm/gtc/noise.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Dependency: -// - GLM core -/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// namespace glm { diff --git a/glm/gtc/random.inl b/glm/gtc/random.inl index 9f9bb25f..bce64f6e 100644 --- a/glm/gtc/random.inl +++ b/glm/gtc/random.inl @@ -1,11 +1,30 @@ -////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) -////////////////////////////////////////////////////////////////////////////////// -// Created : 2011-09-19 -// Updated : 2011-09-19 -// Licence : This source is under MIT License -// File : glm/gtc/random.inl -////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 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. +/// +/// @ref gtc_random +/// @file glm/gtc/random.inl +/// @date 2011-09-19 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// #include #include diff --git a/glm/gtc/reciprocal.inl b/glm/gtc/reciprocal.inl index 1a23a56a..fba5cf02 100644 --- a/glm/gtc/reciprocal.inl +++ b/glm/gtc/reciprocal.inl @@ -1,11 +1,30 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-10-09 -// Updated : 2012-01-25 -// Licence : This source is under MIT License -// File : glm/gtc/reciprocal.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 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. +/// +/// @ref gtc_reciprocal +/// @file glm/gtc/reciprocal.inl +/// @date 2008-10-09 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// #include "../core/_vectorize.hpp" diff --git a/glm/gtc/ulp.inl b/glm/gtc/ulp.inl index 252978dc..c1527840 100644 --- a/glm/gtc/ulp.inl +++ b/glm/gtc/ulp.inl @@ -1,26 +1,41 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2011-03-07 -// Updated : 2011-12-12 -// Licence : This source is under MIT License -// File : glm/gtc/ulp.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2012 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. +/// +/// @ref gtc_ulp +/// @file glm/gtc/ulp.inl +/// @date 2011-03-07 / 2012-04-07 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// +/// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/// +/// Developed at SunPro, a Sun Microsystems, Inc. business. +/// Permission to use, copy, modify, and distribute this +/// software is freely granted, provided that this notice +/// is preserved. +/////////////////////////////////////////////////////////////////////////////////// #include #include -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - #pragma warning(push) #pragma warning(disable : 4127) diff --git a/glm/gtx/constants.hpp b/glm/gtx/constants.hpp index 8526249c..f302d1bd 100644 --- a/glm/gtx/constants.hpp +++ b/glm/gtx/constants.hpp @@ -27,7 +27,7 @@ #include "../gtc/constants.hpp" #if(defined(GLM_MESSAGES)) -# pragma message("GLM: GLM_GTX_constants extension is deprecated, include GLM_GTX_constants instead") +# pragma message("GLM: GLM_GTX_constants extension is deprecated, include GLM_GTC_constants (glm/gtc/constants.hpp) instead") #endif #endif//GLM_GTX_constants diff --git a/glm/gtx/epsilon.hpp b/glm/gtx/epsilon.hpp index 6537db64..73adc1aa 100644 --- a/glm/gtx/epsilon.hpp +++ b/glm/gtx/epsilon.hpp @@ -19,60 +19,11 @@ /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. -/// -/// @ref gtx_epsilon -/// @file glm/gtx/epsilon.hpp -/// @date 2007-05-21 / 2011-06-07 -/// @author Christophe Riccio -/// -/// @see core (dependence) -/// @see gtc_half_float (dependence) -/// @see gtc_quaternion (dependence) -/// -/// @defgroup gtx_epsilon GLM_GTX_epsilon: Epsilon comparison -/// @ingroup gtx -/// -/// @brief Comparison functions for a user defined epsilon values. -/// -/// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// -#ifndef GLM_GTX_epsilon -#define GLM_GTX_epsilon GLM_VERSION - -// Dependency: -#include "../glm.hpp" -#include "../gtc/half_float.hpp" -#include "../gtc/quaternion.hpp" - -#if(defined(GLM_MESSAGES) && !defined(glm_ext)) -# pragma message("GLM: GLM_GTX_epsilon extension included") +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_epsilon extension is deprecated, include GLM_GTC_epsilon (glm/gtc/epsilon) instead") #endif -namespace glm -{ - /// @addtogroup gtx_epsilon - /// @{ - - /// Returns the component-wise compare of |x - y| < epsilon. - /// @see gtx_epsilon - template - bool equalEpsilon( - genTypeT const & x, - genTypeT const & y, - genTypeU const & epsilon); - - /// Returns the component-wise compare of |x - y| >= epsilon. - /// @see gtx_epsilon - template - bool notEqualEpsilon( - genTypeT const & x, - genTypeT const & y, - genTypeU const & epsilon); - - /// @} -}//namespace glm - -#include "epsilon.inl" - -#endif//GLM_GTX_epsilon +// Promoted: +#include "../gtc/epsilon.hpp" diff --git a/glm/gtx/vector_angle.hpp b/glm/gtx/vector_angle.hpp index 1906fa57..d0962747 100644 --- a/glm/gtx/vector_angle.hpp +++ b/glm/gtx/vector_angle.hpp @@ -42,7 +42,7 @@ // Dependency: #include "../glm.hpp" -#include "../gtx/epsilon.hpp" +#include "../gtc/epsilon.hpp" #include "../gtx/quaternion.hpp" #include "../gtx/rotate_vector.hpp" diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index fd22dc7f..d3edba4c 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -11,8 +11,7 @@ //#include //#include #include -#include -#include +#include #include int test_modf() diff --git a/test/core/core_func_geometric.cpp b/test/core/core_func_geometric.cpp index d6b32761..250cf8c4 100644 --- a/test/core/core_func_geometric.cpp +++ b/test/core/core_func_geometric.cpp @@ -4,11 +4,11 @@ // Created : 2011-01-15 // Updated : 2011-11-14 // Licence : This source is under MIT licence -// File : test/gtx/func_geometric.cpp +// File : test/core/func_geometric.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include +#include int test_reflect() { diff --git a/test/core/core_func_noise.cpp b/test/core/core_func_noise.cpp index 26f095f1..8848ac9d 100644 --- a/test/core/core_func_noise.cpp +++ b/test/core/core_func_noise.cpp @@ -4,7 +4,7 @@ // Created : 2011-01-15 // Updated : 2011-09-13 // Licence : This source is under MIT licence -// File : test/gtx/func_noise.cpp +// File : test/core/func_noise.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include diff --git a/test/core/core_func_packing.cpp b/test/core/core_func_packing.cpp index fa70e4f8..831cc6c5 100644 --- a/test/core/core_func_packing.cpp +++ b/test/core/core_func_packing.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include int test_packUnorm2x16() diff --git a/test/gtc/gtc_noise.cpp b/test/gtc/gtc_noise.cpp index 8f5346d4..50a65626 100644 --- a/test/gtc/gtc_noise.cpp +++ b/test/gtc/gtc_noise.cpp @@ -4,11 +4,11 @@ // Created : 2011-04-21 // Updated : 2011-04-26 // Licence : This source is under MIT licence -// File : test/gtx/noise.cpp +// File : test/gtc/noise.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include #include diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 4fdc3968..596fbb18 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -9,7 +9,73 @@ #include #include -#include +#include + +int test_quat_angle() +{ + int Error = 0; + + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; + float A = glm::angle(N); + Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; + } + { + glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(0, 1, 1))); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; + float A = glm::angle(N); + Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; + } + { + glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(1, 2, 3))); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; + float A = glm::angle(N); + Error += glm::equalEpsilon(A, 45.0f, 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(90.0f, glm::vec3(0, 0, 1)); + glm::quat C = glm::mix(A, B, 0.5f); + glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + + Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(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(90.0f, glm::vec3(0, 0, 1)); + glm::quat C = glm::mix(A, B, 0.5f); + glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + + Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1; + Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1; + + return Error; +} int test_quat_precision() { @@ -21,6 +87,32 @@ int test_quat_precision() return Error; } +int test_quat_normalize() +{ + int Error = 0; + + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; + } + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 2)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; + } + { + glm::quat Q = glm::angleAxis(45.0f, glm::vec3(1, 2, 3)); + glm::quat N = glm::normalize(Q); + float L = glm::length(N); + Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; + } + + return Error; +} + int test_quat_type() { glm::quat A; @@ -35,6 +127,10 @@ int main() Error += test_quat_precision(); Error += test_quat_type(); + Error += test_quat_angle(); + Error += test_quat_angleAxis(); + Error += test_quat_mix(); + Error += test_quat_normalize(); return Error; } diff --git a/test/gtc/gtc_random.cpp b/test/gtc/gtc_random.cpp index a9a9afed..22fc9433 100644 --- a/test/gtc/gtc_random.cpp +++ b/test/gtc/gtc_random.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include int test_linearRand() diff --git a/test/gtc/gtc_ulp.cpp b/test/gtc/gtc_ulp.cpp index 5c32a0a1..88b40440 100644 --- a/test/gtc/gtc_ulp.cpp +++ b/test/gtc/gtc_ulp.cpp @@ -4,11 +4,11 @@ // Created : 2011-04-26 // Updated : 2011-04-26 // Licence : This source is under MIT licence -// File : test/gtx/ulp.cpp +// File : test/gtc/ulp.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index 63777e7b..0d2159a7 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -2,7 +2,6 @@ glmCreateTestGTC(gtx_bit) glmCreateTestGTC(gtx_gradient_paint) glmCreateTestGTC(gtx_integer) glmCreateTestGTC(gtx_matrix_query) -glmCreateTestGTC(gtx_noise) glmCreateTestGTC(gtx_quaternion) glmCreateTestGTC(gtx_rotate_vector) glmCreateTestGTC(gtx_simd_vec4) diff --git a/test/gtx/gtx_bit.cpp b/test/gtx/gtx_bit.cpp index 487b217f..ad1c386a 100644 --- a/test/gtx/gtx_bit.cpp +++ b/test/gtx/gtx_bit.cpp @@ -8,7 +8,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/test/gtx/gtx_integer.cpp b/test/gtx/gtx_integer.cpp index b6bc3b42..d351fcac 100644 --- a/test/gtx/gtx_integer.cpp +++ b/test/gtx/gtx_integer.cpp @@ -8,8 +8,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include +#include #include -#include #include int test_floor_log2() diff --git a/test/gtx/gtx_noise.cpp b/test/gtx/gtx_noise.cpp deleted file mode 100644 index 8f5346d4..00000000 --- a/test/gtx/gtx_noise.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2011-04-21 -// Updated : 2011-04-26 -// Licence : This source is under MIT licence -// File : test/gtx/noise.cpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include - -int test_simplex() -{ - std::size_t const Size = 256; - - { - std::vector 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 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 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 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 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 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 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 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 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; -} diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp index 2cc27571..6a2b3619 100644 --- a/test/gtx/gtx_quaternion.cpp +++ b/test/gtx/gtx_quaternion.cpp @@ -8,26 +8,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include -#include - -int test_quat_mix() -{ - int Error = 0; - - glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); - glm::quat B = glm::angleAxis(90.0f, glm::vec3(0, 0, 1)); - glm::quat C = glm::mix(A, B, 0.5f); - glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); - - Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1; - Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1; - Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1; - Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1; - - return Error; -} int test_quat_fastMix() { @@ -63,91 +45,12 @@ int test_quat_shortMix() 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(90.0f, glm::vec3(0, 0, 1)); - glm::quat C = glm::mix(A, B, 0.5f); - glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); - - Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1; - Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1; - Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1; - Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1; - - return Error; -} - -int test_quat_angle() -{ - int Error = 0; - - { - glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; - float A = glm::angle(N); - Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; - } - { - glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(0, 1, 1))); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; - float A = glm::angle(N); - Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; - } - { - glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(1, 2, 3))); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1; - float A = glm::angle(N); - Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1; - } - - return Error; -} - -int test_quat_normalize() -{ - int Error = 0; - - { - glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; - } - { - glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 2)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; - } - { - glm::quat Q = glm::angleAxis(45.0f, glm::vec3(1, 2, 3)); - glm::quat N = glm::normalize(Q); - float L = glm::length(N); - Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1; - } - - return Error; -} - int main() { int Error = 0; - Error += test_quat_angle(); - Error += test_quat_angleAxis(); - Error += test_quat_mix(); - Error += test_quat_fastMix(); + Error += test_quat_fastMix(); Error += test_quat_shortMix(); - Error += test_quat_normalize(); return Error; }