Merge branch '0.9.3' into swizzle

This commit is contained in:
Christophe Riccio
2011-09-21 21:38:22 +01:00
4 changed files with 497 additions and 100 deletions

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

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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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 / 16.f, y / 16.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;
}