Fixed compScale test

master
Christophe Riccio ago%!(EXTRA string=10 years)
parent 273beb8779
commit 8508e099d0
  1. 7
      glm/gtx/component_wise.inl
  2. 18
      test/gtx/gtx_component_wise.cpp

@ -77,9 +77,10 @@ namespace detail
{ {
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v) GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, 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()) + static_cast<floatType>(0.5);
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max()); vecType<floatType, P> const Scaled(v * Max);
return (vecType<floatType, P>(v) + Min) * (Max - Min) * static_cast<floatType>(2) - static_cast<floatType>(1); vecType<T, P> const Result(Scaled - static_cast<floatType>(0.5));
return Result;
} }
}; };

@ -104,6 +104,15 @@ namespace compScale
Error += A.w == 255 ? 0 : 1; Error += A.w == 255 ? 0 : 1;
} }
{
glm::i8vec4 const A = glm::compScale<glm::i8>(glm::vec4(0.0f,-1.0f, 0.5f, 1.0f));
Error += A.x == 0 ? 0 : 1;
Error += A.y == -128 ? 0 : 1;
Error += A.z == 63 ? 0 : 1;
Error += A.w == 127 ? 0 : 1;
}
{ {
glm::u16vec4 const A = glm::compScale<glm::u16>(glm::vec4(0.0f, 0.2f, 0.5f, 1.0f)); glm::u16vec4 const A = glm::compScale<glm::u16>(glm::vec4(0.0f, 0.2f, 0.5f, 1.0f));
@ -113,6 +122,15 @@ namespace compScale
Error += A.w == 65535 ? 0 : 1; Error += A.w == 65535 ? 0 : 1;
} }
{
glm::i16vec4 const A = glm::compScale<glm::i16>(glm::vec4(0.0f,-1.0f, 0.5f, 1.0f));
Error += A.x == 0 ? 0 : 1;
Error += A.y == -32768 ? 0 : 1;
Error += A.z == 16383 ? 0 : 1;
Error += A.w == 32767 ? 0 : 1;
}
return Error; return Error;
} }
}// compScale }// compScale

Loading…
Cancel
Save