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();

View File

@@ -3,6 +3,7 @@ glmCreateTestGTC(gtc_matrix_access)
glmCreateTestGTC(gtc_matrix_integer)
glmCreateTestGTC(gtc_matrix_inverse)
glmCreateTestGTC(gtc_matrix_transform)
glmCreateTestGTC(gtc_noise)
glmCreateTestGTC(gtc_quaternion)
glmCreateTestGTC(gtc_random)
glmCreateTestGTC(gtc_swizzle)

View File

@@ -90,41 +90,211 @@ int test_half_ctor_mat2x3()
{
int Error = 0;
return Error;
{
glm::hvec3 A(1, 2, 3);
glm::hvec3 B(4, 5, 6);
glm::hmat2x3 C(A, B);
glm::hmat2x3 D(1, 2, 3, 4, 5, 6);
Error += C[0] == D[0] ? 0 : 1;
Error += C[1] == D[1] ? 0 : 1;
}
{
glm::hvec3 A(1.0, 2.0f, 3u);
glm::hvec3 B(4, 5u, 6u);
glm::hmat2x3 C(A, B);
glm::hmat2x3 D(1, 2.0, 3u, 4.0f, 5.0, 6);
Error += C[0] == D[0] ? 0 : 1;
Error += C[1] == D[1] ? 0 : 1;
}
{
glm::hmat2x3 A(1);
glm::mat2x3 B(1);
glm::hmat2x3 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
int test_half_ctor_mat2x4()
{
int Error = 0;
return Error;
{
glm::hvec4 A(1, 2, 3, 4);
glm::hvec4 B(5, 6, 7, 8);
glm::hmat2x4 C(A, B);
glm::hmat2x4 D(1, 2, 3, 4, 5, 6, 7, 8);
Error += C[0] == D[0] ? 0 : 1;
Error += C[1] == D[1] ? 0 : 1;
}
{
glm::hvec4 A(1.0, 2.0f, 3u, 4u);
glm::hvec4 B(5u, 6u, 7.0, 8.0);
glm::hmat2x4 C(A, B);
glm::hmat2x4 D(1, 2.0, 3u, 4.0f, 5.0, 6, 7.0f, 8.0f);
Error += C[0] == D[0] ? 0 : 1;
Error += C[1] == D[1] ? 0 : 1;
}
{
glm::hmat2x4 A(1);
glm::mat2x4 B(1);
glm::hmat2x4 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
int test_half_ctor_mat3x2()
{
int Error = 0;
return Error;
{
glm::hvec2 A(1, 2);
glm::hvec2 B(3, 4);
glm::hvec2 C(5, 6);
glm::hmat3x2 M(A, B, C);
glm::hmat3x2 N(1, 2, 3, 4, 5, 6);
Error += M == N ? 0 : 1;
}
{
glm::hvec2 A(1, 2.0);
glm::hvec2 B(3, 4.0f);
glm::hvec2 C(5u, 6.0f);
glm::hmat3x2 M(A, B, C);
glm::hmat3x2 N(1, 2.0, 3u, 4.0f, 5, 6);
Error += M == N ? 0 : 1;
}
{
glm::hmat3x2 A(1);
glm::mat3x2 B(1);
glm::hmat3x2 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
int test_half_ctor_mat3x3()
{
int Error = 0;
return Error;
{
glm::hvec3 A(1, 2, 3);
glm::hvec3 B(4, 5, 6);
glm::hvec3 C(7, 8, 9);
glm::hmat3x3 M(A, B, C);
glm::hmat3x3 N(1, 2, 3, 4, 5, 6, 7, 8, 9);
Error += M == N ? 0 : 1;
}
{
glm::hvec3 A(1, 2.0, 3.0f);
glm::hvec3 B(4, 5.0f, 6.0);
glm::hvec3 C(7u, 8.0f, 9);
glm::hmat3x3 M(A, B, C);
glm::hmat3x3 N(1, 2.0, 3u, 4.0f, 5, 6, 7.0f, 8.0, 9u);
Error += M == N ? 0 : 1;
}
{
glm::hmat3x3 A(1);
glm::mat3x3 B(1);
glm::hmat3x3 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
int test_half_ctor_mat3x4()
{
int Error = 0;
return Error;
{
glm::hvec4 A(1, 2, 3, 4);
glm::hvec4 B(5, 6, 7, 8);
glm::hvec4 C(9, 10, 11, 12);
glm::hmat3x4 M(A, B, C);
glm::hmat3x4 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
Error += M == N ? 0 : 1;
}
{
glm::hvec4 A(1, 2.0, 3.0f, 4u);
glm::hvec4 B(5, 6.0f, 7.0, 8);
glm::hvec4 C(9u, 10.0f, 11, 12.f);
glm::hmat3x4 M(A, B, C);
glm::hmat3x4 N(1, 2.0, 3u, 4.0f, 5, 6, 7.0f, 8.0, 9u, 10, 11.f, 12.0);
Error += M == N ? 0 : 1;
}
{
glm::hmat3x4 A(1);
glm::mat3x4 B(1);
glm::hmat3x4 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
int test_half_ctor_mat4x2()
{
int Error = 0;
{
glm::hvec2 A(1, 2);
glm::hvec2 B(3, 4);
glm::hvec2 C(5, 6);
glm::hvec2 D(7, 8);
glm::hmat4x2 M(A, B, C, D);
glm::hmat4x2 N(1, 2, 3, 4, 5, 6, 7, 8);
Error += M == N ? 0 : 1;
}
{
glm::hvec2 A(1, 2.0);
glm::hvec2 B(3.0f, 4);
glm::hvec2 C(5.0, 6u);
glm::hvec2 D(7, 8u);
glm::hmat4x2 M(A, B, C, D);
glm::hmat4x2 N(1, 2.0, 3u, 4.0f, 5u, 6.0, 7, 8.0f);
Error += M == N ? 0 : 1;
}
{
glm::hmat4x2 A(1);
glm::mat4x2 B(1);
glm::hmat4x2 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
@@ -132,6 +302,36 @@ int test_half_ctor_mat4x3()
{
int Error = 0;
{
glm::hvec3 A(1, 2, 3);
glm::hvec3 B(4, 5, 6);
glm::hvec3 C(7, 8, 9);
glm::hvec3 D(10, 11, 12);
glm::hmat4x3 M(A, B, C, D);
glm::hmat4x3 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
Error += M == N ? 0 : 1;
}
{
glm::hvec3 A(1, 2.0, 3u);
glm::hvec3 B(4.0f, 5, 6u);
glm::hvec3 C(7.0, 8u, 9.f);
glm::hvec3 D(10, 11u, 12.0);
glm::hmat4x3 M(A, B, C, D);
glm::hmat4x3 N(1, 2.0, 3u, 4.0f, 5u, 6.0, 7, 8.0f, 9, 10u, 11.f, 12.0);
Error += M == N ? 0 : 1;
}
{
glm::hmat4x3 A(1);
glm::mat4x3 B(1);
glm::hmat4x3 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
@@ -139,6 +339,36 @@ int test_half_ctor_mat4x4()
{
int Error = 0;
{
glm::hvec4 A(1, 2, 3, 4);
glm::hvec4 B(5, 6, 7, 8);
glm::hvec4 C(9, 10, 11, 12);
glm::hvec4 D(13, 14, 15, 16);
glm::hmat4x4 M(A, B, C, D);
glm::hmat4x4 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
Error += M == N ? 0 : 1;
}
{
glm::hvec4 A(1, 2.0, 3u, 4);
glm::hvec4 B(5.0f, 6, 7u, 8.0);
glm::hvec4 C(9.0, 10u, 11.f, 12);
glm::hvec4 D(13, 14u, 15.0, 16u);
glm::hmat4x4 M(A, B, C, D);
glm::hmat4x4 N(1, 2.0, 3u, 4.0f, 5u, 6.0, 7, 8.0f, 9, 10u, 11.f, 12.0, 13, 14u, 15.0f, 16.0);
Error += M == N ? 0 : 1;
}
{
glm::hmat4x4 A(1);
glm::mat4x4 B(1);
glm::hmat4x4 C(A);
Error += A == C ? 0 : 1;
}
return Error;
}
@@ -288,6 +518,14 @@ int main()
Error += test_half_ctor_vec3();
Error += test_half_ctor_vec4();
Error += test_half_ctor_mat2x2();
Error += test_half_ctor_mat2x3();
Error += test_half_ctor_mat2x4();
Error += test_half_ctor_mat3x2();
Error += test_half_ctor_mat3x3();
Error += test_half_ctor_mat3x4();
Error += test_half_ctor_mat4x2();
Error += test_half_ctor_mat4x3();
Error += test_half_ctor_mat4x4();
Error += test_half_precision_scalar();
Error += test_half_precision_vec();
Error += test_half_precision_mat();

199
test/gtc/gtc_noise.cpp Normal file
View File

@@ -0,0 +1,199 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-21
// Updated : 2011-04-26
// Licence : This source is under MIT licence
// File : test/gtx/noise.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/noise.hpp>
#include <gli/gli.hpp>
#include <gli/gtx/loader.hpp>
#include <iostream>
int test_simplex()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex4d_256.dds");
}
return 0;
}
int test_perlin()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin4d_256.dds");
}
return 0;
}
int test_perlin_pedioric()
{
std::size_t const Size = 256;
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f), glm::vec2(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f), glm::vec3(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_3d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f), glm::vec4(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_4d_256.dds");
}
return 0;
}
int main()
{
int Error = 0;
Error += test_simplex();
Error += test_perlin();
Error += test_perlin_pedioric();
return Error;
}

View File

@@ -8,11 +8,11 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/random.hpp>
#include <glm/gtc/random.hpp>
#include <glm/gtx/epsilon.hpp>
#include <iostream>
int test_signedRand1()
int test_linearRand()
{
int Error = 0;
@@ -21,8 +21,8 @@ int test_signedRand1()
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::signedRand1<float>(/*-1.0f, 1.0f*/);
ResultDouble += glm::signedRand1<double>(/*-1.0, 1.0*/);
ResultFloat += glm::linearRand(-1.0f, 1.0f);
ResultDouble += glm::linearRand(-1.0, 1.0);
}
Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f);
@@ -33,7 +33,7 @@ int test_signedRand1()
return Error;
}
int test_normalizedRand2()
int test_circularRand()
{
int Error = 0;
@@ -41,21 +41,23 @@ int test_normalizedRand2()
std::size_t Max = 100000;
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
double Radius = 2.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloat += glm::length(glm::normalizedRand2(1.0f, 1.0f));
ResultDouble += glm::length(glm::normalizedRand2(1.0f, 1.0f));
ResultFloat += glm::length(glm::circularRand(1.0f));
ResultDouble += glm::length(glm::circularRand(Radius));
}
Error += glm::equalEpsilon(ResultFloat, float(Max), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDouble, double(Max), 0.01) ? 0 : 1;
Error += glm::equalEpsilon(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_normalizedRand3()
int test_sphericalRand()
{
int Error = 0;
@@ -67,22 +69,67 @@ int test_normalizedRand3()
double ResultDoubleA = 0.0f;
double ResultDoubleB = 0.0f;
double ResultDoubleC = 0.0f;
for(std::size_t i = 0; i < Max; ++i)
{
ResultFloatA += glm::length(glm::normalizedRand3(1.0f, 1.0f));
ResultDoubleA += glm::length(glm::normalizedRand3(1.0f, 1.0f));
ResultFloatB += glm::length(glm::normalizedRand3(2.0f, 2.0f));
ResultDoubleB += glm::length(glm::normalizedRand3(2.0, 2.0));
ResultFloatC += glm::length(glm::normalizedRand3(1.0f, 3.0f));
ResultDoubleC += glm::length(glm::normalizedRand3(1.0, 3.0));
ResultFloatA += glm::length(glm::sphericalRand(1.0f));
ResultDoubleA += glm::length(glm::sphericalRand(1.0));
ResultFloatB += glm::length(glm::sphericalRand(2.0f));
ResultDoubleB += glm::length(glm::sphericalRand(2.0));
ResultFloatC += glm::length(glm::sphericalRand(3.0f));
ResultDoubleC += glm::length(glm::sphericalRand(3.0));
}
Error += glm::equalEpsilon(ResultFloatA, float(Max), 100.0f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleA, double(Max), 100.0) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 100.0001f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 100.0001) ? 0 : 1;
Error += (ResultFloatC >= float(Max) && ResultFloatC <= float(Max * 3)) ? 0 : 1;
Error += (ResultDoubleC >= double(Max) && ResultDoubleC <= double(Max * 3)) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
Error += glm::equalEpsilon(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
Error += glm::equalEpsilon(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_diskRand()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::length(glm::diskRand(2.0f));
ResultDouble += glm::length(glm::diskRand(2.0));
}
Error += ResultFloat < 200000.f ? 0 : 1;
Error += ResultDouble < 200000.0 ? 0 : 1;
assert(!Error);
}
return Error;
}
int test_ballRand()
{
int Error = 0;
{
float ResultFloat = 0.0f;
double ResultDouble = 0.0f;
for(std::size_t i = 0; i < 100000; ++i)
{
ResultFloat += glm::length(glm::ballRand(2.0f));
ResultDouble += glm::length(glm::ballRand(2.0));
}
Error += ResultFloat < 200000.f ? 0 : 1;
Error += ResultDouble < 200000.0 ? 0 : 1;
assert(!Error);
}
@@ -93,9 +140,11 @@ int main()
{
int Error = 0;
Error += test_signedRand1();
Error += test_normalizedRand2();
Error += test_normalizedRand3();
Error += test_linearRand();
Error += test_circularRand();
Error += test_sphericalRand();
Error += test_diskRand();
Error += test_ballRand();
return Error;
}

View File

@@ -121,13 +121,83 @@ int test_swizzle_vec4_const_static()
return Error;
}
int test_swizzle_vec3_partial()
{
int Error = 0;
glm::ivec3 A(0, 1, 2);
{
glm::ivec3 B(A.swizzle(glm::R, glm::G, glm::B));
Error += (A == B) ? 0 : 1;
}
{
glm::ivec3 B(A.swizzle(glm::R, glm::G), 2);
Error += (A == B) ? 0 : 1;
}
{
glm::ivec3 B(0, A.swizzle(glm::G, glm::B));
Error += (A == B) ? 0 : 1;
}
return Error;
}
int test_swizzle_vec4_partial()
{
int Error = 0;
glm::ivec4 A(0, 1, 2, 3);
{
glm::ivec4 B(A.swizzle(glm::R, glm::G, glm::B), 3);
Error += (A == B) ? 0 : 1;
}
{
glm::ivec4 B(A.swizzle(glm::R, glm::G), 2, 3);
Error += (A == B) ? 0 : 1;
}
{
glm::ivec4 B(0, A.swizzle(glm::G, glm::B), 3);
Error += (A == B) ? 0 : 1;
}
{
glm::ivec4 B(0, 1, A.swizzle(glm::B, glm::A));
Error += (A == B) ? 0 : 1;
}
{
glm::ivec4 B(A.swizzle(glm::X, glm::Y), A.swizzle(glm::Z, glm::W));
Error += (A == B) ? 0 : 1;
}
{
glm::ivec4 B(A.swizzle(glm::X, glm::Y), glm::vec2(2, 3));
Error += (A == B) ? 0 : 1;
}
{
glm::ivec4 B(glm::vec2(0, 1), A.swizzle(glm::Z, glm::W));
Error += (A == B) ? 0 : 1;
}
return Error;
}
int main()
{
int Error = 0;
Error += test_swizzle_vec3_partial();
Error += test_swizzle_vec4_ref_dynamic();
Error += test_swizzle_vec4_ref_static();
Error += test_swizzle_vec4_const_dynamic();
Error += test_swizzle_vec4_const_static();
Error += test_swizzle_vec4_partial();
return Error;
}

View File

@@ -10,110 +10,180 @@
#include <glm/glm.hpp>
#include <glm/gtx/noise.hpp>
#include <gli/gli.hpp>
#include <gli/gtx/loader.hpp>
#include <iostream>
int test_simplex()
{
std::size_t const Size = 256;
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::simplex(glm::vec2(x / 16.f, y / 16.f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex2d_256.dds");
}
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::simplex(glm::vec3(x / 16.f, y / 16.f, 0.5f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex3d_256.dds");
}
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::simplex(glm::vec4(x / 16.f, y / 16.f, 0.5f, 0.5f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_simplex4d_256.dds");
}
return 0;
}
int test_perlin()
{
std::size_t const Size = 256;
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::perlin(glm::vec2(x / 16.f, y / 16.f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin3d_256.dds");
}
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::perlin(glm::vec3(x / 16.f, y / 16.f, 0.5f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin4d_256.dds");
}
{
float ImageData[256];
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
{
ImageData[x + y * 16] = glm::perlin(glm::vec4(x / 16.f, y / 16.f, 0.5f, 0.5f));
}
}
return 0;
}
int test_perlin_pedioric()
{
std::size_t const Size = 256;
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::perlin(glm::vec2(x / 16.f, y / 16.f), glm::vec2(0.5f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f), glm::vec2(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_2d_256.dds");
}
{
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f), glm::vec3(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_3d_256.dds");
}
{
float ImageData[256];
std::vector<glm::byte> ImageData(Size * Size * 3);
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[x + y * 16] = glm::perlin(glm::vec3(x / 16.f, y / 16.f, 0.5f), glm::vec3(0.5f));
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f), glm::vec4(2.0f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
gli::texture2D Texture(1);
Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U);
memcpy(Texture[0].data(), &ImageData[0], ImageData.size());
gli::saveDDS9(Texture, "texture_perlin_pedioric_4d_256.dds");
}
{
float ImageData[256];
for(std::size_t y = 0; y < 16; ++y)
for(std::size_t x = 0; x < 16; ++x)
{
ImageData[x + y * 16] = glm::perlin(glm::vec4(x / 16.f, y / 16.f, 0.5f, 0.5f), glm::vec4(0.5f));
}
}
return 0;
}