Fixed merge

This commit is contained in:
Christophe Riccio
2011-10-03 16:07:05 +01:00
37 changed files with 3966 additions and 931 deletions

View File

@@ -71,6 +71,118 @@ int test_vec2_operators()
Error += A.x == C.x && A.y == C.y ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
glm::vec2 C = A + B;
Error += C == glm::vec2(5, 7) ? 0 : 1;
glm::vec2 D = B - A;
Error += D == glm::vec2(3, 3) ? 0 : 1;
glm::vec2 E = A * B;
Error += E == glm::vec2(4, 10) ? 0 : 1;
glm::vec2 F = B / A;
Error += F == glm::vec2(4, 2.5) ? 0 : 1;
glm::vec2 G = A + 1.0f;
Error += G == glm::vec2(2, 3) ? 0 : 1;
glm::vec2 H = B - 1.0f;
Error += H == glm::vec2(3, 4) ? 0 : 1;
glm::vec2 I = A * 2.0f;
Error += I == glm::vec2(2, 4) ? 0 : 1;
glm::vec2 J = B / 2.0f;
Error += J == glm::vec2(2, 2.5) ? 0 : 1;
glm::vec2 K = 1.0f + A;
Error += K == glm::vec2(2, 3) ? 0 : 1;
glm::vec2 L = 1.0f - B;
Error += L == glm::vec2(-3, -4) ? 0 : 1;
glm::vec2 M = 2.0f * A;
Error += M == glm::vec2(2, 4) ? 0 : 1;
glm::vec2 N = 2.0f / B;
Error += N == glm::vec2(0.5, 2.0 / 5.0) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
A += B;
Error += A == glm::vec2(5, 7) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec2(6, 8) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
B -= A;
Error += B == glm::vec2(3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec2(2, 2) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
A *= B;
Error += A == glm::vec2(4, 10) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec2(8, 20) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B(4.0f, 5.0f);
B /= A;
Error += B == glm::vec2(4, 2.5) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec2(2, 1.25) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = -A;
Error += B == glm::vec2(-1.0f, -2.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = --A;
Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = A--;
Error += B == glm::vec2(0.0f, 1.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = ++A;
Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1;
}
{
glm::vec2 A(1.0f, 2.0f);
glm::vec2 B = A++;
Error += B == glm::vec2(2.0f, 3.0f) ? 0 : 1;
}
return Error;
}

View File

@@ -9,15 +9,159 @@
#include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
#include <vector>
static int test_vec3_operators()
int test_vec3_ctor()
{
glm::vec3 A(1.0f);
glm::vec3 B(1.0f);
bool R = A != B;
bool S = A == B;
int Error = 0;
{
glm::vec3 A(1);
glm::vec3 B(1, 1, 1);
Error += A == B ? 0 : 1;
}
{
std::vector<glm::vec3> Tests;
Tests.push_back(glm::vec3(glm::vec2(1, 2), 3));
Tests.push_back(glm::vec3(1, glm::vec2(2, 3)));
Tests.push_back(glm::vec3(1, 2, 3));
Tests.push_back(glm::vec3(glm::vec4(1, 2, 3, 4)));
return (S && !R) ? 0 : 1;
for(std::size_t i = 0; i < Tests.size(); ++i)
Error += Tests[i] == glm::vec3(1, 2, 3) ? 0 : 1;
}
return Error;
}
int test_vec3_operators()
{
int Error = 0;
{
glm::vec3 A(1.0f);
glm::vec3 B(1.0f);
bool R = A != B;
bool S = A == B;
Error += (S && !R) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
glm::vec3 C = A + B;
Error += C == glm::vec3(5, 7, 9) ? 0 : 1;
glm::vec3 D = B - A;
Error += D == glm::vec3(3, 3, 3) ? 0 : 1;
glm::vec3 E = A * B;
Error += E == glm::vec3(4, 10, 18) ? 0 : 1;
glm::vec3 F = B / A;
Error += F == glm::vec3(4, 2.5, 2) ? 0 : 1;
glm::vec3 G = A + 1.0f;
Error += G == glm::vec3(2, 3, 4) ? 0 : 1;
glm::vec3 H = B - 1.0f;
Error += H == glm::vec3(3, 4, 5) ? 0 : 1;
glm::vec3 I = A * 2.0f;
Error += I == glm::vec3(2, 4, 6) ? 0 : 1;
glm::vec3 J = B / 2.0f;
Error += J == glm::vec3(2, 2.5, 3) ? 0 : 1;
glm::vec3 K = 1.0f + A;
Error += K == glm::vec3(2, 3, 4) ? 0 : 1;
glm::vec3 L = 1.0f - B;
Error += L == glm::vec3(-3, -4, -5) ? 0 : 1;
glm::vec3 M = 2.0f * A;
Error += M == glm::vec3(2, 4, 6) ? 0 : 1;
glm::vec3 N = 2.0f / B;
Error += N == glm::vec3(0.5, 2.0 / 5.0, 2.0 / 6.0) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
A += B;
Error += A == glm::vec3(5, 7, 9) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec3(6, 8, 10) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
B -= A;
Error += B == glm::vec3(3, 3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec3(2, 2, 2) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
A *= B;
Error += A == glm::vec3(4, 10, 18) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec3(8, 20, 36) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
B /= A;
Error += B == glm::vec3(4, 2.5, 2) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec3(2, 1.25, 1) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = -A;
Error += B == glm::vec3(-1.0f, -2.0f, -3.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = --A;
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = A--;
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = ++A;
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = A++;
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
}
return Error;
}
int test_vec3_size()
@@ -172,15 +316,44 @@ int test_vec3_swizzle_half()
return Error;
}
int test_vec3_swizzle_partial()
{
int Error = 0;
glm::vec3 A(1, 2, 3);
{
glm::vec3 B(A.xy, 3.0f);
Error += A == B ? 0 : 1;
}
{
glm::vec3 B(1.0f, A.yz);
Error += A == B ? 0 : 1;
}
{
glm::vec3 B(A.xyz);
Error += A == B ? 0 : 1;
}
return Error;
}
int main()
{
int Error = 0;
Error += test_vec3_ctor();
Error += test_vec3_operators();
Error += test_vec3_size();
Error += test_vec3_swizzle3_2();
Error += test_vec3_swizzle3_3();
Error += test_vec3_swizzle_half();
Error += test_vec3_swizzle_partial();
return Error;
}

View File

@@ -9,6 +9,7 @@
#include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
#include <vector>
template <int Value>
struct mask
@@ -41,14 +42,161 @@ int test_hvec4()
return 0;
}
int test_vec4_ctor()
{
int Error = 0;
{
glm::vec4 A(1);
glm::vec4 B(1, 1, 1, 1);
Error += A == B ? 0 : 1;
}
{
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(glm::vec2(1, 2), 3, 4));
Tests.push_back(glm::vec4(1, glm::vec2(2, 3), 4));
Tests.push_back(glm::vec4(1, 2, glm::vec2(3, 4)));
Tests.push_back(glm::vec4(glm::vec3(1, 2, 3), 4));
Tests.push_back(glm::vec4(1, glm::vec3(2, 3, 4)));
Tests.push_back(glm::vec4(glm::vec2(1, 2), glm::vec2(3, 4)));
Tests.push_back(glm::vec4(1, 2, 3, 4));
Tests.push_back(glm::vec4(glm::vec4(1, 2, 3, 4)));
for(std::size_t i = 0; i < Tests.size(); ++i)
Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1;
}
return Error;
}
int test_vec4_operators()
{
glm::vec4 A(1.0f);
glm::vec4 B(1.0f);
bool R = A != B;
bool S = A == B;
int Error = 0;
{
glm::vec4 A(1.0f);
glm::vec4 B(1.0f);
bool R = A != B;
bool S = A == B;
return (S && !R) ? 0 : 1;
Error += (S && !R) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
glm::vec4 C = A + B;
Error += C == glm::vec4(5, 7, 9, 11) ? 0 : 1;
glm::vec4 D = B - A;
Error += D == glm::vec4(3, 3, 3, 3) ? 0 : 1;
glm::vec4 E = A * B;
Error += E == glm::vec4(4, 10, 18, 28) ? 0 : 1;
glm::vec4 F = B / A;
Error += F == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
glm::vec4 G = A + 1.0f;
Error += G == glm::vec4(2, 3, 4, 5) ? 0 : 1;
glm::vec4 H = B - 1.0f;
Error += H == glm::vec4(3, 4, 5, 6) ? 0 : 1;
glm::vec4 I = A * 2.0f;
Error += I == glm::vec4(2, 4, 6, 8) ? 0 : 1;
glm::vec4 J = B / 2.0f;
Error += J == glm::vec4(2, 2.5, 3, 3.5) ? 0 : 1;
glm::vec4 K = 1.0f + A;
Error += K == glm::vec4(2, 3, 4, 5) ? 0 : 1;
glm::vec4 L = 1.0f - B;
Error += L == glm::vec4(-3, -4, -5, -6) ? 0 : 1;
glm::vec4 M = 2.0f * A;
Error += M == glm::vec4(2, 4, 6, 8) ? 0 : 1;
glm::vec4 N = 2.0f / B;
Error += N == glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
A += B;
Error += A == glm::vec4(5, 7, 9, 11) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec4(6, 8, 10, 12) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
B -= A;
Error += B == glm::vec4(3, 3, 3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec4(2, 2, 2, 2) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
A *= B;
Error += A == glm::vec4(4, 10, 18, 28) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec4(8, 20, 36, 56) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f);
B /= A;
Error += B == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec4(2, 1.25, 1, 7.0f / 4.0f / 2.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = -A;
Error += B == glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = --A;
Error += B == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A--;
Error += B == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = ++A;
Error += B == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
}
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 B = A++;
Error += B == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1;
}
return Error;
}
int test_vec4_size()
@@ -71,6 +219,7 @@ int main()
//__m128 DataB = swizzle<W, Z, Y, X>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
int Error = 0;
Error += test_vec4_ctor();
Error += test_vec4_size();
Error += test_vec4_operators();
Error += test_hvec4();