2011-01-14 19:35:39 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Created : 2010-09-16
|
|
|
|
// Updated : 2010-09-16
|
|
|
|
// Licence : This source is under MIT licence
|
|
|
|
// File : test/gtx/simd-mat4.cpp
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define GLM_INSTRUCTION_SET GLM_PLATFORM_SSE3 | GLM_PLATFORM_SSE2
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include <glm/gtc/swizzle.hpp>
|
|
|
|
|
2011-01-15 02:37:34 +00:00
|
|
|
int test_swizzle_vec4_ref_dynamic()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec4 B(2, 1, 0, 3);
|
|
|
|
glm::swizzle(A, glm::Z, glm::Y, glm::X, glm::W) = B;
|
|
|
|
assert(A.x == B.x && A.y == B.y && A.z == B.z && A.w == B.w);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec3 B(2, 1, 0);
|
|
|
|
glm::swizzle(A, glm::Z, glm::Y, glm::X) = B;
|
|
|
|
assert(A.x == B.x && A.y == B.y && A.z == B.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec2 B(2, 1);
|
|
|
|
glm::swizzle(A, glm::Z, glm::Y) = B;
|
|
|
|
assert(A.x == B.x && A.y == B.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
int B(2);
|
|
|
|
glm::swizzle(A, glm::Z) = B;
|
2011-01-15 20:03:31 +00:00
|
|
|
assert(A.x == B);
|
2011-01-15 02:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_swizzle_vec4_ref_static()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec4 B(2, 1, 0, 3);
|
|
|
|
glm::swizzle<glm::Z, glm::Y, glm::X, glm::W>(A) = B;
|
|
|
|
assert(A.x == B.x && A.y == B.y && A.z == B.z && A.w == B.w);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec3 B(2, 1, 0);
|
|
|
|
glm::swizzle<glm::Z, glm::Y, glm::X>(A) = B;
|
|
|
|
assert(A.x == B.x && A.y == B.y && A.z == B.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec2 B(2, 1);
|
|
|
|
glm::swizzle<glm::Z, glm::Y>(A) = B;
|
|
|
|
assert(A.x == B.x && A.y == B.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
int B(2);
|
|
|
|
glm::swizzle<glm::Z>(A) = B;
|
2011-01-15 20:03:31 +00:00
|
|
|
assert(A.x == B);
|
2011-01-15 02:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_swizzle_vec4_const_dynamic()
|
2011-01-14 19:35:39 +00:00
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
|
|
|
glm::ivec4 B = glm::swizzle(A, glm::B, glm::G, glm::R, glm::A);
|
2011-01-15 02:37:34 +00:00
|
|
|
assert(glm::all(glm::equal(A, B)));
|
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
glm::ivec3 C = glm::swizzle(A, glm::W, glm::Y, glm::Z);
|
2011-01-15 20:03:31 +00:00
|
|
|
assert(glm::all(glm::equal(glm::ivec3(A), C)));
|
2011-01-15 02:37:34 +00:00
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
glm::ivec2 D = glm::swizzle(A, glm::W, glm::X);
|
2011-01-15 20:03:31 +00:00
|
|
|
assert(glm::all(glm::equal(glm::ivec2(A), D)));
|
2011-01-15 02:37:34 +00:00
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
int E = glm::swizzle(A, glm::Q);
|
|
|
|
assert(E == A.q);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-15 02:37:34 +00:00
|
|
|
int test_swizzle_vec4_const_static()
|
2011-01-14 19:35:39 +00:00
|
|
|
{
|
|
|
|
glm::ivec4 A(0, 1, 2, 3);
|
2011-01-15 02:37:34 +00:00
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
glm::ivec4 B = glm::swizzle<glm::B, glm::G, glm::R, glm::A>(A);
|
2011-01-15 02:37:34 +00:00
|
|
|
assert(glm::all(glm::equal(A, B)));
|
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
glm::ivec3 C = glm::swizzle<glm::W, glm::Y, glm::Z>(A);
|
2011-01-15 20:03:31 +00:00
|
|
|
assert(glm::all(glm::equal(glm::ivec3(A), C)));
|
2011-01-15 02:37:34 +00:00
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
glm::ivec2 D = glm::swizzle<glm::W, glm::X>(A);
|
2011-01-15 20:03:31 +00:00
|
|
|
assert(glm::all(glm::equal(glm::ivec2(A), D)));
|
2011-01-15 02:37:34 +00:00
|
|
|
|
2011-01-14 19:35:39 +00:00
|
|
|
int E = glm::swizzle<glm::Q>(A);
|
|
|
|
assert(E == A.q);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, void* argv[])
|
|
|
|
{
|
|
|
|
int Failed = 0;
|
2011-01-15 02:37:34 +00:00
|
|
|
Failed += test_swizzle_vec4_ref_dynamic();
|
|
|
|
Failed += test_swizzle_vec4_ref_static();
|
|
|
|
Failed += test_swizzle_vec4_const_dynamic();
|
|
|
|
Failed += test_swizzle_vec4_const_static();
|
2011-01-14 19:35:39 +00:00
|
|
|
|
|
|
|
return Failed;
|
|
|
|
}
|