2016-09-01 23:32:12 +02:00
|
|
|
#define GLM_FORCE_SWIZZLE
|
2018-08-05 18:24:22 +02:00
|
|
|
#include <glm/ext/scalar_relational.hpp>
|
2018-07-27 01:15:58 +02:00
|
|
|
#include <glm/ext/vector_relational.hpp>
|
2011-10-18 16:27:20 +01:00
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
|
2018-07-11 02:53:22 +02:00
|
|
|
static int test_ivec2_swizzle()
|
2011-10-19 16:49:28 +01:00
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
2018-07-31 23:05:48 +02:00
|
|
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
2018-07-14 17:56:40 +02:00
|
|
|
{
|
|
|
|
|
glm::ivec2 A(1, 2);
|
|
|
|
|
glm::ivec2 B = A.yx();
|
|
|
|
|
glm::ivec2 C = B.yx();
|
2011-10-19 16:49:28 +01:00
|
|
|
|
2018-07-14 17:56:40 +02:00
|
|
|
Error += A != B ? 0 : 1;
|
|
|
|
|
Error += A == C ? 0 : 1;
|
|
|
|
|
}
|
2018-07-31 23:05:48 +02:00
|
|
|
# endif//GLM_CONFIG_SWIZZLE
|
2018-07-14 17:56:40 +02:00
|
|
|
|
2018-07-31 23:05:48 +02:00
|
|
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
2018-07-14 17:56:40 +02:00
|
|
|
{
|
|
|
|
|
glm::ivec2 A(1, 2);
|
|
|
|
|
glm::ivec2 B = A.yx;
|
|
|
|
|
glm::ivec2 C = A.yx;
|
|
|
|
|
|
|
|
|
|
Error += A != B ? 0 : 1;
|
|
|
|
|
Error += B == C ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
B.xy = B.yx;
|
|
|
|
|
C.xy = C.yx;
|
|
|
|
|
|
|
|
|
|
Error += B == C ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec2 D(0, 0);
|
|
|
|
|
D.yx = A.xy;
|
|
|
|
|
Error += A.yx() == D ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec2 E = A.yx;
|
|
|
|
|
Error += E == D ? 0 : 1;
|
|
|
|
|
}
|
2018-07-31 23:05:48 +02:00
|
|
|
# endif//GLM_CONFIG_SWIZZLE
|
2011-10-19 16:49:28 +01:00
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-01 18:22:47 +02:00
|
|
|
int test_ivec3_swizzle()
|
2011-10-19 16:49:28 +01:00
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
2018-07-31 23:05:48 +02:00
|
|
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
2018-07-14 17:56:40 +02:00
|
|
|
{
|
|
|
|
|
glm::ivec3 A(1, 2, 3);
|
|
|
|
|
glm::ivec3 B = A.zyx();
|
|
|
|
|
glm::ivec3 C = B.zyx();
|
2011-10-19 16:49:28 +01:00
|
|
|
|
2018-07-14 17:56:40 +02:00
|
|
|
Error += A != B ? 0 : 1;
|
|
|
|
|
Error += A == C ? 0 : 1;
|
|
|
|
|
}
|
2018-07-14 19:56:13 +02:00
|
|
|
# endif
|
2018-07-14 17:56:40 +02:00
|
|
|
|
2018-07-31 23:05:48 +02:00
|
|
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR
|
2018-07-14 17:56:40 +02:00
|
|
|
{
|
2018-07-14 19:14:08 +02:00
|
|
|
glm::ivec3 const A(1, 2, 3);
|
2018-07-14 17:56:40 +02:00
|
|
|
glm::ivec2 B = A.yx;
|
|
|
|
|
glm::ivec2 C = A.yx;
|
|
|
|
|
|
|
|
|
|
Error += A.yx() == B ? 0 : 1;
|
|
|
|
|
Error += B == C ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
B.xy = B.yx;
|
|
|
|
|
C.xy = C.yx;
|
|
|
|
|
|
|
|
|
|
Error += B == C ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec2 D(0, 0);
|
|
|
|
|
D.yx = A.xy;
|
|
|
|
|
|
|
|
|
|
Error += A.yx() == D ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec2 E(0, 0);
|
|
|
|
|
E.xy = A.xy();
|
|
|
|
|
|
|
|
|
|
Error += E == A.xy() ? 0 : 1;
|
|
|
|
|
Error += E.xy() == A.xy() ? 0 : 1;
|
2018-07-14 19:14:08 +02:00
|
|
|
|
|
|
|
|
glm::ivec3 const F = A.xxx + A.xxx;
|
|
|
|
|
Error += F == glm::ivec3(2) ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec3 const G = A.xxx - A.xxx;
|
|
|
|
|
Error += G == glm::ivec3(0) ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec3 const H = A.xxx * A.xxx;
|
|
|
|
|
Error += H == glm::ivec3(1) ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec3 const I = A.xxx / A.xxx;
|
|
|
|
|
Error += I == glm::ivec3(1) ? 0 : 1;
|
2018-07-14 19:56:13 +02:00
|
|
|
|
|
|
|
|
glm::ivec3 J(1, 2, 3);
|
|
|
|
|
J.xyz += glm::ivec3(1);
|
|
|
|
|
Error += J == glm::ivec3(2, 3, 4) ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
glm::ivec3 K(1, 2, 3);
|
|
|
|
|
K.xyz += A.xyz;
|
|
|
|
|
Error += K == glm::ivec3(2, 4, 6) ? 0 : 1;
|
2018-07-14 17:56:40 +02:00
|
|
|
}
|
2018-07-14 19:56:13 +02:00
|
|
|
# endif
|
2011-10-19 16:49:28 +01:00
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-01 18:22:47 +02:00
|
|
|
int test_ivec4_swizzle()
|
2011-10-18 16:27:20 +01:00
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
2018-07-31 23:05:48 +02:00
|
|
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
2018-07-14 19:56:13 +02:00
|
|
|
{
|
|
|
|
|
glm::ivec4 A(1, 2, 3, 4);
|
|
|
|
|
glm::ivec4 B = A.wzyx();
|
|
|
|
|
glm::ivec4 C = B.wzyx();
|
2011-10-18 16:27:20 +01:00
|
|
|
|
2018-07-14 19:56:13 +02:00
|
|
|
Error += A != B ? 0 : 1;
|
|
|
|
|
Error += A == C ? 0 : 1;
|
|
|
|
|
}
|
|
|
|
|
# endif
|
2011-10-18 16:27:20 +01:00
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-01 18:22:47 +02:00
|
|
|
int test_vec4_swizzle()
|
|
|
|
|
{
|
|
|
|
|
int Error = 0;
|
|
|
|
|
|
2018-07-31 23:05:48 +02:00
|
|
|
# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_FUNCTION
|
2018-07-14 19:56:13 +02:00
|
|
|
{
|
|
|
|
|
glm::vec4 A(1, 2, 3, 4);
|
|
|
|
|
glm::vec4 B = A.wzyx();
|
|
|
|
|
glm::vec4 C = B.wzyx();
|
2013-09-01 18:22:47 +02:00
|
|
|
|
2018-07-28 13:57:38 +02:00
|
|
|
Error += glm::any(glm::notEqual(A, B, 0.0001f)) ? 0 : 1;
|
|
|
|
|
Error += glm::all(glm::equal(A, C, 0.0001f)) ? 0 : 1;
|
2013-09-01 18:22:47 +02:00
|
|
|
|
2018-07-27 01:15:58 +02:00
|
|
|
float D = glm::dot(C.wzyx(), C.xyzw());
|
|
|
|
|
Error += glm::equal(D, 20.f, 0.001f) ? 0 : 1;
|
2018-07-14 19:56:13 +02:00
|
|
|
}
|
|
|
|
|
# endif
|
2016-05-30 14:23:58 +02:00
|
|
|
|
2013-09-01 18:22:47 +02:00
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-18 16:27:20 +01:00
|
|
|
int main()
|
|
|
|
|
{
|
2013-05-12 11:40:25 +02:00
|
|
|
int Error = 0;
|
|
|
|
|
|
2018-07-12 00:36:59 +02:00
|
|
|
Error += test_ivec2_swizzle();
|
|
|
|
|
Error += test_ivec3_swizzle();
|
|
|
|
|
Error += test_ivec4_swizzle();
|
|
|
|
|
Error += test_vec4_swizzle();
|
2013-05-12 11:40:25 +02:00
|
|
|
|
2011-10-18 16:27:20 +01:00
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|