Updated random tests

This commit is contained in:
Christophe Riccio 2011-06-01 10:45:24 +01:00
parent 74e22c481e
commit b049cae5f2
4 changed files with 68 additions and 2 deletions

View File

@ -17,7 +17,7 @@ namespace random
template <>
GLM_FUNC_QUALIFIER float signedRand1()
{
#if(GLM_COMPILER & GLM_COMPILER_VC)
#if(GLM_COMPILER & GLM_COMPILER_VC)// && (GLM_COMPILER < GLM_COMPILER_VC2010)
#define RAND_SHIFT_NUM 5
#else
#define RAND_SHIFT_NUM 0

View File

@ -1,6 +1,7 @@
glmCreateTestGTC(gtx_bit)
glmCreateTestGTC(gtx_noise)
glmCreateTestGTC(gtx_quaternion)
glmCreateTestGTC(gtx_random)
glmCreateTestGTC(gtx_rotate_vector)
glmCreateTestGTC(gtx_simd_vec4)
glmCreateTestGTC(gtx_simd_mat4)

View File

@ -11,17 +11,40 @@
#include <glm/gtx/noise.hpp>
#include <iostream>
int main()
int test_simplex()
{
float ValueSNoise2D = glm::simplex(glm::vec2(0.5f));
float ValueSNoise3D = glm::simplex(glm::vec3(0.5f));
float ValueSNoise4D = glm::simplex(glm::vec4(0.5f));
return 0;
}
int test_perlin()
{
float ValueCNoise2D = glm::perlin(glm::vec2(0.5f));
float ValueCNoise3D = glm::perlin(glm::vec3(0.5f));
float ValueCNoise4D = glm::perlin(glm::vec4(0.5f));
return 0;
}
int test_perlin_pedioric()
{
float ValuePNoise2D = glm::perlin(glm::vec2(0.5f), glm::vec2(0.5f));
float ValuePNoise3D = glm::perlin(glm::vec3(0.5f), glm::vec3(0.5f));
float ValuePNoise4D = glm::perlin(glm::vec4(0.5f), glm::vec4(0.5f));
return 0;
}
int main()
{
int Error = 0;
Error += test_simplex();
Error += test_perlin();
Error += test_perlin_pedioric();
return Error;
}

42
test/gtx/gtx_random.cpp Normal file
View File

@ -0,0 +1,42 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-05-31
// Updated : 2011-05-31
// Licence : This source is under MIT licence
// File : test/gtx/random.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/random.hpp>
#include <glm/gtx/epsilon.hpp>
#include <iostream>
int test_signedRand1()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::signedRand1<float>();
ResultDouble += glm::signedRand1<double>();
}
Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f);
Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001);
}
return Error;
}
int main()
{
int Error = 0;
Error += test_signedRand1();
return Error;
}