2012-09-19 13:34:23 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Created : 2012-09-19
|
|
|
|
// Updated : 2012-09-19
|
|
|
|
// Licence : This source is under MIT licence
|
|
|
|
// File : test/gtc/epsilon.cpp
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <glm/glm.hpp>
|
2012-11-05 18:39:22 +00:00
|
|
|
#include <glm/gtc/half_float.hpp>
|
2012-09-19 13:34:23 +00:00
|
|
|
#include <glm/gtc/epsilon.hpp>
|
2012-11-05 18:39:22 +00:00
|
|
|
#include <glm/gtc/constants.hpp>
|
2012-09-19 13:34:23 +00:00
|
|
|
|
2012-11-05 18:39:22 +00:00
|
|
|
template <typename T>
|
|
|
|
int test_equal()
|
2012-09-19 13:34:23 +00:00
|
|
|
{
|
|
|
|
int Error(0);
|
2012-11-05 18:39:22 +00:00
|
|
|
|
2012-11-05 23:44:48 +00:00
|
|
|
{
|
|
|
|
T A = glm::epsilon<T>();
|
|
|
|
T B = glm::epsilon<T>();
|
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
T A(0);
|
|
|
|
T B = T(0) + glm::epsilon<T>();
|
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
T A(0);
|
|
|
|
T B = T(0) - glm::epsilon<T>();
|
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
T A = T(0) + glm::epsilon<T>();
|
|
|
|
T B = T(0);
|
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
T A = T(0) - glm::epsilon<T>();
|
|
|
|
T B = T(0);
|
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
2012-11-05 18:39:22 +00:00
|
|
|
return Error;
|
|
|
|
}
|
2012-09-19 13:34:23 +00:00
|
|
|
|
2012-11-05 18:39:22 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int Error(0);
|
2012-09-19 13:34:23 +00:00
|
|
|
|
2012-11-05 23:44:48 +00:00
|
|
|
Error += test_equal<glm::half>();
|
|
|
|
Error += test_equal<float>();
|
|
|
|
Error += test_equal<double>();
|
2012-09-19 13:34:23 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|