mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Added compNormalize function to GTX_component_wise
This commit is contained in:
parent
998feff87e
commit
a9ab80d5fd
@ -86,7 +86,7 @@ namespace detail
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType length(genType x)
|
GLM_FUNC_QUALIFIER genType length(genType x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'length' accepts only floating-point inputs");
|
||||||
|
|
||||||
return abs(x);
|
return abs(x);
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER T length(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER T length(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'length' accepts only floating-point inputs");
|
||||||
|
|
||||||
return sqrt(dot(v, v));
|
return sqrt(dot(v, v));
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ namespace detail
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType distance(genType const & p0, genType const & p1)
|
GLM_FUNC_QUALIFIER genType distance(genType const & p0, genType const & p1)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'distance' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'distance' accepts only floating-point inputs");
|
||||||
|
|
||||||
return length(p1 - p0);
|
return length(p1 - p0);
|
||||||
}
|
}
|
||||||
@ -118,14 +118,14 @@ namespace detail
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T dot(T x, T y)
|
GLM_FUNC_QUALIFIER T dot(T x, T y)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
|
||||||
return x * y;
|
return x * y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER T dot(vecType<T, P> const & x, vecType<T, P> const & y)
|
GLM_FUNC_QUALIFIER T dot(vecType<T, P> const & x, vecType<T, P> const & y)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' accepts only floating-point inputs");
|
||||||
return detail::compute_dot<vecType, T, P>::call(x, y);
|
return detail::compute_dot<vecType, T, P>::call(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ namespace detail
|
|||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tvec3<T, P> cross(tvec3<T, P> const & x, tvec3<T, P> const & y)
|
GLM_FUNC_QUALIFIER tvec3<T, P> cross(tvec3<T, P> const & x, tvec3<T, P> const & y)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cross' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'cross' accepts only floating-point inputs");
|
||||||
|
|
||||||
return tvec3<T, P>(
|
return tvec3<T, P>(
|
||||||
x.y * y.z - y.y * x.z,
|
x.y * y.z - y.y * x.z,
|
||||||
@ -145,7 +145,7 @@ namespace detail
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType normalize(genType const & x)
|
GLM_FUNC_QUALIFIER genType normalize(genType const & x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'normalize' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'normalize' accepts only floating-point inputs");
|
||||||
|
|
||||||
return x < genType(0) ? genType(-1) : genType(1);
|
return x < genType(0) ? genType(-1) : genType(1);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> normalize(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> normalize(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
|
||||||
|
|
||||||
return x * inversesqrt(dot(x, x));
|
return x * inversesqrt(dot(x, x));
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ namespace detail
|
|||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER genType refract(genType const & I, genType const & N, genType const & eta)
|
GLM_FUNC_QUALIFIER genType refract(genType const & I, genType const & N, genType const & eta)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'refract' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'refract' accepts only floating-point inputs");
|
||||||
|
|
||||||
genType const dotValue(dot(N, I));
|
genType const dotValue(dot(N, I));
|
||||||
genType const k(static_cast<genType>(1) - eta * eta * (static_cast<genType>(1) - dotValue * dotValue));
|
genType const k(static_cast<genType>(1) - eta * eta * (static_cast<genType>(1) - dotValue * dotValue));
|
||||||
@ -192,7 +192,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> refract(vecType<T, P> const & I, vecType<T, P> const & N, T eta)
|
GLM_FUNC_QUALIFIER vecType<T, P> refract(vecType<T, P> const & I, vecType<T, P> const & N, T eta)
|
||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'refract' only accept floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'refract' accepts only floating-point inputs");
|
||||||
|
|
||||||
T const dotValue(dot(N, I));
|
T const dotValue(dot(N, I));
|
||||||
T const k(static_cast<T>(1) - eta * eta * (static_cast<T>(1) - dotValue * dotValue));
|
T const k(static_cast<T>(1) - eta * eta * (static_cast<T>(1) - dotValue * dotValue));
|
||||||
|
@ -94,7 +94,6 @@
|
|||||||
#include "./gtx/fast_exponential.hpp"
|
#include "./gtx/fast_exponential.hpp"
|
||||||
#include "./gtx/fast_square_root.hpp"
|
#include "./gtx/fast_square_root.hpp"
|
||||||
#include "./gtx/fast_trigonometry.hpp"
|
#include "./gtx/fast_trigonometry.hpp"
|
||||||
#include "./gtx/float_normalize.hpp"
|
|
||||||
#include "./gtx/gradient_paint.hpp"
|
#include "./gtx/gradient_paint.hpp"
|
||||||
#include "./gtx/handed_coordinate_space.hpp"
|
#include "./gtx/handed_coordinate_space.hpp"
|
||||||
#include "./gtx/integer.hpp"
|
#include "./gtx/integer.hpp"
|
||||||
|
@ -54,29 +54,31 @@ namespace glm
|
|||||||
/// @addtogroup gtx_component_wise
|
/// @addtogroup gtx_component_wise
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
/// Convert an integer vector to a normalized float vector.
|
||||||
|
/// If the parameter value type is already a floating precision type, the value is passed through.
|
||||||
|
/// @see gtx_component_wise
|
||||||
|
template <typename floatType, typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_DECL vecType<floatType, P> compNormalize(vecType<T, P> const & v);
|
||||||
|
|
||||||
/// Add all vector components together.
|
/// Add all vector components together.
|
||||||
/// @see gtx_component_wise
|
/// @see gtx_component_wise
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL typename genType::value_type compAdd(
|
GLM_FUNC_DECL typename genType::value_type compAdd(genType const & v);
|
||||||
genType const & v);
|
|
||||||
|
|
||||||
/// Multiply all vector components together.
|
/// Multiply all vector components together.
|
||||||
/// @see gtx_component_wise
|
/// @see gtx_component_wise
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL typename genType::value_type compMul(
|
GLM_FUNC_DECL typename genType::value_type compMul(genType const & v);
|
||||||
genType const & v);
|
|
||||||
|
|
||||||
/// Find the minimum value between single vector components.
|
/// Find the minimum value between single vector components.
|
||||||
/// @see gtx_component_wise
|
/// @see gtx_component_wise
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL typename genType::value_type compMin(
|
GLM_FUNC_DECL typename genType::value_type compMin(genType const & v);
|
||||||
genType const & v);
|
|
||||||
|
|
||||||
/// Find the maximum value between single vector components.
|
/// Find the maximum value between single vector components.
|
||||||
/// @see gtx_component_wise
|
/// @see gtx_component_wise
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_DECL typename genType::value_type compMax(
|
GLM_FUNC_DECL typename genType::value_type compMax(genType const & v);
|
||||||
genType const & v);
|
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -30,8 +30,51 @@
|
|||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm
|
namespace glm{
|
||||||
|
namespace detail
|
||||||
{
|
{
|
||||||
|
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
|
||||||
|
struct compute_compNormalize
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||||
|
struct compute_compNormalize<T, floatType, P, vecType, true, true>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
|
||||||
|
{
|
||||||
|
floatType const Min = static_cast<floatType>(std::numeric_limits<T>::min());
|
||||||
|
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max());
|
||||||
|
return (vecType<floatType, P>(v) - Min) / (Max - Min) * static_cast<floatType>(2) - static_cast<floatType>(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||||
|
struct compute_compNormalize<T, floatType, P, vecType, true, false>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
|
||||||
|
{
|
||||||
|
return vecType<floatType, P>(v) / static_cast<floatType>(std::numeric_limits<T>::max());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
||||||
|
struct compute_compNormalize<T, floatType, P, vecType, false, true>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
|
||||||
|
{
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}//namespace detail
|
||||||
|
|
||||||
|
template <typename floatType, typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
GLM_FUNC_QUALIFIER vecType<floatType, P> compNormalize(vecType<T, P> const & v)
|
||||||
|
{
|
||||||
|
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "'compNormalize' accepts only floating-point types for 'floatType' template parameter");
|
||||||
|
|
||||||
|
return detail::compute_compNormalize<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER T compAdd(vecType<T, P> const & v)
|
GLM_FUNC_QUALIFIER T compAdd(vecType<T, P> const & v)
|
||||||
{
|
{
|
||||||
|
@ -1,64 +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.
|
|
||||||
///
|
|
||||||
/// @ref gtx_float_normalize
|
|
||||||
/// @file glm/gtx/float_normalize.hpp
|
|
||||||
/// @date 2015-09-25 / 2015-09-25
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///
|
|
||||||
/// @see core (dependence)
|
|
||||||
///
|
|
||||||
/// @defgroup gtx_float_normalize GLM_GTX_float_normalize
|
|
||||||
/// @ingroup gtx
|
|
||||||
///
|
|
||||||
/// @brief Convert integer vectors into normalized float vectors.
|
|
||||||
///
|
|
||||||
/// <glm/gtx/color_space.hpp> need to be included to use these functionalities.
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// Dependency:
|
|
||||||
#include "../glm.hpp"
|
|
||||||
|
|
||||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
|
||||||
# pragma message("GLM: GLM_GTX_float_normalize extension included")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace glm
|
|
||||||
{
|
|
||||||
/// @addtogroup gtx_float_normalize
|
|
||||||
/// @{
|
|
||||||
|
|
||||||
/// Converts a color from HSV color space to its color in RGB color space.
|
|
||||||
/// @see gtx_float_normalize
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
|
||||||
GLM_FUNC_DECL vecType<float, P> floatNormalize(vecType<T, P> const & v);
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
}//namespace glm
|
|
||||||
|
|
||||||
#include "float_normalize.inl"
|
|
@ -1,77 +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.
|
|
||||||
///
|
|
||||||
/// @ref gtx_float_normalize
|
|
||||||
/// @file glm/gtx/float_normalize.inl
|
|
||||||
/// @date 2015-09-25 / 2015-09-25
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace glm{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
|
|
||||||
struct compute_floatNormalize
|
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
|
||||||
struct compute_floatNormalize<T, floatType, P, vecType, true, true>
|
|
||||||
{
|
|
||||||
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
|
|
||||||
{
|
|
||||||
floatType const Min = static_cast<floatType>(std::numeric_limits<T>::min());
|
|
||||||
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max());
|
|
||||||
return (vecType<floatType, P>(v) - Min) / (Max - Min) * static_cast<floatType>(2) - static_cast<floatType>(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
|
||||||
struct compute_floatNormalize<T, floatType, P, vecType, true, false>
|
|
||||||
{
|
|
||||||
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
|
|
||||||
{
|
|
||||||
return vecType<floatType, P>(v) / static_cast<floatType>(std::numeric_limits<T>::max());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
|
|
||||||
struct compute_floatNormalize<T, floatType, P, vecType, false, true>
|
|
||||||
{
|
|
||||||
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
|
|
||||||
{
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}//namespace detail
|
|
||||||
|
|
||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
|
||||||
GLM_FUNC_QUALIFIER vecType<float, P> floatNormalize(vecType<T, P> const & v)
|
|
||||||
{
|
|
||||||
return detail::compute_floatNormalize<T, float, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
|
|
||||||
}
|
|
||||||
}//namespace glm
|
|
@ -11,7 +11,6 @@ glmCreateTestGTC(gtx_extented_min_max)
|
|||||||
glmCreateTestGTC(gtx_fast_exponential)
|
glmCreateTestGTC(gtx_fast_exponential)
|
||||||
glmCreateTestGTC(gtx_fast_square_root)
|
glmCreateTestGTC(gtx_fast_square_root)
|
||||||
glmCreateTestGTC(gtx_fast_trigonometry)
|
glmCreateTestGTC(gtx_fast_trigonometry)
|
||||||
glmCreateTestGTC(gtx_float_normalize)
|
|
||||||
glmCreateTestGTC(gtx_gradient_paint)
|
glmCreateTestGTC(gtx_gradient_paint)
|
||||||
glmCreateTestGTC(gtx_handed_coordinate_space)
|
glmCreateTestGTC(gtx_handed_coordinate_space)
|
||||||
glmCreateTestGTC(gtx_integer)
|
glmCreateTestGTC(gtx_integer)
|
||||||
|
@ -25,15 +25,86 @@
|
|||||||
/// THE SOFTWARE.
|
/// THE SOFTWARE.
|
||||||
///
|
///
|
||||||
/// @file test/gtx/gtx_component_wise.cpp
|
/// @file test/gtx/gtx_component_wise.cpp
|
||||||
/// @date 2013-10-25 / 2014-11-25
|
/// @date 2013-10-25 / 2015-09-25
|
||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <glm/gtx/component_wise.hpp>
|
#include <glm/gtx/component_wise.hpp>
|
||||||
|
#include <glm/gtc/type_precision.hpp>
|
||||||
|
#include <glm/gtc/epsilon.hpp>
|
||||||
|
#include <glm/gtc/constants.hpp>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
namespace integer_8bit_test
|
||||||
|
{
|
||||||
|
int run()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec4 const A = glm::compNormalize<float>(glm::u8vec4(0, 127, 128, 255));
|
||||||
|
|
||||||
|
Error += glm::epsilonEqual(A.x, 0.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
Error += A.y < 0.5f ? 0 : 1;
|
||||||
|
Error += A.z > 0.5f ? 0 : 1;
|
||||||
|
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec4 const A = glm::compNormalize<float>(glm::i8vec4(-128, -1, 0, 127));
|
||||||
|
|
||||||
|
Error += glm::epsilonEqual(A.x,-1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
Error += A.y < 0.0f ? 0 : 1;
|
||||||
|
Error += A.z > 0.0f ? 0 : 1;
|
||||||
|
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace integer_8bit_test
|
||||||
|
|
||||||
|
namespace integer_16bit_test
|
||||||
|
{
|
||||||
|
int run()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec4 const A = glm::compNormalize<float>(glm::u16vec4(
|
||||||
|
std::numeric_limits<glm::u16>::min(),
|
||||||
|
(std::numeric_limits<glm::u16>::max() >> 1) + 0,
|
||||||
|
(std::numeric_limits<glm::u16>::max() >> 1) + 1,
|
||||||
|
std::numeric_limits<glm::u16>::max()));
|
||||||
|
|
||||||
|
Error += glm::epsilonEqual(A.x, 0.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
Error += A.y < 0.5f ? 0 : 1;
|
||||||
|
Error += A.z > 0.5f ? 0 : 1;
|
||||||
|
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
glm::vec4 const A = glm::compNormalize<float>(glm::i16vec4(
|
||||||
|
std::numeric_limits<glm::i16>::min(),
|
||||||
|
static_cast<glm::i16>(-1),
|
||||||
|
static_cast<glm::i16>(0),
|
||||||
|
std::numeric_limits<glm::i16>::max()));
|
||||||
|
|
||||||
|
Error += glm::epsilonEqual(A.x,-1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
Error += A.y < 0.0f ? 0 : 1;
|
||||||
|
Error += A.z > 0.0f ? 0 : 1;
|
||||||
|
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
}//namespace integer_16bit_test
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
|
Error += integer_8bit_test::run();
|
||||||
|
Error += integer_16bit_test::run();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
@ -1,110 +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/gtx/gtx_float_normalize.cpp
|
|
||||||
/// @date 2015-09-25 / 2015-09-25
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <glm/gtx/float_normalize.hpp>
|
|
||||||
#include <glm/gtc/type_precision.hpp>
|
|
||||||
#include <glm/gtc/epsilon.hpp>
|
|
||||||
#include <glm/gtc/constants.hpp>
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
namespace integer_8bit_test
|
|
||||||
{
|
|
||||||
int run()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 const A = glm::floatNormalize(glm::u8vec4(0, 127, 128, 255));
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(A.x, 0.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += A.y < 0.5f ? 0 : 1;
|
|
||||||
Error += A.z > 0.5f ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 const A = glm::floatNormalize(glm::i8vec4(-128, -1, 0, 127));
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(A.x,-1.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += A.y < 0.0f ? 0 : 1;
|
|
||||||
Error += A.z > 0.0f ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//namespace integer_8bit_test
|
|
||||||
|
|
||||||
namespace integer_16bit_test
|
|
||||||
{
|
|
||||||
int run()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 const A = glm::floatNormalize(glm::u16vec4(
|
|
||||||
std::numeric_limits<glm::u16>::min(),
|
|
||||||
(std::numeric_limits<glm::u16>::max() >> 1) + 0,
|
|
||||||
(std::numeric_limits<glm::u16>::max() >> 1) + 1,
|
|
||||||
std::numeric_limits<glm::u16>::max()));
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(A.x, 0.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += A.y < 0.5f ? 0 : 1;
|
|
||||||
Error += A.z > 0.5f ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
glm::vec4 const A = glm::floatNormalize(glm::i16vec4(
|
|
||||||
std::numeric_limits<glm::i16>::min(),
|
|
||||||
static_cast<glm::i16>(-1),
|
|
||||||
static_cast<glm::i16>(0),
|
|
||||||
std::numeric_limits<glm::i16>::max()));
|
|
||||||
|
|
||||||
Error += glm::epsilonEqual(A.x,-1.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
Error += A.y < 0.0f ? 0 : 1;
|
|
||||||
Error += A.z > 0.0f ? 0 : 1;
|
|
||||||
Error += glm::epsilonEqual(A.w, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
||||||
}//namespace integer_16bit_test
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int Error(0);
|
|
||||||
|
|
||||||
Error += integer_8bit_test::run();
|
|
||||||
Error += integer_16bit_test::run();
|
|
||||||
|
|
||||||
return Error;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user