glm/test/gtc/gtc_half_float.cpp

193 lines
3.3 KiB
C++
Raw Normal View History

2011-01-20 11:02:39 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
2011-01-20 11:40:14 +00:00
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
2011-01-20 11:02:39 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
2011-05-31 15:45:41 +00:00
// Created : 2011-05-32
// Updated : 2011-05-32
2011-01-20 11:02:39 +00:00
// Licence : This source is under MIT licence
2011-05-31 15:45:41 +00:00
// File : test/gtc/half_float.cpp
2011-01-20 11:02:39 +00:00
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
2011-05-31 15:45:41 +00:00
#include <glm/gtc/half_float.hpp>
int test_half_precision_scalar()
{
int Error = 0;
Error += sizeof(glm::half) == 2 ? 0 : 1;
return Error;
}
int test_half_precision_vec()
{
int Error = 0;
Error += sizeof(glm::hvec2) == 4 ? 0 : 1;
Error += sizeof(glm::hvec3) == 6 ? 0 : 1;
Error += sizeof(glm::hvec4) == 8 ? 0 : 1;
return Error;
}
int test_half_precision_mat()
{
int Error = 0;
Error += sizeof(glm::hmat2) == 8 ? 0 : 1;
Error += sizeof(glm::hmat3) == 18 ? 0 : 1;
Error += sizeof(glm::hmat4) == 32 ? 0 : 1;
Error += sizeof(glm::hmat2x2) == 8 ? 0 : 1;
Error += sizeof(glm::hmat2x3) == 12 ? 0 : 1;
Error += sizeof(glm::hmat2x4) == 16 ? 0 : 1;
Error += sizeof(glm::hmat3x2) == 12 ? 0 : 1;
Error += sizeof(glm::hmat3x3) == 18 ? 0 : 1;
Error += sizeof(glm::hmat3x4) == 24 ? 0 : 1;
Error += sizeof(glm::hmat4x2) == 16 ? 0 : 1;
Error += sizeof(glm::hmat4x3) == 24 ? 0 : 1;
Error += sizeof(glm::hmat4x4) == 32 ? 0 : 1;
return Error;
}
2011-01-20 11:02:39 +00:00
int test_half_ctor_mat2x2()
{
int Error = 0;
{
glm::hvec2 A(1, 2);
glm::hvec2 B(3, 4);
glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f);
glm::hmat2 D(1, 2, 3, 4);
Error += C[0] == D[0] ? 0 : 1;
Error += C[1] == D[1] ? 0 : 1;
}
{
glm::hvec2 A(1, 2.0);
glm::hvec2 B(3, 4.0);
glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f);
glm::hmat2 D(1, 2.0, 3u, 4.0f);
Error += C[0] == D[0] ? 0 : 1;
Error += C[1] == D[1] ? 0 : 1;
}
return Error;
}
2011-07-11 08:52:03 +00:00
int test_half_ctor_mat2x3()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat2x4()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat3x2()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat3x3()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat3x4()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat4x2()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat4x3()
{
int Error = 0;
return Error;
}
int test_half_ctor_mat4x4()
{
int Error = 0;
return Error;
}
int test_half_ctor_vec2()
{
int Error = 0;
{
glm::hvec2 A(1, 2);
glm::hvec2 B(A);
glm::vec2 C(1, 2);
glm::hvec2 D(C);
glm::dvec2 E(1, 2);
glm::hvec2 F(E);
glm::hvec2 G(1, 2.0);
glm::hvec2 H;
H = A;
Error += A == B ? 0 : 1;
//Error += C == D ? 0 : 1; //Error
//Error += E == F ? 0 : 1; //Error
2011-07-11 08:52:03 +00:00
Error += A == G ? 0 : 1;
Error += A == H ? 0 : 1;
}
{
glm::hvec2 A(1);
glm::vec2 B(1);
//Error += A == B ? 0 : 1; //Error
2011-07-11 08:52:03 +00:00
}
return Error;
}
int test_half_ctor_vec3()
{
}
int test_half_ctor_vec4()
{
}
2011-01-24 15:44:14 +00:00
int main()
2011-01-20 11:02:39 +00:00
{
2011-05-31 15:45:41 +00:00
int Error = 0;
2011-07-11 08:52:03 +00:00
Error += test_half_ctor_vec2();
Error += test_half_ctor_vec3();
Error += test_half_ctor_vec4();
Error += test_half_ctor_mat2x2();
2011-05-31 15:45:41 +00:00
Error += test_half_precision_scalar();
Error += test_half_precision_vec();
Error += test_half_precision_mat();
2011-01-20 11:02:39 +00:00
2011-05-31 15:45:41 +00:00
return Error;
2011-01-20 11:02:39 +00:00
}