Rely on STL functions for GLM functions using the same prototype #233

This commit is contained in:
Christophe Riccio
2014-09-06 01:45:13 +02:00
parent 4a701c6760
commit ac3c2e37f1
8 changed files with 288 additions and 151 deletions

View File

@@ -10,34 +10,116 @@
#include <glm/common.hpp>
#include <glm/exponential.hpp>
#include <glm/gtc/ulp.hpp>
#include <glm/gtx/vec1.hpp>
namespace inversesqrt
int test_pow()
{
int test()
int Error(0);
float A = glm::pow(10.f, 10.f);
glm::vec1 B = glm::pow(glm::vec1(10.f), glm::vec1(10.f));
glm::vec2 C = glm::pow(glm::vec2(10.f), glm::vec2(10.f));
glm::vec3 D = glm::pow(glm::vec3(10.f), glm::vec3(10.f));
glm::vec4 E = glm::pow(glm::vec4(10.f), glm::vec4(10.f));
return Error;
}
int test_exp()
{
int Error(0);
float A = glm::exp(10.f);
glm::vec1 B = glm::exp(glm::vec1(10.f));
glm::vec2 C = glm::exp(glm::vec2(10.f));
glm::vec3 D = glm::exp(glm::vec3(10.f));
glm::vec4 E = glm::exp(glm::vec4(10.f));
return Error;
}
int test_log()
{
int Error(0);
float A = glm::log(10.f);
glm::vec1 B = glm::log(glm::vec1(10.f));
glm::vec2 C = glm::log(glm::vec2(10.f));
glm::vec3 D = glm::log(glm::vec3(10.f));
glm::vec4 E = glm::log(glm::vec4(10.f));
return Error;
}
int test_exp2()
{
int Error(0);
float A = glm::exp2(10.f);
glm::vec1 B = glm::exp2(glm::vec1(10.f));
glm::vec2 C = glm::exp2(glm::vec2(10.f));
glm::vec3 D = glm::exp2(glm::vec3(10.f));
glm::vec4 E = glm::exp2(glm::vec4(10.f));
return Error;
}
int test_log2()
{
int Error(0);
float A = glm::log2(10.f);
glm::vec1 B = glm::log2(glm::vec1(10.f));
glm::vec2 C = glm::log2(glm::vec2(10.f));
glm::vec3 D = glm::log2(glm::vec3(10.f));
glm::vec4 E = glm::log2(glm::vec4(10.f));
return Error;
}
int test_sqrt()
{
int Error(0);
float A = glm::sqrt(10.f);
glm::vec1 B = glm::sqrt(glm::vec1(10.f));
glm::vec2 C = glm::sqrt(glm::vec2(10.f));
glm::vec3 D = glm::sqrt(glm::vec3(10.f));
glm::vec4 E = glm::sqrt(glm::vec4(10.f));
return Error;
}
int test_inversesqrt()
{
int Error(0);
glm::uint ulp(0);
float diff(0.0f);
for(float f = 0.001f; f < 10.f; f *= 1.001f)
{
int Error(0);
glm::lowp_fvec1 lowp_v = glm::inversesqrt(glm::lowp_fvec1(f));
float defaultp_v = glm::inversesqrt(f);
glm::uint ulp(0);
float diff(0.0f);
for(float f = 0.001f; f < 10.f; f *= 1.001f)
{
glm::lowp_fvec1 lowp_v = glm::inversesqrt(glm::lowp_fvec1(f));
float defaultp_v = glm::inversesqrt(f);
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
diff = glm::abs(lowp_v.x - defaultp_v);
}
return Error;
ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
diff = glm::abs(lowp_v.x - defaultp_v);
}
}//namespace inversesqrt
return Error;
}
int main()
{
int Error(0);
Error += inversesqrt::test();
Error += test_pow();
Error += test_exp();
Error += test_log();
Error += test_exp2();
Error += test_log2();
Error += test_sqrt();
Error += test_inversesqrt();
return Error;
}

View File

@@ -7,7 +7,7 @@
// File : test/core/func_trigonometric.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/trigonometric.hpp>
int main()
{

View File

@@ -7,6 +7,7 @@
// File : test/gtx/gtx_integer.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/exponential.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtx/integer.hpp>
#include <cstdio>