Fixed compScale test

This commit is contained in:
Christophe Riccio 2015-10-08 23:49:43 +02:00
parent 273beb8779
commit 8508e099d0
2 changed files with 22 additions and 3 deletions

View File

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

View File

@ -104,6 +104,15 @@ namespace compScale
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));
@ -113,6 +122,15 @@ namespace compScale
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;
}
}// compScale