From bc877da307115438d61ad8302dcb4645e2fc721a Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 14 Apr 2010 13:25:41 +0100 Subject: [PATCH] Added test files --- test/CMakeLists.txt | 52 + test/bug.cpp | 0 test/core.cpp | 27 + test/core.hpp | 0 test/core/cast/mat.cpp | 130 ++ test/core/cast/mat.h | 6 + test/core/ctor/vec2.cpp | 11 + test/core/ctor/vec2.h | 6 + test/core/ctor/vec3.cpp | 12 + test/core/ctor/vec3.h | 6 + test/core/ctor/vec4.cpp | 14 + test/core/ctor/vec4.h | 6 + test/core/func_common.cpp | 882 ++++++++++ test/core/func_exponential.cpp | 351 ++++ test/core/func_geometric.cpp | 370 ++++ test/core/func_matrix.cpp | 81 + test/core/func_noise.cpp | 27 + test/core/func_trigonometric.cpp | 400 +++++ test/core/func_vector_relational.cpp | 383 +++++ test/core/type.cpp | 10 + test/core/type_float.cpp | 22 + test/core/type_half.cpp | 42 + test/core/type_int.cpp | 22 + test/core/type_mat2x2.cpp | 22 + test/core/type_mat2x3.cpp | 22 + test/core/type_mat2x4.cpp | 22 + test/core/type_mat3x2.cpp | 22 + test/core/type_mat3x3.cpp | 22 + test/core/type_mat3x4.cpp | 22 + test/core/type_mat4x2.cpp | 22 + test/core/type_mat4x3.cpp | 22 + test/core/type_mat4x4.cpp | 22 + test/core/type_vec1.cpp | 22 + test/core/type_vec2.cpp | 22 + test/core/type_vec3.cpp | 22 + test/core/type_vec4.cpp | 22 + test/gtc.cpp | 0 test/gtc.hpp | 0 test/gtc/double_float.cpp | 14 + test/gtc/half_float.cpp | 25 + test/gtc/matrix_access.cpp | 14 + test/gtc/matrix_operation.cpp | 14 + test/gtc/matrix_projection.cpp | 14 + test/gtc/matrix_transform.cpp | 14 + test/gtc/quaternion.cpp | 14 + test/gtc/type_precision.cpp | 14 + test/gtx.hpp | 0 test/gtx/associated_min_max.cpp | 222 +++ test/gtx/bit.cpp | 11 + test/gtx/closest_point.cpp | 11 + test/gtx/color_cast.cpp | 11 + test/gtx/color_space.cpp | 11 + test/gtx/comparison.cpp | 11 + test/gtx/compatibility.cpp | 11 + test/gtx/component_wise.cpp | 11 + test/gtx/epsilon.cpp | 11 + test/gtx/euler_angles.cpp | 11 + test/gtx/extend.cpp | 11 + test/gtx/extented_min_max.cpp | 11 + test/gtx/fast_exponential.cpp | 11 + test/gtx/fast_square_root.cpp | 11 + test/gtx/fast_trigonometry.cpp | 11 + test/gtx/handed_coordinate_space.cpp | 11 + test/gtx/inertia.cpp | 11 + test/gtx/integer.cpp | 11 + test/gtx/intersect.cpp | 27 + test/gtx/inverse.cpp | 11 + test/gtx/inverse_transpose.cpp | 11 + test/gtx/matrix_access.cpp | 11 + test/gtx/matrix_cross_product.cpp | 11 + test/gtx/matrix_major_storage.cpp | 11 + test/gtx/matrix_projection.cpp | 11 + test/gtx/matrix_query.cpp | 11 + test/gtx/matrix_selection.cpp | 11 + test/gtx/matx.cpp | 11 + test/gtx/mixed_product.cpp | 11 + test/gtx/norm.cpp | 11 + test/gtx/normal.cpp | 11 + test/gtx/normalize_dot.cpp | 11 + test/gtx/number_precision.cpp | 11 + test/gtx/optimum_pow.cpp | 11 + test/gtx/orthonormalize.cpp | 11 + test/gtx/perpendicular.cpp | 11 + test/gtx/polar_coordinates.cpp | 11 + test/gtx/projection.cpp | 11 + test/gtx/quaternion.cpp | 11 + test/gtx/random.cpp | 11 + test/gtx/rotate_vector.cpp | 11 + test/gtx/safe_limits.cpp | 12 + test/gtx/spline.cpp | 11 + test/gtx/statistics_operation.cpp | 11 + test/gtx/std_based_type.cpp | 11 + test/gtx/string_cast.cpp | 11 + test/gtx/transform.cpp | 11 + test/gtx/transform2.cpp | 11 + test/gtx/transpose.cpp | 10 + test/gtx/unsigned_int.cpp | 11 + test/gtx/vector_access.cpp | 11 + test/gtx/vector_angle.cpp | 11 + test/gtx/vector_query.cpp | 11 + test/gtx/vecx.cpp | 11 + test/gtx/verbose_operator.cpp | 11 + test/header.cpp | 128 ++ test/img.cpp | 34 + test/img.hpp | 24 + test/img/multiple.cpp | 127 ++ test/img/wrap.cpp | 141 ++ test/main.cpp | 2313 ++++++++++++++++++++++++++ test/precompiled.cpp | 2 + test/precompiled.hpp | 18 + test/virtrev.cpp | 0 test/virtrev.hpp | 0 112 files changed, 6888 insertions(+) create mode 100644 test/CMakeLists.txt create mode 100644 test/bug.cpp create mode 100644 test/core.cpp create mode 100644 test/core.hpp create mode 100644 test/core/cast/mat.cpp create mode 100644 test/core/cast/mat.h create mode 100644 test/core/ctor/vec2.cpp create mode 100644 test/core/ctor/vec2.h create mode 100644 test/core/ctor/vec3.cpp create mode 100644 test/core/ctor/vec3.h create mode 100644 test/core/ctor/vec4.cpp create mode 100644 test/core/ctor/vec4.h create mode 100644 test/core/func_common.cpp create mode 100644 test/core/func_exponential.cpp create mode 100644 test/core/func_geometric.cpp create mode 100644 test/core/func_matrix.cpp create mode 100644 test/core/func_noise.cpp create mode 100644 test/core/func_trigonometric.cpp create mode 100644 test/core/func_vector_relational.cpp create mode 100644 test/core/type.cpp create mode 100644 test/core/type_float.cpp create mode 100644 test/core/type_half.cpp create mode 100644 test/core/type_int.cpp create mode 100644 test/core/type_mat2x2.cpp create mode 100644 test/core/type_mat2x3.cpp create mode 100644 test/core/type_mat2x4.cpp create mode 100644 test/core/type_mat3x2.cpp create mode 100644 test/core/type_mat3x3.cpp create mode 100644 test/core/type_mat3x4.cpp create mode 100644 test/core/type_mat4x2.cpp create mode 100644 test/core/type_mat4x3.cpp create mode 100644 test/core/type_mat4x4.cpp create mode 100644 test/core/type_vec1.cpp create mode 100644 test/core/type_vec2.cpp create mode 100644 test/core/type_vec3.cpp create mode 100644 test/core/type_vec4.cpp create mode 100644 test/gtc.cpp create mode 100644 test/gtc.hpp create mode 100644 test/gtc/double_float.cpp create mode 100644 test/gtc/half_float.cpp create mode 100644 test/gtc/matrix_access.cpp create mode 100644 test/gtc/matrix_operation.cpp create mode 100644 test/gtc/matrix_projection.cpp create mode 100644 test/gtc/matrix_transform.cpp create mode 100644 test/gtc/quaternion.cpp create mode 100644 test/gtc/type_precision.cpp create mode 100644 test/gtx.hpp create mode 100644 test/gtx/associated_min_max.cpp create mode 100644 test/gtx/bit.cpp create mode 100644 test/gtx/closest_point.cpp create mode 100644 test/gtx/color_cast.cpp create mode 100644 test/gtx/color_space.cpp create mode 100644 test/gtx/comparison.cpp create mode 100644 test/gtx/compatibility.cpp create mode 100644 test/gtx/component_wise.cpp create mode 100644 test/gtx/epsilon.cpp create mode 100644 test/gtx/euler_angles.cpp create mode 100644 test/gtx/extend.cpp create mode 100644 test/gtx/extented_min_max.cpp create mode 100644 test/gtx/fast_exponential.cpp create mode 100644 test/gtx/fast_square_root.cpp create mode 100644 test/gtx/fast_trigonometry.cpp create mode 100644 test/gtx/handed_coordinate_space.cpp create mode 100644 test/gtx/inertia.cpp create mode 100644 test/gtx/integer.cpp create mode 100644 test/gtx/intersect.cpp create mode 100644 test/gtx/inverse.cpp create mode 100644 test/gtx/inverse_transpose.cpp create mode 100644 test/gtx/matrix_access.cpp create mode 100644 test/gtx/matrix_cross_product.cpp create mode 100644 test/gtx/matrix_major_storage.cpp create mode 100644 test/gtx/matrix_projection.cpp create mode 100644 test/gtx/matrix_query.cpp create mode 100644 test/gtx/matrix_selection.cpp create mode 100644 test/gtx/matx.cpp create mode 100644 test/gtx/mixed_product.cpp create mode 100644 test/gtx/norm.cpp create mode 100644 test/gtx/normal.cpp create mode 100644 test/gtx/normalize_dot.cpp create mode 100644 test/gtx/number_precision.cpp create mode 100644 test/gtx/optimum_pow.cpp create mode 100644 test/gtx/orthonormalize.cpp create mode 100644 test/gtx/perpendicular.cpp create mode 100644 test/gtx/polar_coordinates.cpp create mode 100644 test/gtx/projection.cpp create mode 100644 test/gtx/quaternion.cpp create mode 100644 test/gtx/random.cpp create mode 100644 test/gtx/rotate_vector.cpp create mode 100644 test/gtx/safe_limits.cpp create mode 100644 test/gtx/spline.cpp create mode 100644 test/gtx/statistics_operation.cpp create mode 100644 test/gtx/std_based_type.cpp create mode 100644 test/gtx/string_cast.cpp create mode 100644 test/gtx/transform.cpp create mode 100644 test/gtx/transform2.cpp create mode 100644 test/gtx/transpose.cpp create mode 100644 test/gtx/unsigned_int.cpp create mode 100644 test/gtx/vector_access.cpp create mode 100644 test/gtx/vector_angle.cpp create mode 100644 test/gtx/vector_query.cpp create mode 100644 test/gtx/vecx.cpp create mode 100644 test/gtx/verbose_operator.cpp create mode 100644 test/header.cpp create mode 100644 test/img.cpp create mode 100644 test/img.hpp create mode 100644 test/img/multiple.cpp create mode 100644 test/img/wrap.cpp create mode 100644 test/main.cpp create mode 100644 test/precompiled.cpp create mode 100644 test/precompiled.hpp create mode 100644 test/virtrev.cpp create mode 100644 test/virtrev.hpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..c8329f76 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) +cmake_policy(VERSION 2.6) + +project(glm) + +set(NAME glm-test) + +file(GLOB ROOT_SOURCE *.cpp) +file(GLOB ROOT_INLINE *.inl) +file(GLOB ROOT_HEADER *.hpp) + +file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp) +file(GLOB_RECURSE CORE_INLINE ./core/*.inl) +file(GLOB_RECURSE CORE_HEADER ./core/*.hpp) + +file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) +file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) +file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) + +file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) +file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) +file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) + +file(GLOB_RECURSE IMG_SOURCE ./img/*.cpp) +file(GLOB_RECURSE IMG_INLINE ./img/*.inl) +file(GLOB_RECURSE IMG_HEADER ./img/*.hpp) + +source_group("Core Files" FILES ${CORE_SOURCE}) +source_group("Core Files" FILES ${CORE_INLINE}) +source_group("Core Files" FILES ${CORE_HEADER}) +source_group("GTC Files" FILES ${GTC_SOURCE}) +source_group("GTC Files" FILES ${GTC_INLINE}) +source_group("GTC Files" FILES ${GTC_HEADER}) +source_group("GTX Files" FILES ${GTX_SOURCE}) +source_group("GTX Files" FILES ${GTX_INLINE}) +source_group("GTX Files" FILES ${GTX_HEADER}) +source_group("IMG Files" FILES ${IMG_SOURCE}) +source_group("IMG Files" FILES ${IMG_INLINE}) +source_group("IMG Files" FILES ${IMG_HEADER}) + +include_directories(..) + + + +add_executable(${NAME} + ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} + ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} + ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} + ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER} + ${IMG_SOURCE} ${IMG_INLINE} ${IMG_HEADER}) + +add_definitions(-D_CRT_SECURE_NO_WARNINGS) diff --git a/test/bug.cpp b/test/bug.cpp new file mode 100644 index 00000000..e69de29b diff --git a/test/core.cpp b/test/core.cpp new file mode 100644 index 00000000..c73f5a37 --- /dev/null +++ b/test/core.cpp @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-11-14 +// Updated : 2009-11-14 +// Licence : This source is under MIT licence +// File : test/bug.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace glm{ +namespace test +{ + bool main_bug() + { + bool Result = true; + + { + + } + + return Result; + } + +}//namespace test +}//namespace glm diff --git a/test/core.hpp b/test/core.hpp new file mode 100644 index 00000000..e69de29b diff --git a/test/core/cast/mat.cpp b/test/core/cast/mat.cpp new file mode 100644 index 00000000..48730343 --- /dev/null +++ b/test/core/cast/mat.cpp @@ -0,0 +1,130 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-14 +// Updated : 2008-03-14 +// Licence : This source is under MIT License +// File : test/core/ctor/mat.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../../precompiled.hpp" +#include + +using namespace glm; + +bool test_core_cast_mat() +{ + { + mat2x3 m01(1.0f); + mat2x4 m02(1.0f); + mat3x2 m03(1.0f); + mat3x4 m04(1.0f); + mat4x2 m05(1.0f); + mat4x3 m06(1.0f); + } + + { + mat2x3 m01(mat2(1.0f)); + mat2x3 m02(mat3(1.0f)); + mat2x3 m03(mat4(1.0f)); + mat2x3 m04(mat2x3(1.0f)); + mat2x3 m05(mat2x4(1.0f)); + mat2x3 m06(mat3x2(1.0f)); + mat2x3 m07(mat3x4(1.0f)); + mat2x3 m08(mat4x2(1.0f)); + mat2x3 m09(mat4x3(1.0f)); + } + + { + mat2x4 m01(mat2(1.0f)); + mat2x4 m02(mat3(1.0f)); + mat2x4 m03(mat4(1.0f)); + mat2x4 m04(mat2x3(1.0f)); + mat2x4 m05(mat2x4(1.0f)); + mat2x4 m06(mat3x2(1.0f)); + mat2x4 m07(mat3x4(1.0f)); + mat2x4 m08(mat4x2(1.0f)); + mat2x4 m09(mat4x3(1.0f)); + } + + { + mat3x2 m01(mat2(1.0f)); + mat3x2 m02(mat3(1.0f)); + mat3x2 m03(mat4(1.0f)); + mat3x2 m04(mat2x3(1.0f)); + mat3x2 m05(mat2x4(1.0f)); + mat3x2 m06(mat3x2(1.0f)); + mat3x2 m07(mat3x4(1.0f)); + mat3x2 m08(mat4x2(1.0f)); + mat3x2 m09(mat4x3(1.0f)); + } + + { + mat3x4 m01(mat2(1.0f)); + mat3x4 m02(mat3(1.0f)); + mat3x4 m03(mat4(1.0f)); + mat3x4 m04(mat2x3(1.0f)); + mat3x4 m05(mat2x4(1.0f)); + mat3x4 m06(mat3x2(1.0f)); + mat3x4 m07(mat3x4(1.0f)); + mat3x4 m08(mat4x2(1.0f)); + mat3x4 m09(mat4x3(1.0f)); + } + + { + mat4x2 m01(mat2(1.0f)); + mat4x2 m02(mat3(1.0f)); + mat4x2 m03(mat4(1.0f)); + mat4x2 m04(mat2x3(1.0f)); + mat4x2 m05(mat2x4(1.0f)); + mat4x2 m06(mat3x2(1.0f)); + mat4x2 m07(mat3x4(1.0f)); + mat4x2 m08(mat4x2(1.0f)); + mat4x2 m09(mat4x3(1.0f)); + } + + { + mat4x3 m01(mat2(1.0f)); + mat4x3 m02(mat3(1.0f)); + mat4x3 m03(mat4(1.0f)); + mat4x3 m04(mat2x3(1.0f)); + mat4x3 m05(mat2x4(1.0f)); + mat4x3 m06(mat3x2(1.0f)); + mat4x3 m07(mat3x4(1.0f)); + mat4x3 m08(mat4x2(1.0f)); + mat4x3 m09(mat4x3(1.0f)); + } + + { + mat2 m01(mat2x3(1.0f)); + mat2 m02(mat2x4(1.0f)); + mat2 m03(mat3x2(1.0f)); + mat2 m04(mat3x4(1.0f)); + mat2 m05(mat4x2(1.0f)); + mat2 m06(mat4x3(1.0f)); + mat2 m07(mat4(1.0f)); + mat2 m08(mat3(1.0f)); + } + { + mat3 m01(mat2x3(1.0f)); + mat3 m02(mat2x4(1.0f)); + mat3 m03(mat3x2(1.0f)); + mat3 m04(mat3x4(1.0f)); + mat3 m05(mat4x2(1.0f)); + mat3 m06(mat4x3(1.0f)); + mat3 m07(mat4(1.0f)); + mat3 m08(mat2(1.0f)); + } + { + mat4 m01(mat2x3(1.0f)); + mat4 m02(mat2x4(1.0f)); + mat4 m03(mat3x2(1.0f)); + mat4 m04(mat3x4(1.0f)); + mat4 m05(mat4x2(1.0f)); + mat4 m06(mat4x3(1.0f)); + mat4 m07(mat2(1.0f)); + mat4 m08(mat3(1.0f)); + } + + return true; +} diff --git a/test/core/cast/mat.h b/test/core/cast/mat.h new file mode 100644 index 00000000..826bb9ad --- /dev/null +++ b/test/core/cast/mat.h @@ -0,0 +1,6 @@ +#ifndef GLM_TEST_CAST_MAT_H +#define GLM_TEST_CAST_MAT_H + +bool test_core_cast_mat(); + +#endif//GLM_TEST_CAST_MAT_H diff --git a/test/core/ctor/vec2.cpp b/test/core/ctor/vec2.cpp new file mode 100644 index 00000000..83da1169 --- /dev/null +++ b/test/core/ctor/vec2.cpp @@ -0,0 +1,11 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-14 +// Updated : 2008-03-14 +// Licence : This source is under MIT licence +// File : test/core/ctor/vec2.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../../precompiled.hpp" +#include diff --git a/test/core/ctor/vec2.h b/test/core/ctor/vec2.h new file mode 100644 index 00000000..77829ac5 --- /dev/null +++ b/test/core/ctor/vec2.h @@ -0,0 +1,6 @@ +#ifndef GLM_TEST_CORE_CTOR_VEC2_H +#define GLM_TEST_CORE_CTOR_VEC2_H + + + +#endif//GLM_TEST_CORE_CTOR_VEC2_H diff --git a/test/core/ctor/vec3.cpp b/test/core/ctor/vec3.cpp new file mode 100644 index 00000000..b3e5b28f --- /dev/null +++ b/test/core/ctor/vec3.cpp @@ -0,0 +1,12 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-14 +// Updated : 2008-03-14 +// Licence : This source is under MIT licence +// File : test/core/ctor/vec3.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../../precompiled.hpp" +#include + diff --git a/test/core/ctor/vec3.h b/test/core/ctor/vec3.h new file mode 100644 index 00000000..2403cb8a --- /dev/null +++ b/test/core/ctor/vec3.h @@ -0,0 +1,6 @@ +#ifndef GLM_TEST_CORE_CTOR_VEC3_H +#define GLM_TEST_CORE_CTOR_VEC3_H + + + +#endif//GLM_TEST_CORE_CTOR_VEC3_H diff --git a/test/core/ctor/vec4.cpp b/test/core/ctor/vec4.cpp new file mode 100644 index 00000000..57b2ecb5 --- /dev/null +++ b/test/core/ctor/vec4.cpp @@ -0,0 +1,14 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-14 +// Updated : 2008-03-14 +// Licence : This source is under MIT licence +// File : test/core/ctor/vec4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../../precompiled.hpp" +#include + + + diff --git a/test/core/ctor/vec4.h b/test/core/ctor/vec4.h new file mode 100644 index 00000000..748dfccf --- /dev/null +++ b/test/core/ctor/vec4.h @@ -0,0 +1,6 @@ +#ifndef GLM_TEST_CORE_CTOR_VEC4_H +#define GLM_TEST_CORE_CTOR_VEC4_H + + + +#endif//GLM_TEST_CORE_CTOR_VEC4_H diff --git a/test/core/func_common.cpp b/test/core/func_common.cpp new file mode 100644 index 00000000..d4efffd0 --- /dev/null +++ b/test/core/func_common.cpp @@ -0,0 +1,882 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_common.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +static const float epsilon = 0.00001f; + +bool test_abs_type1() +{ + float absolute1 = glm::abs(( 76.f)); + float absolute2 = glm::abs((-76.f)); + + if(absolute1 != (76.f) || + absolute2 != (76.f)) + return false; + return true; +} + +bool test_abs_type2() +{ + glm::vec2 absolute1 = glm::abs(glm::vec2( 76.f, 76.f)); + glm::vec2 absolute2 = glm::abs(glm::vec2(-76.f,-76.f)); + + if(absolute1.x != 76.f || absolute1.y != 76.f || + absolute2.x != 76.f || absolute2.y != 76.f) + return false; + return true; +} + +bool test_abs_type3() +{ + glm::vec3 absolute1 = glm::abs(glm::vec3( 76.f, 76.f, 76.f)); + glm::vec3 absolute2 = glm::abs(glm::vec3(-76.f,-76.f,-76.f)); + + if(absolute1.x != 76.f || absolute1.y != 76.f || absolute1.z != 76.f || + absolute2.x != 76.f || absolute2.y != 76.f || absolute2.z != 76.f) + return false; + return true; +} + +bool test_abs_type4() +{ + glm::vec4 absolute1 = glm::abs(glm::vec4( 76.f, 76.f, 76.f, 76.f)); + glm::vec4 absolute2 = glm::abs(glm::vec4(-76.f,-76.f,-76.f,-76.f)); + + if(absolute1.x != 76.f || absolute1.y != 76.f || absolute1.z != 76.f || absolute1.w != 76.f || + absolute2.x != 76.f || absolute2.y != 76.f || absolute2.z != 76.f || absolute2.w != 76.f) + return false; + return true; +} + +bool test_sign_type1() +{ + float vec_sign1 = sign( 76.f); + float vec_sign2 = sign( 0.f); + float vec_sign3 = sign(-76.f); + + if(vec_sign1 != 1.0f || + vec_sign2 != 0.0f || + vec_sign3 != -1.0f) + return false; + return true; +} + +bool test_sign_type2() +{ + vec2 vec_sign1 = sign(vec2( 76.f, 76.f)); + vec2 vec_sign2 = sign(vec2( 0.f, 0.f)); + vec2 vec_sign3 = sign(vec2(-76.f,-76.f)); + + if(vec_sign1.x != 1.0f || + vec_sign1.y != 1.0f) + return false; + if(vec_sign2.x != 0.0f || + vec_sign2.y != 0.0f) + return false; + if(vec_sign3.x != -1.0f || + vec_sign3.y != -1.0f) + return false; + return true; +} + +bool test_sign_type3() +{ + vec3 vec_sign1 = sign(vec3( 76.f, 76.f, 76.f)); + vec3 vec_sign2 = sign(vec3( 0.f, 0.f, 0.f)); + vec3 vec_sign3 = sign(vec3(-76.f,-76.f,-76.f)); + + if(vec_sign1.x != 1.0f || + vec_sign1.y != 1.0f || + vec_sign1.z != 1.0f) + return false; + if(vec_sign2.x != 0.0f || + vec_sign2.y != 0.0f || + vec_sign2.z != 0.0f) + return false; + if(vec_sign3.x != -1.0f || + vec_sign3.y != -1.0f || + vec_sign3.z != -1.0f) + return false; + return true; +} + +bool test_sign_type4() +{ + vec4 vec_sign1 = sign(vec4( 76.f, 76.f, 76.f, 76.f)); + vec4 vec_sign2 = sign(vec4( 0.f, 0.f, 0.f, 0.f)); + vec4 vec_sign3 = sign(vec4(-76.f,-76.f,-76.f,-76.f)); + + if(vec_sign1.x != 1.0f || + vec_sign1.y != 1.0f || + vec_sign1.z != 1.0f || + vec_sign1.w != 1.0f) + return false; + if(vec_sign2.x != 0.0f || + vec_sign2.y != 0.0f || + vec_sign2.z != 0.0f || + vec_sign2.w != 0.0f) + return false; + if(vec_sign3.x != -1.0f || + vec_sign3.y != -1.0f || + vec_sign3.z != -1.0f || + vec_sign3.w != -1.0f) + return false; + return true; +} + +bool test_floor_type1() +{ + float val_floor = glm::floor(float(0.5f)); + + if(val_floor != 0) + return false; + return true; +} + +bool test_floor_type2() +{ + glm::vec2 vec_floor = glm::floor(glm::vec2(0.5f, 0.5f)); + + if(vec_floor.x != 0 || + vec_floor.y != 0) + return false; + return true; +} + +bool test_floor_type3() +{ + glm::vec3 vec_floor = glm::floor(glm::vec3(0.5f, 0.5f, 0.5f)); + + if(vec_floor.x != 0 || + vec_floor.y != 0 || + vec_floor.z != 0) + return false; + return true; +} + +bool test_floor_type4() +{ + glm::vec4 vec_floor = glm::floor(glm::vec4(0.5f, 0.5f, 0.5f, 0.5f)); + + if(vec_floor.x != 0 || + vec_floor.y != 0 || + vec_floor.z != 0 || + vec_floor.w != 0) + return false; + return true; +} + +bool test_trunc_type1() +{ + return true; +} + +bool test_trunc_type2() +{ + return true; +} + +bool test_trunc_type3() +{ + return true; +} + +bool test_trunc_type4() +{ + return true; +} + +bool test_round_type1() +{ + return true; +} + +bool test_round_type2() +{ + return true; +} + +bool test_round_type3() +{ + return true; +} + +bool test_round_type4() +{ + return true; +} + +bool test_roundEven_type1() +{ + float a = glm::roundEven(3.5f); + float b = glm::roundEven(4.5f); + float c = glm::roundEven(5.5f); + + float d = glm::roundEven(3.4f); + float e = glm::roundEven(4.4f); + float f = glm::roundEven(5.4f); + + float g = glm::roundEven(3.6f); + float h = glm::roundEven(4.6f); + float i = glm::roundEven(5.6f); + + float end = 0.0f; + + return true; +} + +bool test_roundEven_type2() +{ + return true; +} + +bool test_roundEven_type3() +{ + return true; +} + +bool test_roundEven_type4() +{ + return true; +} + +bool test_ceil_1() +{ + float val_ceil = glm::ceil(float(0.5f)); + + if(val_ceil != 1) + return false; + return true; +} + +bool test_ceil_2() +{ + glm::vec2 vec_ceil = glm::ceil(glm::vec2(0.5f, 0.5f)); + + if(vec_ceil.x != 1 || + vec_ceil.y != 1) + return false; + return true; +} + +bool test_ceil_3() +{ + glm::vec3 vec_ceil = glm::ceil(glm::vec3(0.5f, 0.5f, 0.5f)); + + if(vec_ceil.x != 1 || + vec_ceil.y != 1 || + vec_ceil.z != 1) + return false; + return true; +} + +bool test_ceil_4() +{ + glm::vec4 vec_ceil = glm::ceil(glm::vec4(0.5f, 0.5f, 0.5f, 0.5f)); + + if(vec_ceil.x != 1 || + vec_ceil.y != 1 || + vec_ceil.z != 1 || + vec_ceil.w != 1) + return false; + return true; +} + +bool test_fract_1() +{ + float val_fract = fract(float(0.5f)); + + if(val_fract != 0.5f) + return false; + return true; +} + +bool test_fract_2() +{ + vec2 vec_fract = fract(vec2(0.5f, 0.5f)); + + if(vec_fract.x != 0.5f || + vec_fract.y != 0.5f) + return false; + return true; +} + +bool test_fract_3() +{ + vec3 vec_fract = fract(vec3(0.5f, 0.5f, 0.5f)); + + if(vec_fract.x != 0.5f || + vec_fract.y != 0.5f || + vec_fract.z != 0.5f) + return false; + return true; +} + +bool test_fract_4() +{ + vec4 vec_fract = fract(vec4(0.5f, 0.5f, 0.5f, 0.5f)); + + if(vec_fract.x != 0.5f || + vec_fract.y != 0.5f || + vec_fract.z != 0.5f || + vec_fract.w != 0.5f) + return false; + return true; +} + +bool test_mod_1() +{ + float val_mod = glm::mod(float(4.0f), float(2.0f)); + + if(val_mod != 0.0f) + return false; + return true; +} + +bool test_mod_2() +{ + glm::vec2 vec_mod1 = glm::mod(glm::vec2(4.0f, 4.0f), glm::vec2(2.0f, 2.0f)); + glm::vec2 vec_mod2 = glm::mod(glm::vec2(4.0f, 4.0f), float(2.0f)); + + if(vec_mod1.x != 0.0f || + vec_mod1.y != 0.0f) + return false; + if(vec_mod2.x != 0.0f || + vec_mod2.y != 0.0f) + return false; + return true; +} + +bool test_mod_3() +{ + glm::vec3 vec_mod1 = glm::mod(glm::vec3(4.0f, 4.0f, 4.0f), glm::vec3(2.0f, 2.0f, 2.0f)); + glm::vec3 vec_mod2 = glm::mod(glm::vec3(4.0f, 4.0f, 4.0f), float(2.0f)); + + if(vec_mod1.x != 0.0f || + vec_mod1.y != 0.0f || + vec_mod1.z != 0.0f) + return false; + if(vec_mod2.x != 0.0f || + vec_mod2.y != 0.0f || + vec_mod2.z != 0.0f) + return false; + return true; +} + +bool test_mod_4() +{ + glm::vec4 vec_mod1 = glm::mod(glm::vec4(4.0f, 4.0f, 4.0f, 4.0f), glm::vec4(2.0f, 2.0f, 2.0f, 2.0f)); + glm::vec4 vec_mod2 = glm::mod(glm::vec4(4.0f, 4.0f, 4.0f, 4.0f), float(2.0f)); + + if(vec_mod1.x != 0.0f || + vec_mod1.y != 0.0f || + vec_mod1.z != 0.0f || + vec_mod1.w != 0.0f) + return false; + if(vec_mod2.x != 0.0f || + vec_mod2.y != 0.0f || + vec_mod2.z != 0.0f || + vec_mod2.w != 0.0f) + return false; + return true; +} + +bool test_modf() +{ + return true; +} + +bool test_min_1() +{ + float val_min = glm::min(float(0.0f), float(1.0f)); + + if(val_min > 0.0f) + return false; + return true; +} + +bool test_min_2() +{ + glm::vec2 val_min1 = glm::min(glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 1.0f)); + glm::vec2 val_min2 = glm::min(glm::vec2(0.0f, 0.0f), float(1.0f)); + + if(val_min1.x > 0.0f || + val_min1.y > 0.0f) + return false; + if(val_min2.x > 0.0f || + val_min2.y > 0.0f) + return false; + return true; +} + +bool test_min_3() +{ + glm::vec3 val_min1 = glm::min(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f)); + glm::vec3 val_min2 = glm::min(glm::vec3(0.0f, 0.0f, 0.0f), float(1.0f)); + + if(val_min1.x > 0.0f || + val_min1.y > 0.0f || + val_min1.z > 0.0f) + return false; + if(val_min2.x > 0.0f || + val_min2.y > 0.0f || + val_min2.z > 0.0f) + return false; + return true; +} + +bool test_min_4() +{ + glm::vec4 val_min1 = glm::min(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); + glm::vec4 val_min2 = glm::min(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), float(1.0f)); + + if(val_min1.x > 0.0f || + val_min1.y > 0.0f || + val_min1.z > 0.0f || + val_min1.w > 0.0f) + return false; + if(val_min2.x > 0.0f || + val_min2.y > 0.0f || + val_min2.z > 0.0f || + val_min2.w > 0.0f) + return false; + return true; +} + +bool test_max_1() +{ + float val_max = glm::max(float(0.0f), float(1.0f)); + + if(val_max < 1.0f) + return false; + return true; +} + +bool test_max_2() +{ + glm::vec2 val_max1 = glm::max(glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 1.0f)); + glm::vec2 val_max2 = glm::max(glm::vec2(0.0f, 0.0f), float(1.0f)); + + if(val_max1.x < 1.0f || + val_max1.y < 1.0f) + return false; + if(val_max2.x < 1.0f || + val_max2.y < 1.0f) + return false; + return true; +} + +bool test_max_3() +{ + glm::vec3 val_max1 = glm::max(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f)); + glm::vec3 val_max2 = glm::max(glm::vec3(0.0f, 0.0f, 0.0f), float(1.0f)); + + if(val_max1.x < 1.0f || + val_max1.y < 1.0f || + val_max1.z < 1.0f) + return false; + if(val_max2.x < 1.0f || + val_max2.y < 1.0f || + val_max2.z < 1.0f) + return false; + return true; +} + +bool test_max_4() +{ + glm::vec4 val_max1 = glm::max(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); + glm::vec4 val_max2 = glm::max(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f), float(1.0f)); + + if(val_max1.x < 1.0f || + val_max1.y < 1.0f || + val_max1.z < 1.0f || + val_max1.w < 1.0f) + return false; + if(val_max2.x < 1.0f || + val_max2.y < 1.0f || + val_max2.z < 1.0f || + val_max2.w < 1.0f) + return false; + return true; +} + +bool test_clamp_1() +{ + float clamp1 = glm::clamp(float( 4.0f), float(0.0f), float(1.0f)); + float clamp2 = glm::clamp(float(-4.0f), float(0.0f), float(1.0f)); + + if(clamp1 != 1.0f || + clamp2 != 0.0f) + return false; + return true; +} + +bool test_clamp_2() +{ + glm::vec2 clamp1 = glm::clamp( + glm::vec2( 4.0f, 4.0f), + glm::vec2( 0.0f, 0.0f), + glm::vec2( 1.0f, 1.0f)); + glm::vec2 clamp2 = glm::clamp( + glm::vec2(-4.0f,-4.0f), + glm::vec2( 0.0f, 0.0f), + glm::vec2( 1.0f, 1.0f)); + glm::vec2 clamp3 = glm::clamp( + glm::vec2( 4.0f, 4.0f), + float(0.0f), float(1.0f)); + glm::vec2 clamp4 = glm::clamp( + glm::vec2(-4.0f,-4.0f), + float(0.0f), float(1.0f)); + + if(clamp1.x != 1.0f || + clamp1.y != 1.0f) + return false; + if(clamp2.x != 0.0f || + clamp2.y != 0.0f) + return false; + if(clamp3.x != 1.0f || + clamp3.y != 1.0f) + return false; + if(clamp4.x != 0.0f || + clamp4.y != 0.0f) + return false; + return true; +} + +bool test_clamp_3() +{ + glm::vec3 clamp1 = glm::clamp( + glm::vec3( 4.0f, 4.0f, 4.0f), + glm::vec3( 0.0f, 0.0f, 0.0f), + glm::vec3( 1.0f, 1.0f, 1.0f)); + glm::vec3 clamp2 = glm::clamp( + glm::vec3(-4.0f,-4.0f,-4.0f), + glm::vec3( 0.0f, 0.0f, 0.0f), + glm::vec3( 1.0f, 1.0f, 1.0f)); + glm::vec3 clamp3 = glm::clamp( + glm::vec3( 4.0f, 4.0f, 4.0f), + float(0.0f), float(1.0f)); + glm::vec3 clamp4 = glm::clamp( + glm::vec3(-4.0f,-4.0f,-4.0f), + float(0.0f), float(1.0f)); + + if(clamp1.x != 1.0f || + clamp1.y != 1.0f || + clamp1.z != 1.0f) + return false; + if(clamp2.x != 0.0f || + clamp2.y != 0.0f || + clamp2.z != 0.0f) + return false; + if(clamp3.x != 1.0f || + clamp3.y != 1.0f || + clamp3.z != 1.0f) + return false; + if(clamp4.x != 0.0f || + clamp4.y != 0.0f || + clamp4.z != 0.0f) + return false; + return true; +} + +bool test_clamp_4() +{ + glm::vec4 clamp1 = glm::clamp( + glm::vec4( 4.0f, 4.0f, 4.0f, 4.0f), + glm::vec4( 0.0f, 0.0f, 0.0f, 0.0f), + glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f)); + glm::vec4 clamp2 = glm::clamp( + glm::vec4(-4.0f,-4.0f,-4.0f,-4.0f), + glm::vec4( 0.0f, 0.0f, 0.0f, 0.0f), + glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f)); + glm::vec4 clamp3 = glm::clamp( + glm::vec4( 4.0f, 4.0f, 4.0f, 4.0f), + float(0.0f), float(1.0f)); + glm::vec4 clamp4 = glm::clamp( + glm::vec4(-4.0f,-4.0f,-4.0f,-4.0f), + float(0.0f), float(1.0f)); + + if(clamp1.x != 1.0f || + clamp1.y != 1.0f || + clamp1.z != 1.0f || + clamp1.w != 1.0f) + return false; + if(clamp2.x != 0.0f || + clamp2.y != 0.0f || + clamp2.z != 0.0f || + clamp2.w != 0.0f) + return false; + if(clamp3.x != 1.0f || + clamp3.y != 1.0f || + clamp3.z != 1.0f || + clamp3.w != 1.0f) + return false; + if(clamp4.x != 0.0f || + clamp4.y != 0.0f || + clamp4.z != 0.0f || + clamp4.w != 0.0f) + return false; + return true; +} + +bool test_mix_1() +{ + float val_mix = glm::mix(float(1.0f), float(1.0f), float(1.0f)); + + if(val_mix != 1.0f) + return false; + return true; +} + +bool test_mix_2() +{ + glm::vec2 val_mix1 = glm::mix(glm::vec2(1.0f, 1.0f), glm::vec2(1.0f, 1.0f), glm::vec2(1.0f, 1.0f)); + glm::vec2 val_mix2 = glm::mix(glm::vec2(1.0f, 1.0f), glm::vec2(1.0f, 1.0f), float(1.0f)); + + if(val_mix1.x != 1.0f || val_mix1.y != 1.0f || + val_mix2.x != 1.0f || val_mix2.y != 1.0f) + return false; + return true; +} + +bool test_mix_3() +{ + glm::vec3 val_mix1 = glm::mix(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f)); + glm::vec3 val_mix2 = glm::mix(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), float(1.0f)); + + if(val_mix1.x != 1.0f || val_mix1.y != 1.0f || val_mix1.z != 1.0f || + val_mix2.x != 1.0f || val_mix2.y != 1.0f || val_mix2.z != 1.0f) + return false; + return true; +} + +bool test_mix_4() +{ + glm::vec4 val_mix1 = glm::mix(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); + glm::vec4 val_mix2 = glm::mix(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), float(1.0f)); + + if(val_mix1.x != 1.0f || val_mix1.y != 1.0f || val_mix1.z != 1.0f || val_mix1.w != 1.0f || + val_mix2.x != 1.0f || val_mix2.y != 1.0f || val_mix2.z != 1.0f || val_mix2.w != 1.0f) + return false; + return true; +} + +bool test_step_1() +{ + float vec_step1 = step(1.f, 76.f); + + if(vec_step1 != 1.0f) + return false; + return true; +} + +bool test_step_2() +{ + vec2 vec_step1 = step(1.f, vec2(76.f, 1.f)); + vec2 vec_step2 = step(vec2(1.f, 1.f), vec2(76.f, 1.f)); + + if(vec_step1.x != 1.0f || vec_step1.y != 0.0f || + vec_step2.x != 1.0f || vec_step2.y != 0.0f) + return false; + return true; +} + +bool test_step_3() +{ + vec3 vec_step1 = step(1.f, vec3(76.f, 1.f, 0.f)); + vec3 vec_step2 = step(vec3(1.f, 1.f, 1.f), vec3(76.f, 1.f, 0.f)); + + if(vec_step1.x != 1.0f || vec_step1.y != 0.0f || vec_step1.z != 0.0f || + vec_step2.x != 1.0f || vec_step2.y != 0.0f || vec_step2.z != 0.0f) + return false; + return true; +} + +bool test_step_4() +{ + vec4 vec_step1 = step(1.f, vec4(76.f, 1.f, 0.f, 0.f)); + vec4 vec_step2 = step(vec4(1.f, 1.f, 1.f, 1.f), vec4(76.f, 1.f, 0.f, 0.f)); + + if(vec_step1.x != 1.0f || vec_step1.y != 0.0f || vec_step1.z != 0.0f || vec_step1.w != 0.0f || + vec_step2.x != 1.0f || vec_step2.y != 0.0f || vec_step2.z != 0.0f || vec_step2.w != 0.0f) + return false; + return true; +} + +bool test_smoothstep_1() +{ + float vec_smoothstep1 = smoothstep(0.f, 100.f, 50.f); + + bool Result = (vec_smoothstep1 < 0.5f - epsilon || vec_smoothstep1 > 0.5f + epsilon); + assert(!Result); + + float A = smoothstep(0.2f, 0.8f, 0.5f); + float B = smoothstep(0.2f, 0.8f, 0.7f); + float C = smoothstep(0.2f, 0.8f, 0.3f); + float D = smoothstep(0.2f, 0.8f, 1.2f); + float E = smoothstep(0.2f, 0.8f,-0.2f); + + if(Result) + return false; + return true; +} + +bool test_smoothstep_2() +{ + vec2 vec_smoothstep1 = smoothstep(0.f, 100.f, vec2(50.f, 100.f)); + vec2 vec_smoothstep2 = smoothstep(vec2(0.f, 0.f), vec2(100.f, 100.f), vec2(50.f, 100.f)); + + if(vec_smoothstep1.x < 0.50f - epsilon || vec_smoothstep1.x > 0.50f + epsilon || + vec_smoothstep1.y < 1.00f - epsilon || vec_smoothstep1.y > 1.00f + epsilon) + return false; + if(vec_smoothstep2.x < 0.50f - epsilon || vec_smoothstep2.x > 0.50f + epsilon || + vec_smoothstep2.y < 1.00f - epsilon || vec_smoothstep2.y > 1.00f + epsilon) + return false; + return true; +} + +bool test_smoothstep_3() +{ + vec3 vec_smoothstep1 = smoothstep(0.f, 100.f, vec3(50.f, 100.f, 0.f)); + vec3 vec_smoothstep2 = smoothstep(vec3(0.f, 0.f, 0.f), vec3(100.f, 100.f, 100.f), vec3(50.f, 100.f, 0.f)); + + if(vec_smoothstep1.x < 0.50f - epsilon || vec_smoothstep1.x > 0.50f + epsilon || + vec_smoothstep1.y < 1.00f - epsilon || vec_smoothstep1.y > 1.00f + epsilon || + vec_smoothstep1.z < 0.00f - epsilon || vec_smoothstep1.z > 0.00f + epsilon) + return false; + if(vec_smoothstep2.x < 0.50f - epsilon || vec_smoothstep2.x > 0.50f + epsilon || + vec_smoothstep2.y < 1.00f - epsilon || vec_smoothstep2.y > 1.00f + epsilon || + vec_smoothstep2.z < 0.00f - epsilon || vec_smoothstep2.z > 0.00f + epsilon) + return false; + return true; +} + +bool test_smoothstep_4() +{ + vec4 vec_smoothstep1 = smoothstep(0.f, 100.f, vec4(50.f, 100.f, 0.f, 0.f)); + vec4 vec_smoothstep2 = smoothstep(vec4(0.f, 0.f, 0.f, 0.f), vec4(100.f, 100.f, 100.f, 100.f), vec4(50.f, 100.f, 0.f, 0.f)); + + if(vec_smoothstep1.x < 0.50f - epsilon || vec_smoothstep1.x > 0.50f + epsilon || + vec_smoothstep1.y < 1.00f - epsilon || vec_smoothstep1.y > 1.00f + epsilon || + vec_smoothstep1.z < 0.00f - epsilon || vec_smoothstep1.z > 0.00f + epsilon || + vec_smoothstep1.w < 0.00f - epsilon || vec_smoothstep1.w > 0.00f + epsilon) + return false; + if(vec_smoothstep2.x < 0.50f - epsilon || vec_smoothstep2.x > 0.50f + epsilon || + vec_smoothstep2.y < 1.00f - epsilon || vec_smoothstep2.y > 1.00f + epsilon || + vec_smoothstep2.z < 0.00f - epsilon || vec_smoothstep2.z > 0.00f + epsilon || + vec_smoothstep2.w < 0.00f - epsilon || vec_smoothstep2.w > 0.00f + epsilon) + return false; + return true; +} + +bool test_isnan() +{ + return true; +} + +bool test_isinf() +{ + return true; +} + +void main_core_func_common() +{ + assert(test_abs_type1()); + assert(test_abs_type2()); + assert(test_abs_type3()); + assert(test_abs_type4()); + + assert(test_sign_type1()); + assert(test_sign_type2()); + assert(test_sign_type3()); + assert(test_sign_type4()); + + assert(test_floor_type1()); + assert(test_floor_type2()); + assert(test_floor_type3()); + assert(test_floor_type4()); + + assert(test_trunc_type1()); + assert(test_trunc_type2()); + assert(test_trunc_type3()); + assert(test_trunc_type4()); + + assert(test_round_type1()); + assert(test_round_type2()); + assert(test_round_type3()); + assert(test_round_type4()); + + assert(test_roundEven_type1()); + assert(test_roundEven_type2()); + assert(test_roundEven_type3()); + assert(test_roundEven_type4()); + + assert(test_ceil_1()); + assert(test_ceil_2()); + assert(test_ceil_3()); + assert(test_ceil_4()); + + assert(test_fract_1()); + assert(test_fract_2()); + assert(test_fract_3()); + assert(test_fract_4()); + + assert(test_mod_1()); + assert(test_mod_2()); + assert(test_mod_3()); + assert(test_mod_4()); + + assert(test_mod_1()); + assert(test_mod_2()); + assert(test_mod_3()); + assert(test_mod_4()); + + assert(test_modf()); + + assert(test_min_1()); + assert(test_min_2()); + assert(test_min_3()); + assert(test_min_4()); + + assert(test_max_1()); + assert(test_max_2()); + assert(test_max_3()); + assert(test_max_4()); + + assert(test_clamp_1()); + assert(test_clamp_2()); + assert(test_clamp_3()); + assert(test_clamp_4()); + + assert(test_mix_1()); + assert(test_mix_2()); + assert(test_mix_3()); + assert(test_mix_4()); + + assert(test_step_1()); + assert(test_step_2()); + assert(test_step_3()); + assert(test_step_4()); + + assert(test_smoothstep_1()); + assert(test_smoothstep_2()); + assert(test_smoothstep_3()); + assert(test_smoothstep_4()); + + assert(test_isnan()); + assert(test_isinf()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/func_exponential.cpp b/test/core/func_exponential.cpp new file mode 100644 index 00000000..e834ef87 --- /dev/null +++ b/test/core/func_exponential.cpp @@ -0,0 +1,351 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_exponential.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +static const float epsilon = 0.00001f; + +bool test_pow_1() +{ + float power = glm::pow(2.f, 2.f); + + if(power <= 4.f + epsilon && power >= 4.f - epsilon) + return true; + return false; +} + +bool test_pow_2() +{ + glm::vec2 power = glm::pow(glm::vec2(2.f, 2.f), glm::vec2(2.f, 2.f)); + + if(power.x <= 4.f + epsilon && power.x >= 4.f - epsilon && + power.y <= 4.f + epsilon && power.y >= 4.f - epsilon) + return true; + return false; +} + +bool test_pow_3() +{ + glm::vec3 power = glm::pow(glm::vec3(2.f, 2.f, 2.f), glm::vec3(2.f, 2.f, 2.f)); + + if(power.x <= 4.f + epsilon && power.x >= 4.f - epsilon && + power.y <= 4.f + epsilon && power.y >= 4.f - epsilon && + power.z <= 4.f + epsilon && power.z >= 4.f - epsilon) + return true; + return false; +} + +bool test_pow_4() +{ + glm::vec4 power = glm::pow(glm::vec4(2.f, 2.f, 2.f, 2.f), glm::vec4(2.f, 2.f, 2.f, 2.f)); + + if(power.x <= 4.f + epsilon && power.x >= 4.f - epsilon && + power.y <= 4.f + epsilon && power.y >= 4.f - epsilon && + power.z <= 4.f + epsilon && power.z >= 4.f - epsilon && + power.w <= 4.f + epsilon && power.w >= 4.f - epsilon) + return true; + return false; +} + +bool test_exp_1() +{ + float result = glm::exp(0.f); + + if(result > 1.f + epsilon || result < 1.f - epsilon) + return false; + return true; +} + +bool test_exp_2() +{ + glm::vec2 result = glm::exp(glm::vec2(0.f, 0.f)); + + if(result.x > 1.f + epsilon || result.x < 1.f - epsilon || + result.y > 1.f + epsilon || result.y < 1.f - epsilon) + return false; + return true; +} + +bool test_exp_3() +{ + glm::vec3 result = glm::exp(glm::vec3(0.f, 0.f, 0.f)); + + if(result.x > 1.f + epsilon || result.x < 1.f - epsilon || + result.y > 1.f + epsilon || result.y < 1.f - epsilon || + result.z > 1.f + epsilon || result.z < 1.f - epsilon) + return false; + return true; +} + +bool test_exp_4() +{ + glm::vec4 result = glm::exp(glm::vec4(0.f, 0.f, 0.f, 0.f)); + + if(result.x > 1.f + epsilon || result.x < 1.f - epsilon || + result.y > 1.f + epsilon || result.y < 1.f - epsilon || + result.z > 1.f + epsilon || result.z < 1.f - epsilon || + result.w > 1.f + epsilon || result.w < 1.f - epsilon) + return false; + return true; +} + +bool test_log_1() +{ + float result = glm::log(1.f); + + if(result > epsilon || result < -epsilon) + return false; + return true; +} + +bool test_log_2() +{ + glm::vec2 result = glm::log(glm::vec2(1.f, 1.f)); + + if(result.x > epsilon || result.x < -epsilon || + result.y > epsilon || result.y < -epsilon) + return false; + return true; +} + +bool test_log_3() +{ + glm::vec3 result = glm::log(glm::vec3(1.f, 1.f, 1.f)); + + if(result.x > epsilon || result.x < -epsilon || + result.y > epsilon || result.y < -epsilon || + result.z > epsilon || result.z < -epsilon) + return false; + return true; +} + +bool test_log_4() +{ + glm::vec4 result = glm::log(glm::vec4(1.f, 1.f, 1.f, 1.f)); + + if(result.x > epsilon || result.x < -epsilon || + result.y > epsilon || result.y < -epsilon || + result.z > epsilon || result.z < -epsilon || + result.w > epsilon || result.w < -epsilon) + return false; + return true; +} + +bool test_exp2_1() +{ + float result = glm::exp2(2.f); + + if(result > 4.f + epsilon || result < 4.f - epsilon) + return false; + return true; +} + +bool test_exp2_2() +{ + glm::vec2 result = glm::exp2(glm::vec2(2.f, 2.f)); + + if(result.x > 4.f + epsilon || result.x < 4.f - epsilon || + result.y > 4.f + epsilon || result.y < 4.f - epsilon) + return false; + return true; +} + +bool test_exp2_3() +{ + glm::vec3 result = glm::exp2(glm::vec3(2.f, 2.f, 2.f)); + + if(result.x > 4.f + epsilon || result.x < 4.f - epsilon || + result.y > 4.f + epsilon || result.y < 4.f - epsilon || + result.z > 4.f + epsilon || result.z < 4.f - epsilon) + return false; + return true; +} + +bool test_exp2_4() +{ + glm::vec4 result = glm::exp2(glm::vec4(2.f, 2.f, 2.f, 2.f)); + + if(result.x > 4.f + epsilon || result.x < 4.f - epsilon || + result.y > 4.f + epsilon || result.y < 4.f - epsilon || + result.z > 4.f + epsilon || result.z < 4.f - epsilon || + result.w > 4.f + epsilon || result.w < 4.f - epsilon) + return false; + return true; +} + +bool test_log2_1() +{ + float result = glm::log2(2.f); + + if(result > 1.f + epsilon || result < 1.f - epsilon) + return false; + return true; +} + +bool test_log2_2() +{ + glm::vec2 result = glm::log2(glm::vec2(2.f, 4.f)); + + if(result.x > 1.f + epsilon || result.x < 1.f - epsilon || + result.y > 2.f + epsilon || result.y < 2.f - epsilon) + return false; + return true; +} + +bool test_log2_3() +{ + glm::vec3 result = glm::log2(glm::vec3(2.f, 4.f, 8.f)); + + if(result.x > 1.f + epsilon || result.x < 1.f - epsilon || + result.y > 2.f + epsilon || result.y < 2.f - epsilon || + result.z > 3.f + epsilon || result.z < 3.f - epsilon) + return false; + return true; +} + +bool test_log2_4() +{ + glm::vec4 result = glm::log2(glm::vec4(2.f, 4.f, 8.f, 16.f)); + + if(result.x > 1.f + epsilon || result.x < 1.f - epsilon || + result.y > 2.f + epsilon || result.y < 2.f - epsilon || + result.z > 3.f + epsilon || result.z < 3.f - epsilon || + result.w > 4.f + epsilon || result.w < 4.f - epsilon) + return false; + return true; +} + +bool test_sqrt_1() +{ + float result = glm::sqrt(4.f); + + if(result < 2.f - epsilon && result > 2.f + epsilon) + return false; + return true; +} + +bool test_sqrt_2() +{ + glm::vec2 result = glm::sqrt(glm::vec2(4.f, 4.f)); + + if(result.x < 2.f - epsilon && result.x > 2.f + epsilon && + result.y < 2.f - epsilon && result.y > 2.f + epsilon) + return false; + return true; +} + +bool test_sqrt_3() +{ + glm::vec3 result = glm::sqrt(glm::vec3(4.f, 4.f, 4.f)); + + if(result.x < 2.f - epsilon && result.x > 2.f + epsilon && + result.y < 2.f - epsilon && result.y > 2.f + epsilon && + result.z < 2.f - epsilon && result.z > 2.f + epsilon) + return false; + return true; +} + +bool test_sqrt_4() +{ + glm::vec4 result = glm::sqrt(glm::vec4(4.f, 4.f, 4.f, 4.f)); + + if(result.x < 2.f - epsilon && result.x > 2.f + epsilon && + result.y < 2.f - epsilon && result.y > 2.f + epsilon && + result.z < 2.f - epsilon && result.z > 2.f + epsilon && + result.w < 2.f - epsilon && result.w > 2.f + epsilon) + return false; + return true; +} + +bool test_inversesqrt_1() +{ + float result = glm::inversesqrt(4.f); + + if(result < 0.5f - epsilon && result > 0.5f + epsilon) + return false; + return true; +} + +bool test_inversesqrt_2() +{ + glm::vec2 result = glm::inversesqrt(glm::vec2(4.f, 4.f)); + + if(result.x < 0.5f - epsilon && result.x > 0.5f + epsilon && + result.y < 0.5f - epsilon && result.y > 0.5f + epsilon) + return false; + return true; +} + +bool test_inversesqrt_3() +{ + glm::vec3 result = glm::inversesqrt(glm::vec3(4.f, 4.f, 4.f)); + + if(result.x < 0.5f - epsilon && result.x > 0.5f + epsilon && + result.y < 0.5f - epsilon && result.y > 0.5f + epsilon && + result.z < 0.5f - epsilon && result.z > 0.5f + epsilon) + return false; + return true; +} + +bool test_inversesqrt_4() +{ + glm::vec4 result = glm::inversesqrt(glm::vec4(4.f, 4.f, 4.f, 4.f)); + + if(result.x < 0.5f - epsilon && result.x > 0.5f + epsilon && + result.y < 0.5f - epsilon && result.y > 0.5f + epsilon && + result.z < 0.5f - epsilon && result.z > 0.5f + epsilon && + result.w < 0.5f - epsilon && result.w > 0.5f + epsilon) + return false; + return true; +} + +void main_core_func_exponential() +{ + assert(test_pow_1()); + assert(test_pow_2()); + assert(test_pow_3()); + assert(test_pow_4()); + + assert(test_exp_1()); + assert(test_exp_2()); + assert(test_exp_3()); + assert(test_exp_4()); + + assert(test_log_1()); + assert(test_log_2()); + assert(test_log_3()); + assert(test_log_4()); + + assert(test_exp2_1()); + assert(test_exp2_2()); + assert(test_exp2_3()); + assert(test_exp2_4()); + + assert(test_log2_1()); + assert(test_log2_2()); + assert(test_log2_3()); + assert(test_log2_4()); + + assert(test_sqrt_1()); + assert(test_sqrt_2()); + assert(test_sqrt_3()); + assert(test_sqrt_4()); + + assert(test_inversesqrt_1()); + assert(test_inversesqrt_2()); + assert(test_inversesqrt_3()); + assert(test_inversesqrt_4()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/func_geometric.cpp b/test/core/func_geometric.cpp new file mode 100644 index 00000000..271751c7 --- /dev/null +++ b/test/core/func_geometric.cpp @@ -0,0 +1,370 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_geometric.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +bool test_length_1() +{ + float f1 = 0.0f; + float len1 = length(f1); + float f2 = 1.0f; + float len2 = length(f2); + + if (len1 == 0.0f && len2 == 1.0f) + return true; + return false; +} + +bool test_length_2() +{ + vec2 v1 = vec2(0, 0); + float len1 = length(v1); + vec2 v2 = vec2 (1, 1); + float len2 = length(v2); + + if (len1 == 0.0f && len2 > 1.41f && len2 < 1.42f) + return true; + return false; +} + +bool test_length_3() +{ + vec3 v1 = vec3(0, 0, 0); + float len1 = length(v1); + vec3 v2 = vec3 (1, 1, 1); + float len2 = length(v2); + + if (len1 == 0.0f && len2 > 1.73f && len2 < 1.74f) + return true; + return false; +} + +bool test_length_4() +{ + vec4 v1 = vec4(0, 0, 0, 0); + float len1 = length(v1); + vec4 v2 = vec4(1, 1, 1, 1); + float len2 = length(v2); + + if (len1 == 0.0f && len2 == 2.f) + return true; + return false; +} + +bool test_distance_1() +{ + float p0 = 2.f; + float p1 = -2.f; + float dist = distance(p0, p1); + + if (dist == 4.0f) + return true; + return false; +} + +bool test_distance_2() +{ + vec2 p0 = vec2(0.f, 2.f); + vec2 p1 = vec2(0.f,-2.f); + float dist = distance(p0, p1); + + if (dist == 4.0f) + return true; + return false; +} + +bool test_distance_3() +{ + vec3 p0 = vec3(0.f, 0.f, 2.f); + vec3 p1 = vec3(0.f, 0.f,-2.f); + float dist = distance(p0, p1); + + if (dist == 4.0f) + return true; + return false; +} + +bool test_distance_4() +{ + vec4 p0 = vec4(0.f, 0.f, 2.f, 0.f); + vec4 p1 = vec4(0.f, 0.f,-2.f, 0.f); + float dist = distance(p0, p1); + + if (dist == 4.0f) + return true; + return false; +} + +bool test_dot_1() +{ + float v1 = 1.0f; + float v2 = 0.0f; + float dot1 = dot (v1, v1); + float dot2 = dot (v1, v2); + + if (dot1 == 1.0f && dot2 == 0.0f) + return true; + return false; +} + +bool test_dot_2() +{ + vec2 v1 = vec2 (1, 0); + vec2 v2 = vec2 (0, 1); + float dot1 = dot (v1, v1); + float dot2 = dot (v1, v2); + + if (dot1 == 1.0f && dot2 == 0.0f) + return true; + return false; +} + +bool test_dot_3() +{ + vec3 v1 = vec3 (1, 0, 0); + vec3 v2 = vec3 (0, 1, 0); + float dot1 = dot (v1, v1); + float dot2 = dot (v1, v2); + + if (dot1 == 1.0f && dot2 == 0.0f) + return true; + return false; +} + +bool test_dot_4() +{ + vec4 v1 = vec4 (1, 0, 0, 0); + vec4 v2 = vec4 (0, 1, 0, 0); + float dot1 = dot (v1, v1); + float dot2 = dot (v1, v2); + + if (dot1 == 1.0f && dot2 == 0.0f) + return true; + return false; +} + +bool test_cross_vec3 () +{ + vec3 v1 = vec3(1.0f, 0.0f, 0.0f); + vec3 v2 = vec3(0.0f, 1.0f, 0.0f); + vec3 v3 = cross(v1, v2); + vec3 v4 = vec3(0.0f, 0.0f, 1.0f); + + if (v3.x == v4.x && v3.y == v4.y && v3.z == v4.z) + return true; + return false; +} + +bool test_normalize_1() +{ + float f1 = 0.0f; + f1 = normalize(f1); + float f2 = 1.0f; + f2 = normalize(f2); + + if (f1 == 1.0f && f2 == 1.0f) + return true; + return false; +} + +bool test_normalize_2() +{ + vec2 v1 = vec2(0, 0); + v1 = normalize(v1); + vec2 v2 = vec2 (1, 1); + v2 = normalize(v2); + + if (length (v2) > 0.99f && length (v2) < 1.01f) + return true; + return false; +} + +bool test_normalize_3() +{ + vec3 v1 = vec3(0, 0, 0); + v1 = normalize(v1); + vec3 v2 = vec3(1, 1, 1); + v2 = normalize(v2); + + if (length (v2) > 0.99f && length (v2) < 1.01f) + return true; + return false; +} + +bool test_normalize_4() +{ + vec4 v1 = vec4(0, 0, 0, 0); + v1 = normalize(v1); + vec4 v2 = vec4(1, 1, 1, 1); + v2 = normalize(v2); + + if (length (v2) > 0.99f && length (v2) < 1.01f) + return true; + return false; +} + +bool test_faceforward_1() +{ + float N = 1.0f; + float I = 1.0f; + float Nref = 1.0f; + N = faceforward(N, I, Nref); + + if (N == -1) + return true; + return false; +} + +bool test_faceforward_2() +{ + vec2 N = vec2(1, 1); + vec2 I = vec2(1, 0); + vec2 Nref = vec2(0, 0); + N = faceforward(N, I, Nref); + + if (N.x == -1 && N.y == -1) + return true; + return false; +} + +bool test_faceforward_3() +{ + vec3 N = vec3(1, 1, 1); + vec3 I = vec3(1, 0, 0); + vec3 Nref = vec3(0, 0, 0); + N = faceforward(N, I, Nref); + + if (N.x == -1 && N.y == -1 && N.z == -1) + return true; + return false; +} + +bool test_faceforward_4() +{ + vec4 N = vec4(1, 1, 1, 1); + vec4 I = vec4(1, 0, 0, 0); + vec4 Nref = vec4(0, 0, 0, 0); + N = faceforward(N, I, Nref); + + if (N.x == -1 && N.y == -1 && N.z == -1 && N.w == -1) + return true; + return false; +} + +bool test_reflect_2() +{ + vec2 N = vec2( 1, 0); + vec2 I = vec2(-1, 0); + vec2 result = reflect(I, N); + + if (result.x != 1.0f || result.y != 0.f) + return false; + return true; +} + +bool test_reflect_3() +{ + vec3 N = vec3( 1, 0, 0); + vec3 I = vec3(-1, 0, 0); + vec3 result = reflect(I, N); + + if (result.x != 1.0f || result.y != 0.f || result.z != 0.f) + return false; + return true; +} + +bool test_reflect_4() +{ + vec4 N = vec4( 1, 0, 0, 0); + vec4 I = vec4(-1, 0, 0, 0); + vec4 result = reflect(I, N); + + if (result.x != 1.0f || result.y != 0.f || result.z != 0.f || result.w != 0.f) + return false; + return true; +} + +bool test_refract_2() +{ + glm::vec2 N = glm::vec2( 1, 0); + glm::vec2 I = glm::vec2(-1, 0); + glm::vec2 result = glm::refract(I, N, 1.0f); + + if (result.x != -1.f || result.y != 0.f) + return false; + return true; +} + +bool test_refract_3() +{ + glm::vec3 N = glm::vec3( 1, 0, 0); + glm::vec3 I = glm::vec3(-1, 0, 0); + glm::vec3 result = glm::refract(I, N, 1.0f); + + if (result.x != -1.f || result.y != 0.f || result.z != 0.f) + return false; + return true; +} + +bool test_refract_4() +{ + glm::vec4 N = glm::vec4( 1, 0, 0, 0); + glm::vec4 I = glm::vec4(-1, 0, 0, 0); + glm::vec4 result = glm::refract(I, N, 1.0f); + + if (result.x != -1.f || result.y != 0.f || result.z != 0.f || result.w != 0.f) + return false; + return true; +} + + +void main_core_func_geometric() +{ + assert(test_length_1()); + assert(test_length_2()); + assert(test_length_3()); + assert(test_length_4()); + + assert(test_distance_1()); + assert(test_distance_2()); + assert(test_distance_3()); + assert(test_distance_4()); + + assert(test_dot_1()); + assert(test_dot_2()); + assert(test_dot_3()); + assert(test_dot_4()); + + assert(test_cross_vec3()); + + assert(test_normalize_1()); + assert(test_normalize_2()); + assert(test_normalize_3()); + assert(test_normalize_4()); + + assert(test_faceforward_1()); + assert(test_faceforward_2()); + assert(test_faceforward_3()); + assert(test_faceforward_4()); + + assert(test_reflect_2()); + assert(test_reflect_3()); + assert(test_reflect_4()); + + assert(test_refract_2()); + assert(test_refract_3()); + assert(test_refract_4()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/func_matrix.cpp b/test/core/func_matrix.cpp new file mode 100644 index 00000000..0ae3a106 --- /dev/null +++ b/test/core/func_matrix.cpp @@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_matrix.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +bool test_matrixcompmult_2x2() +{ + mat2 x = mat2(vec2(0, 1), vec2(2, 3)); + mat2 result = matrixCompMult(x, x); + + if(result[0][0] != 0 || result[0][1] != 1 || + result[1][0] != 4 || result[1][1] != 9) + return false; + return true; +} + +bool test_matrixcompmult_3x3() +{ + mat3 x = mat3(vec3(0, 0, 0), + vec3(1, 1, 1), + vec3(2, 2, 2)); + mat3 result = matrixCompMult(x, x); + + if(result[0][0] != 0 || result[0][1] != 0 || result[0][2] != 0 || + result[1][0] != 1 || result[1][1] != 1 || result[1][2] != 1 || + result[2][0] != 4 || result[2][1] != 4 || result[2][2] != 4) + return false; + return true; +} + +bool test_matrixcompmult_4x4() +{ + mat4 x = mat4(vec4(0, 0, 0, 0), + vec4(1, 1, 1, 1), + vec4(2, 2, 2, 2), + vec4(3, 3, 3, 3)); + mat4 result = matrixCompMult(x, x); + + if(result[0][0] != 0 || result[0][1] != 0 || result[0][2] != 0 || result[0][3] != 0 || + result[1][0] != 1 || result[1][1] != 1 || result[1][2] != 1 || result[1][3] != 1 || + result[2][0] != 4 || result[2][1] != 4 || result[2][2] != 4 || result[2][3] != 4 || + result[3][0] != 9 || result[3][1] != 9 || result[3][2] != 9 || result[3][3] != 9) + return false; + return true; +} + +bool test_outerProduct() +{ + mat2x2 m0 = glm::outerProduct(vec2(1.f), vec2(1.f)); + + return true; +} + +bool test_transpose() +{ + return true; +} + +void main_core_func_matrix() +{ + assert(test_matrixcompmult_2x2()); + assert(test_matrixcompmult_3x3()); + assert(test_matrixcompmult_4x4()); + + assert(test_outerProduct()); + + assert(test_transpose()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/func_noise.cpp b/test/core/func_noise.cpp new file mode 100644 index 00000000..c9c6e4c0 --- /dev/null +++ b/test/core/func_noise.cpp @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_noise.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +bool test_noise() +{ + return true; +} + +void main_core_func_noise() +{ + assert(test_noise()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/func_trigonometric.cpp b/test/core/func_trigonometric.cpp new file mode 100644 index 00000000..f14a9cd9 --- /dev/null +++ b/test/core/func_trigonometric.cpp @@ -0,0 +1,400 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_trigonometric.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +static const float epsilon = 0.00001f; +static const float pi = 3.14159265358979323846f; + +bool test_radians_1() +{ + float angle = radians(360.f); + + if(angle < 2.0f * pi + epsilon && angle > 2.0f * pi - epsilon) + return true; + return false; +} + +bool test_radians_2() +{ + vec2 angle = radians(vec2(360.f, 180.f)); + + if(angle.x < 2.0f * pi + epsilon && angle.x > 2.0f * pi - epsilon && + angle.y < pi + epsilon && angle.y > pi - epsilon) + return true; + return false; +} + +bool test_radians_3() +{ + vec3 angle = radians(vec3(360.f, 180.f, 0.f)); + + if(angle.x < 2.0f * pi + epsilon && angle.x > 2.0f * pi - epsilon && + angle.y < pi + epsilon && angle.y > pi - epsilon && + angle.z == 0.f) + return true; + return false; +} + +bool test_radians_4() +{ + vec4 angle = radians(vec4 (360.f, 180.f, 0.f, -180.f)); + + if(angle.x < 2.0f * pi + epsilon && angle.x > 2.0f * pi - epsilon && + angle.y < pi + epsilon && angle.y > pi - epsilon && + angle.z == 0.f && + angle.w > -(pi + epsilon) && angle.w < -(pi - epsilon)) + return true; + return false; +} + +bool test_degrees_1() +{ + float angle1 = degrees(pi * 2.f); + float angle2 = degrees(0.f); + + if(angle1 < 360.1f && angle1 > 359.9f && angle2 == 0.0f) + return true; + return false; +} + +bool test_degrees_2() +{ + vec2 angle = degrees(vec2 (pi * 2.f, pi)); + + if(angle.x < 360.1f && angle.x > 359.9f && + angle.y < 180.1f && angle.y > 179.9f) + return true; + return false; +} + +bool test_degrees_3() +{ + vec3 angle = degrees(vec3 (pi * 2.f, pi, 0.f)); + + if(angle.x < 360.1f && angle.x > 359.9f && + angle.y < 180.1f && angle.y > 179.9f && + angle.z == 0.f) + return true; + return false; +} + +bool test_degrees_4() +{ + vec4 angle = degrees(vec4 (pi * 2.f, pi, 0.f, -pi)); + + if(angle.x < 360.1f && angle.x > 359.9f && + angle.y < 180.1f && angle.y > 179.9f && + angle.z == 0.f && + angle.w > -180.1f && angle.w < -179.9f) + return true; + return false; +} + +bool test_sin_1() +{ + float sinus = glm::sin(0.f); + + if(sinus <= epsilon && sinus >= -epsilon) + return true; + return false; +} + +bool test_sin_2() +{ + glm::vec2 sinus = glm::sin(glm::vec2(0.f, 0.f)); + + if(sinus.x <= epsilon && sinus.x >= -epsilon && + sinus.y <= epsilon && sinus.y >= -epsilon) + return true; + return false; +} + +bool test_sin_3() +{ + glm::vec3 sinus = glm::sin(glm::vec3(0.f, 0.f, 0.f)); + + if(sinus.x <= epsilon && sinus.x >= -epsilon && + sinus.y <= epsilon && sinus.y >= -epsilon && + sinus.z <= epsilon && sinus.z >= -epsilon) + return true; + return false; +} + +bool test_sin_4() +{ + glm::vec4 sinus = glm::sin(glm::vec4(0.f, 0.f, 0.f, 0.f)); + + if(sinus.x <= epsilon && sinus.x >= -epsilon && + sinus.y <= epsilon && sinus.y >= -epsilon && + sinus.z <= epsilon && sinus.z >= -epsilon && + sinus.w <= epsilon && sinus.w >= -epsilon) + return true; + return false; +} + +bool test_cos_1() +{ + float cosinus = glm::cos(0.f); + + if(cosinus <= 1.0f + epsilon && cosinus >= 1.0f - epsilon) + return true; + return false; +} + +bool test_cos_2() +{ + glm::vec2 cosinus = glm::cos(glm::vec2(0.f, 0.f)); + + if(cosinus.x <= 1.0f + epsilon && cosinus.x >= 1.0f - epsilon && + cosinus.y <= 1.0f + epsilon && cosinus.y >= 1.0f - epsilon) + return true; + return false; +} + +bool test_cos_3() +{ + glm::vec3 cosinus = glm::cos(glm::vec3(0.f, 0.f, 0.f)); + + if(cosinus.x <= 1.0f + epsilon && cosinus.x >= 1.0f - epsilon && + cosinus.y <= 1.0f + epsilon && cosinus.y >= 1.0f - epsilon && + cosinus.z <= 1.0f + epsilon && cosinus.z >= 1.0f - epsilon) + return true; + return false; +} + +bool test_cos_4() +{ + glm::vec4 cosinus = glm::cos(glm::vec4(0.f, 0.f, 0.f, 0.f)); + + if(cosinus.x <= 1.0f + epsilon && cosinus.x >= 1.0f - epsilon && + cosinus.y <= 1.0f + epsilon && cosinus.y >= 1.0f - epsilon && + cosinus.z <= 1.0f + epsilon && cosinus.z >= 1.0f - epsilon && + cosinus.w <= 1.0f + epsilon && cosinus.w >= 1.0f - epsilon) + return true; + return false; +} + +bool test_tan_1() +{ + float tangent = glm::tan(0.f); + + if(tangent <= epsilon && tangent >= -epsilon) + return true; + return false; +} + +bool test_tan_2() +{ + glm::vec2 tangent = glm::tan(glm::vec2(0.f, 0.f)); + + if(tangent.x <= epsilon && tangent.x >= -epsilon && + tangent.y <= epsilon && tangent.y >= -epsilon) + return true; + return false; +} + +bool test_tan_3() +{ + glm::vec3 tangent = glm::tan(glm::vec3(0.f, 0.f, 0.f)); + + if(tangent.x <= epsilon && tangent.x >= -epsilon && + tangent.y <= epsilon && tangent.y >= -epsilon && + tangent.z <= epsilon && tangent.z >= -epsilon) + return true; + return false; +} + +bool test_tan_4() +{ + glm::vec4 tangent = glm::tan(glm::vec4(0.f, 0.f, 0.f, 0.f)); + + if(tangent.x <= epsilon && tangent.x >= -epsilon && + tangent.y <= epsilon && tangent.y >= -epsilon && + tangent.z <= epsilon && tangent.z >= -epsilon && + tangent.w <= epsilon && tangent.w >= -epsilon) + return true; + return false; +} + +bool test_asin_1() +{ + float arc_sinus = glm::asin(0.f); + + if(arc_sinus <= epsilon && arc_sinus >= -epsilon) + return true; + return false; +} + +bool test_asin_2() +{ + glm::vec2 arc_sinus = glm::asin(glm::vec2(0.f, 0.f)); + + if(arc_sinus.x <= epsilon && arc_sinus.x >= -epsilon && + arc_sinus.y <= epsilon && arc_sinus.y >= -epsilon) + return true; + return false; +} + +bool test_asin_3() +{ + glm::vec3 arc_sinus = glm::asin(glm::vec3(0.f, 0.f, 0.f)); + + if(arc_sinus.x <= epsilon && arc_sinus.x >= -epsilon && + arc_sinus.y <= epsilon && arc_sinus.y >= -epsilon && + arc_sinus.z <= epsilon && arc_sinus.z >= -epsilon) + return true; + return false; +} + +bool test_asin_4() +{ + glm::vec4 arc_sinus = glm::sin(glm::vec4(0.f, 0.f, 0.f, 0.f)); + + if(arc_sinus.x <= epsilon && arc_sinus.x >= -epsilon && + arc_sinus.y <= epsilon && arc_sinus.y >= -epsilon && + arc_sinus.z <= epsilon && arc_sinus.z >= -epsilon && + arc_sinus.w <= epsilon && arc_sinus.w >= -epsilon) + return true; + return false; +} + +bool test_acos_1() +{ + float arc_cosinus = glm::acos(1.f); + + if(arc_cosinus <= epsilon && arc_cosinus >= -epsilon) + return true; + return false; +} + +bool test_acos_2() +{ + glm::vec2 arc_cosinus = glm::acos(glm::vec2(1.f, 1.f)); + + if(arc_cosinus.x <= epsilon && arc_cosinus.x >= -epsilon && + arc_cosinus.y <= epsilon && arc_cosinus.y >= -epsilon) + return true; + return false; +} + +bool test_acos_3() +{ + glm::vec3 arc_cosinus = glm::acos(glm::vec3(1.f, 1.f, 1.f)); + + if(arc_cosinus.x <= epsilon && arc_cosinus.x >= -epsilon && + arc_cosinus.y <= epsilon && arc_cosinus.y >= -epsilon && + arc_cosinus.z <= epsilon && arc_cosinus.z >= -epsilon) + return true; + return false; +} + +bool test_acos_4() +{ + glm::vec4 arc_cosinus = glm::acos(glm::vec4(1.f, 1.f, 1.f, 1.f)); + + if(arc_cosinus.x <= epsilon && arc_cosinus.x >= -epsilon && + arc_cosinus.y <= epsilon && arc_cosinus.y >= -epsilon && + arc_cosinus.z <= epsilon && arc_cosinus.z >= -epsilon && + arc_cosinus.w <= epsilon && arc_cosinus.w >= -epsilon) + return true; + return false; +} + +bool test_atan_1() +{ + float tangent = glm::atan(0.f); + + if(tangent <= epsilon && tangent >= -epsilon) + return true; + return false; +} + +bool test_atan_2() +{ + glm::vec2 tangent = glm::atan(glm::vec2(0.f, 0.f)); + + if(tangent.x <= epsilon && tangent.x >= -epsilon && + tangent.y <= epsilon && tangent.y >= -epsilon) + return true; + return false; +} + +bool test_atan_3() +{ + glm::vec3 tangent = glm::atan(glm::vec3(0.f, 0.f, 0.f)); + + if(tangent.x <= epsilon && tangent.x >= -epsilon && + tangent.y <= epsilon && tangent.y >= -epsilon && + tangent.z <= epsilon && tangent.z >= -epsilon) + return true; + return false; +} + +bool test_atan_4() +{ + glm::vec4 tangent = glm::atan(glm::vec4(0.f, 0.f, 0.f, 0.f)); + + if(tangent.x <= epsilon && tangent.x >= -epsilon && + tangent.y <= epsilon && tangent.y >= -epsilon && + tangent.z <= epsilon && tangent.z >= -epsilon && + tangent.w <= epsilon && tangent.w >= -epsilon) + return true; + return false; +} + +void main_core_func_trigonometric() +{ + assert(test_radians_1()); + assert(test_radians_2()); + assert(test_radians_3()); + assert(test_radians_4()); + + assert(test_degrees_1()); + assert(test_degrees_2()); + assert(test_degrees_3()); + assert(test_degrees_4()); + + assert(test_sin_1()); + assert(test_sin_2()); + assert(test_sin_3()); + assert(test_sin_4()); + + assert(test_cos_1()); + assert(test_cos_2()); + assert(test_cos_3()); + assert(test_cos_4()); + + assert(test_tan_1()); + assert(test_tan_2()); + assert(test_tan_3()); + assert(test_tan_4()); + + assert(test_asin_1()); + assert(test_asin_2()); + assert(test_asin_3()); + assert(test_asin_4()); + + assert(test_acos_1()); + assert(test_acos_2()); + assert(test_acos_3()); + assert(test_acos_4()); + + assert(test_atan_1()); + assert(test_atan_2()); + assert(test_atan_3()); + assert(test_atan_4()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/func_vector_relational.cpp b/test/core/func_vector_relational.cpp new file mode 100644 index 00000000..3bf0612c --- /dev/null +++ b/test/core/func_vector_relational.cpp @@ -0,0 +1,383 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/func_vector_relational.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +bool test_lessthan_2() +{ + bvec2 lessThan1 = lessThan(vec2(0.f, 1.f), vec2(1.f, 0.f)); + bvec2 lessThan2 = lessThan(ivec2(0, 1), ivec2(1, 0)); + + if(!lessThan1.x || lessThan1.y) + return false; + if(!lessThan2.x || lessThan2.y) + return false; + return true; +} + +bool test_lessthan_3() +{ + bvec3 lessThan1 = lessThan(vec3(0.f, 1.f, 1.f), vec3(1.f, 0.f, 1.f)); + bvec3 lessThan2 = lessThan(ivec3(0, 1, 1), ivec3(1, 0, 1)); + + if(!lessThan1.x || lessThan1.y || lessThan1.z) + return false; + if(!lessThan2.x || lessThan2.y || lessThan2.z) + return false; + return true; +} + +bool test_lessthan_4() +{ + bvec4 lessThan1 = lessThan(vec4(0.f, 1.f, 1.f, 0.f), vec4(1.f, 0.f, 1.f, 0.f)); + bvec4 lessThan2 = lessThan(ivec4(0, 1, 1, 0), ivec4(1, 0, 1, 0)); + + if(!lessThan1.x || lessThan1.y || lessThan1.z || lessThan1.w) + return false; + if(!lessThan2.x || lessThan2.y || lessThan2.z || lessThan2.w) + return false; + return true; +} + +bool test_lessthanequal_2() +{ + bvec2 result1 = lessThanEqual(vec2(0.f, 1.f), vec2(1.f, 0.f)); + bvec2 result2 = lessThanEqual(ivec2(0, 1), ivec2(1, 0)); + + if(!result1.x || result1.y) + return false; + if(!result2.x || result2.y) + return false; + return true; +} + +bool test_lessthanequal_3() +{ + bvec3 result1 = lessThanEqual(vec3(0.f, 1.f, 1.f), vec3(1.f, 0.f, 1.f)); + bvec3 result2 = lessThanEqual(ivec3(0, 1, 1), ivec3(1, 0, 1)); + + if(!result1.x || result1.y || !result1.z) + return false; + if(!result2.x || result2.y || !result2.z) + return false; + return true; +} + +bool test_lessthanequal_4() +{ + bvec4 result1 = lessThanEqual(vec4(0.f, 1.f, 1.f, 0.f), vec4(1.f, 0.f, 1.f, 0.f)); + bvec4 result2 = lessThanEqual(ivec4(0, 1, 1, 0), ivec4(1, 0, 1, 0)); + + if(!result1.x || result1.y || !result1.z || !result1.w) + return false; + if(!result2.x || result2.y || !result2.z || !result2.w) + return false; + return true; +} + +bool test_all_2() +{ + bool result1 = all(bvec2(true, true)); + bool result2 = all(bvec2(true, false)); + bool result3 = all(bvec2(false, false)); + + if(!result1 || result2 || result3) + return false; + return true; +} + +bool test_all_3() +{ + bool result1 = all(bvec3(true, true, true)); + bool result2 = all(bvec3(true, false, true)); + bool result3 = all(bvec3(false, false, false)); + + if(!result1 || result2 || result3) + return false; + return true; +} + +bool test_all_4() +{ + bool result1 = all(bvec4(true, true, true, true)); + bool result2 = all(bvec4(true, false, true, false)); + bool result3 = all(bvec4(false, false, false, false)); + + if(!result1 || result2 || result3) + return false; + return true; +} + +bool test_greaterthan_2() +{ + bvec2 result1 = greaterThan(vec2(0.f, 1.f), vec2(1.f, 0.f)); + bvec2 result2 = greaterThan(ivec2(0, 1), ivec2(1, 0)); + + if(result1.x || !result1.y) + return false; + if(result2.x || !result2.y) + return false; + return true; +} + +bool test_greaterthan_3() +{ + bvec3 result1 = greaterThan(vec3(0.f, 1.f, 1.f), vec3(1.f, 0.f, 1.f)); + bvec3 result2 = greaterThan(ivec3(0, 1, 1), ivec3(1, 0, 1)); + + if(result1.x || !result1.y || result1.z) + return false; + if(result2.x || !result2.y || result2.z) + return false; + return true; +} + +bool test_greaterthan_4() +{ + bvec4 result1 = greaterThan(vec4(0.f, 1.f, 1.f, 0.f), vec4(1.f, 0.f, 1.f, 0.f)); + bvec4 result2 = greaterThan(ivec4(0, 1, 1, 0), ivec4(1, 0, 1, 0)); + + if(result1.x || !result1.y || result1.z || result1.w) + return false; + if(result2.x || !result2.y || result2.z || result2.w) + return false; + return true; +} + +bool test_greaterthanequal_2() +{ + bvec2 result1 = greaterThanEqual(vec2(0.f, 1.f), vec2(1.f, 0.f)); + bvec2 result2 = greaterThanEqual(ivec2(0, 1), ivec2(1, 0)); + + if(result1.x || !result1.y) + return false; + if(result2.x || !result2.y) + return false; + return true; +} + +bool test_greaterthanequal_3() +{ + bvec3 result1 = greaterThanEqual(vec3(0.f, 1.f, 1.f), vec3(1.f, 0.f, 1.f)); + bvec3 result2 = greaterThanEqual(ivec3(0, 1, 1), ivec3(1, 0, 1)); + + if(result1.x || !result1.y || !result1.z) + return false; + if(result2.x || !result2.y || !result2.z) + return false; + return true; +} + +bool test_greaterthanequal_4() +{ + bvec4 result1 = greaterThanEqual(vec4(0.f, 1.f, 1.f, 0.f), vec4(1.f, 0.f, 1.f, 0.f)); + bvec4 result2 = greaterThanEqual(ivec4(0, 1, 1, 0), ivec4(1, 0, 1, 0)); + + if(result1.x || !result1.y || !result1.z || !result1.w) + return false; + if(result2.x || !result2.y || !result2.z || !result2.w) + return false; + return true; +} + +bool test_equal_2() +{ + bvec2 result1 = equal(vec2(76.f, 0.f), vec2(76.f, 76.f)); + bvec2 result2 = equal(ivec2(76, 0), ivec2(76, 76)); + bvec2 result3 = equal(bvec2(true, false), bvec2(true, true)); + + if(!result1.x || result1.y) + return false; + if(!result2.x || result2.y) + return false; + if(!result3.x || result3.y) + return false; + return true; +} + +bool test_equal_3() +{ + bvec3 result1 = equal(vec3(76.f, 0.f, 76.f), vec3(76.f, 76.f, 76.f)); + bvec3 result2 = equal(ivec3(76, 0, 76), ivec3(76, 76, 76)); + bvec3 result3 = equal(bvec3(true, false, true), bvec3(true, true, true)); + + if(!result1.x || result1.y || !result1.z) + return false; + if(!result2.x || result2.y || !result2.z) + return false; + if(!result3.x || result3.y || !result3.z) + return false; + return true; +} + +bool test_equal_4() +{ + bvec4 result1 = equal(vec4(76.f, 0.f, 76.f, 0.f), vec4(76.f, 76.f, 76.f, 76.f)); + bvec4 result2 = equal(ivec4(76, 0, 76, 0), ivec4(76, 76, 76, 76)); + bvec4 result3 = equal(bvec4(true, false, true, false), bvec4(true, true, true, true)); + + if(!result1.x || result1.y || !result1.z || result1.w) + return false; + if(!result2.x || result2.y || !result2.z || result2.w) + return false; + if(!result3.x || result3.y || !result3.z || result3.w) + return false; + return true; +} + +bool test_notequal_2() +{ + bvec2 result1 = notEqual(vec2(76.f, 0.f), vec2(76.f, 76.f)); + bvec2 result2 = notEqual(ivec2(76, 0), ivec2(76, 76)); + bvec2 result3 = notEqual(bvec2(true, false), bvec2(true, true)); + + if(result1.x || !result1.y) + return false; + if(result2.x || !result2.y) + return false; + if(result3.x || !result3.y) + return false; + return true; +} + +bool test_notequal_3() +{ + bvec3 result1 = notEqual(vec3(76.f, 0.f, 76.f), vec3(76.f, 76.f, 76.f)); + bvec3 result2 = notEqual(ivec3(76, 0, 76), ivec3(76, 76, 76)); + bvec3 result3 = notEqual(bvec3(true, false, true), bvec3(true, true, true)); + + if(result1.x || !result1.y || result1.z) + return false; + if(result2.x || !result2.y || result2.z) + return false; + if(result3.x || !result3.y || result3.z) + return false; + return true; +} + +bool test_notequal_4() +{ + bvec4 result1 = notEqual(vec4(76.f, 0.f, 76.f, 0.f), vec4(76.f, 76.f, 76.f, 76.f)); + bvec4 result2 = notEqual(ivec4(76, 0, 76, 0), ivec4(76, 76, 76, 76)); + bvec4 result3 = notEqual(bvec4(true, false, true, false), bvec4(true, true, true, true)); + + if(result1.x || !result1.y || result1.z || !result1.w) + return false; + if(result2.x || !result2.y || result2.z || !result2.w) + return false; + if(result3.x || !result3.y || result3.z || !result3.w) + return false; + return true; +} + +bool test_any_2() +{ + bool result1 = any(bvec2(true, true)); + bool result2 = any(bvec2(true, false)); + bool result3 = any(bvec2(false, false)); + + if(!result1 || !result2 || result3) + return false; + return true; +} + +bool test_any_3() +{ + bool result1 = any(bvec3(true, true, true)); + bool result2 = any(bvec3(true, false, true)); + bool result3 = any(bvec3(false, false, false)); + + if(!result1 || !result2 || result3) + return false; + return true; +} + +bool test_any_4() +{ + bool result1 = any(bvec4(true, true, true, true)); + bool result2 = any(bvec4(true, false, true, false)); + bool result3 = any(bvec4(false, false, false, false)); + + if(!result1 || !result2 || result3) + return false; + return true; +} + +bool test_not_2() +{ + bvec2 result = not_(bvec2(true, false)); + + if(result.x || !result.y) + return false; + return true; +} + +bool test_not_3() +{ + bvec3 result = not_(bvec3(true, false, true)); + + if(result.x || !result.y || result.z) + return false; + return true; +} + +bool test_not_4() +{ + bvec4 result = not_(bvec4(true, false, true, false)); + + if(result.x || !result.y || result.z || !result.w) + return false; + return true; +} + +void main_core_func_vector_relational() +{ + assert(test_lessthan_2()); + assert(test_lessthan_3()); + assert(test_lessthan_4()); + + assert(test_lessthanequal_2()); + assert(test_lessthanequal_3()); + assert(test_lessthanequal_4()); + + assert(test_greaterthan_2()); + assert(test_greaterthan_3()); + assert(test_greaterthan_4()); + + assert(test_greaterthanequal_2()); + assert(test_greaterthanequal_3()); + assert(test_greaterthanequal_4()); + + assert(test_greaterthanequal_2()); + assert(test_greaterthanequal_3()); + assert(test_greaterthanequal_4()); + + assert(test_equal_2()); + assert(test_equal_3()); + assert(test_equal_4()); + + assert(test_notequal_2()); + assert(test_notequal_3()); + assert(test_notequal_4()); + + assert(test_any_2()); + assert(test_any_3()); + assert(test_any_4()); + + assert(test_all_2()); + assert(test_all_3()); + assert(test_all_4()); +} + +}//namespace test +}//namespace glm diff --git a/test/core/type.cpp b/test/core/type.cpp new file mode 100644 index 00000000..f3d50ebd --- /dev/null +++ b/test/core/type.cpp @@ -0,0 +1,10 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" diff --git a/test/core/type_float.cpp b/test/core/type_float.cpp new file mode 100644 index 00000000..69f383f4 --- /dev/null +++ b/test/core/type_float.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_float.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_float() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_half.cpp b/test/core/type_half.cpp new file mode 100644 index 00000000..77d0a281 --- /dev/null +++ b/test/core/type_half.cpp @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT licence +// File : test/core/type_half.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test +{ + typedef detail::thalf thalf; + + bool main_type_half() + { + bool Result = true; + + { + thalf A(1.0f); + thalf B(2.0f); + thalf C = A + B; + thalf D(C); + float E = D; + int F = C; + thalf G = B * C; + thalf H = G / C; + H += thalf(1.0f); + double J = H; + int I = H; + + Result = Result && J == 3.0; + } + + return Result; + } + +}//namespace test +}//namespace glm diff --git a/test/core/type_int.cpp b/test/core/type_int.cpp new file mode 100644 index 00000000..d41e4f63 --- /dev/null +++ b/test/core/type_int.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_int.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_int() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat2x2.cpp b/test/core/type_mat2x2.cpp new file mode 100644 index 00000000..4ad2a82f --- /dev/null +++ b/test/core/type_mat2x2.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat2x2.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat2x2() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat2x3.cpp b/test/core/type_mat2x3.cpp new file mode 100644 index 00000000..b4d0db37 --- /dev/null +++ b/test/core/type_mat2x3.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat2x3.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat2x3() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat2x4.cpp b/test/core/type_mat2x4.cpp new file mode 100644 index 00000000..549eb507 --- /dev/null +++ b/test/core/type_mat2x4.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat2x4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat2x4() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat3x2.cpp b/test/core/type_mat3x2.cpp new file mode 100644 index 00000000..4d229b00 --- /dev/null +++ b/test/core/type_mat3x2.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat3x2.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat3x2() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat3x3.cpp b/test/core/type_mat3x3.cpp new file mode 100644 index 00000000..9d099a16 --- /dev/null +++ b/test/core/type_mat3x3.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat3x3.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat3x3() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat3x4.cpp b/test/core/type_mat3x4.cpp new file mode 100644 index 00000000..8489d517 --- /dev/null +++ b/test/core/type_mat3x4.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat3x4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat3x4() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat4x2.cpp b/test/core/type_mat4x2.cpp new file mode 100644 index 00000000..bdb61886 --- /dev/null +++ b/test/core/type_mat4x2.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat4x2.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat4x2() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat4x3.cpp b/test/core/type_mat4x3.cpp new file mode 100644 index 00000000..bd0c720c --- /dev/null +++ b/test/core/type_mat4x3.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat4x3.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_mat4x3() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_mat4x4.cpp b/test/core/type_mat4x4.cpp new file mode 100644 index 00000000..dc8845ba --- /dev/null +++ b/test/core/type_mat4x4.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_mat4x4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include "glm/core/type_mat4x4.hpp" + +namespace glm{ +namespace test{ + +void main_mat4x4() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_vec1.cpp b/test/core/type_vec1.cpp new file mode 100644 index 00000000..44f711c1 --- /dev/null +++ b/test/core/type_vec1.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_vec1.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_vec1() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_vec2.cpp b/test/core/type_vec2.cpp new file mode 100644 index 00000000..859f7620 --- /dev/null +++ b/test/core/type_vec2.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_vec2.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_vec2() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_vec3.cpp b/test/core/type_vec3.cpp new file mode 100644 index 00000000..38467c2c --- /dev/null +++ b/test/core/type_vec3.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_vec3.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_vec3() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/core/type_vec4.cpp b/test/core/type_vec4.cpp new file mode 100644 index 00000000..55d6fdf7 --- /dev/null +++ b/test/core/type_vec4.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2008-08-31 +// Licence : This source is under MIT License +// File : test/core/type_vec4.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "../precompiled.hpp" +#include + +namespace glm{ +namespace test{ + +void main_vec4() +{ + +} + +}//namespace test +}//namespace glm diff --git a/test/gtc.cpp b/test/gtc.cpp new file mode 100644 index 00000000..e69de29b diff --git a/test/gtc.hpp b/test/gtc.hpp new file mode 100644 index 00000000..e69de29b diff --git a/test/gtc/double_float.cpp b/test/gtc/double_float.cpp new file mode 100644 index 00000000..0ca43e65 --- /dev/null +++ b/test/gtc/double_float.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_double_float() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/half_float.cpp b/test/gtc/half_float.cpp new file mode 100644 index 00000000..deb09dc5 --- /dev/null +++ b/test/gtc/half_float.cpp @@ -0,0 +1,25 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_half_float() + { + bool Result = true; + + { + glm::hvec2 A(1.0f, 3.0f); + glm::half B(2.0f); + glm::hvec2 C = A * B; + glm::hvec2 D = C - glm::hvec2(2.0f); + + Result = Result && glm::all(glm::equal(C, glm::hvec2(0.0f, 4.0f))); + } + + return Result; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/matrix_access.cpp b/test/gtc/matrix_access.cpp new file mode 100644 index 00000000..adbfd430 --- /dev/null +++ b/test/gtc/matrix_access.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_matrix_access() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/matrix_operation.cpp b/test/gtc/matrix_operation.cpp new file mode 100644 index 00000000..41346539 --- /dev/null +++ b/test/gtc/matrix_operation.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_matrix_operation() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/matrix_projection.cpp b/test/gtc/matrix_projection.cpp new file mode 100644 index 00000000..b67325ac --- /dev/null +++ b/test/gtc/matrix_projection.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_matrix_projection() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/matrix_transform.cpp b/test/gtc/matrix_transform.cpp new file mode 100644 index 00000000..c833e8aa --- /dev/null +++ b/test/gtc/matrix_transform.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_matrix_transform() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/quaternion.cpp b/test/gtc/quaternion.cpp new file mode 100644 index 00000000..cfc89e24 --- /dev/null +++ b/test/gtc/quaternion.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_quaternion() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtc/type_precision.cpp b/test/gtc/type_precision.cpp new file mode 100644 index 00000000..02ac245e --- /dev/null +++ b/test/gtc/type_precision.cpp @@ -0,0 +1,14 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_gtc_type_precision() + { + return false; + } + +}//namespace test +}//namespace glm diff --git a/test/gtx.hpp b/test/gtx.hpp new file mode 100644 index 00000000..e69de29b diff --git a/test/gtx/associated_min_max.cpp b/test/gtx/associated_min_max.cpp new file mode 100644 index 00000000..2a440512 --- /dev/null +++ b/test/gtx/associated_min_max.cpp @@ -0,0 +1,222 @@ +#include "../precompiled.hpp" +#include +#include + +using namespace glm; + +bool test_associated_min_max() +{ + //{ + // int ResultA = associatedMinGTX( + // 0.0f, 2, + // 1.0f, 4); + + // int ResultB = associatedMaxGTX( + // 0.0f, 2, + // 1.0f, 4); + + // int ResultC = associatedMinGTX( + // 0.0f, 2, + // 1.0f, 4, + // 2.0f, 8); + + // int ResultD = associatedMaxGTX( + // 0.0f, 2, + // 1.0f, 4, + // 2.0f, 8); + + // int ResultE = associatedMinGTX( + // 0.0f, 2, + // 1.0f, 4, + // 2.0f, 8, + // 3.0f, 6); + + // int ResultF = associatedMaxGTX( + // 0.0f, 2, + // 1.0f, 4, + // 2.0f, 8, + // 3.0f, 6); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMinGTX( + // glm::vec2(0), glm::ivec2(2), + // glm::vec2(1), glm::ivec2(4)); + + // glm::ivec3 ResultB = associatedMinGTX( + // glm::vec3(0), glm::ivec3(2), + // glm::vec3(1), glm::ivec3(4)); + + // glm::ivec4 ResultC = associatedMinGTX( + // glm::vec4(0), glm::ivec4(2), + // glm::vec4(1), glm::ivec4(4)); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMaxGTX( + // glm::vec2(0), glm::ivec2(2), + // glm::vec2(1), glm::ivec2(4)); + + // glm::ivec3 ResultB = associatedMaxGTX( + // glm::vec3(0), glm::ivec3(2), + // glm::vec3(1), glm::ivec3(4)); + + // glm::ivec4 ResultC = associatedMaxGTX( + // glm::vec4(0), glm::ivec4(2), + // glm::vec4(1), glm::ivec4(4)); + + // int End = 0; + //} + + //{ + // glm::vec2 ResultA = associatedMinGTX( + // glm::vec2(0.f), 2.f, + // glm::vec2(1.f), 4.f); + + // glm::ivec3 ResultB = associatedMinGTX( + // glm::vec3(0.f), 2, + // glm::vec3(1.f), 4); + + // glm::ivec4 ResultC = associatedMinGTX( + // glm::vec4(0.f), 2, + // glm::vec4(1.f), 4); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMaxGTX( + // glm::vec2(0), 2, + // glm::vec2(1), 4); + + // glm::ivec3 ResultB = associatedMaxGTX( + // glm::vec3(0), 2, + // glm::vec3(1), 4); + + // glm::ivec4 ResultC = associatedMaxGTX( + // glm::vec4(0), 2, + // glm::vec4(1), 4); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMinGTX( + // 0.0f, glm::ivec2(2), + // 1.0f, glm::ivec2(4)); + + // glm::ivec3 ResultB = associatedMinGTX( + // 0.0f, glm::ivec3(2), + // 1.0f, glm::ivec3(4)); + + // glm::ivec4 ResultC = associatedMinGTX( + // 0.0f, glm::ivec4(2), + // 1.0f, glm::ivec4(4)); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMaxGTX( + // 0.0f, glm::ivec2(2), + // 1.0f, glm::ivec2(4)); + + // glm::ivec3 ResultB = associatedMaxGTX( + // 0.0f, glm::ivec3(2), + // 1.0f, glm::ivec3(4)); + + // glm::ivec4 ResultC = associatedMaxGTX( + // 0.0f, glm::ivec4(2), + // 1.0f, glm::ivec4(4)); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMinGTX( + // glm::vec2(0), glm::ivec2(2), + // glm::vec2(1), glm::ivec2(4), + // glm::vec2(2), glm::ivec2(8)); + + // glm::ivec3 ResultB = associatedMinGTX( + // glm::vec3(0), glm::ivec3(2), + // glm::vec3(1), glm::ivec3(4), + // glm::vec3(2), glm::ivec3(8)); + + // glm::ivec4 ResultC = associatedMinGTX( + // glm::vec4(0), glm::ivec4(2), + // glm::vec4(1), glm::ivec4(4), + // glm::vec4(2), glm::ivec4(8)); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMaxGTX( + // glm::vec2(0), glm::ivec2(2), + // glm::vec2(1), glm::ivec2(4), + // glm::vec2(2), glm::ivec2(8)); + + // glm::ivec3 ResultB = associatedMaxGTX( + // glm::vec3(0), glm::ivec3(2), + // glm::vec3(1), glm::ivec3(4), + // glm::vec3(2), glm::ivec3(8)); + + // glm::ivec4 ResultC = associatedMaxGTX( + // glm::vec4(0), glm::ivec4(2), + // glm::vec4(1), glm::ivec4(4), + // glm::vec4(2), glm::ivec4(8)); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMinGTX( + // glm::vec2(0), glm::ivec2(2), + // glm::vec2(1), glm::ivec2(4), + // glm::vec2(2), glm::ivec2(8), + // glm::vec2(3), glm::ivec2(6)); + + // glm::ivec3 ResultB = associatedMinGTX( + // glm::vec3(0), glm::ivec3(2), + // glm::vec3(1), glm::ivec3(4), + // glm::vec3(2), glm::ivec3(8), + // glm::vec3(3), glm::ivec3(6)); + + // glm::ivec4 ResultC = associatedMinGTX( + // glm::vec4(0), glm::ivec4(2), + // glm::vec4(1), glm::ivec4(4), + // glm::vec4(2), glm::ivec4(8), + // glm::vec4(3), glm::ivec4(6)); + + // int End = 0; + //} + + //{ + // glm::ivec2 ResultA = associatedMaxGTX( + // glm::vec2(0), glm::ivec2(2), + // glm::vec2(1), glm::ivec2(4), + // glm::vec2(2), glm::ivec2(8), + // glm::vec2(3), glm::ivec2(6)); + + // glm::ivec3 ResultB = associatedMaxGTX( + // glm::vec3(0), glm::ivec3(2), + // glm::vec3(1), glm::ivec3(4), + // glm::vec3(2), glm::ivec3(8), + // glm::vec3(3), glm::ivec3(6)); + + // glm::ivec4 ResultC = associatedMaxGTX( + // glm::vec4(0), glm::ivec4(2), + // glm::vec4(1), glm::ivec4(4), + // glm::vec4(2), glm::ivec4(8), + // glm::vec4(3), glm::ivec4(6)); + + // int End = 0; + //} + + return true; +} diff --git a/test/gtx/bit.cpp b/test/gtx/bit.cpp new file mode 100644 index 00000000..30893d05 --- /dev/null +++ b/test/gtx/bit.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/closest_point.cpp b/test/gtx/closest_point.cpp new file mode 100644 index 00000000..7245a91b --- /dev/null +++ b/test/gtx/closest_point.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/color_cast.cpp b/test/gtx/color_cast.cpp new file mode 100644 index 00000000..a30afb74 --- /dev/null +++ b/test/gtx/color_cast.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/color_space.cpp b/test/gtx/color_space.cpp new file mode 100644 index 00000000..f9a3d355 --- /dev/null +++ b/test/gtx/color_space.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/comparison.cpp b/test/gtx/comparison.cpp new file mode 100644 index 00000000..870b7b30 --- /dev/null +++ b/test/gtx/comparison.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/compatibility.cpp b/test/gtx/compatibility.cpp new file mode 100644 index 00000000..8517853c --- /dev/null +++ b/test/gtx/compatibility.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/component_wise.cpp b/test/gtx/component_wise.cpp new file mode 100644 index 00000000..f3a2c8c1 --- /dev/null +++ b/test/gtx/component_wise.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/epsilon.cpp b/test/gtx/epsilon.cpp new file mode 100644 index 00000000..32b386f0 --- /dev/null +++ b/test/gtx/epsilon.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/euler_angles.cpp b/test/gtx/euler_angles.cpp new file mode 100644 index 00000000..090e8795 --- /dev/null +++ b/test/gtx/euler_angles.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/extend.cpp b/test/gtx/extend.cpp new file mode 100644 index 00000000..e863a5a4 --- /dev/null +++ b/test/gtx/extend.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/extented_min_max.cpp b/test/gtx/extented_min_max.cpp new file mode 100644 index 00000000..21ade74b --- /dev/null +++ b/test/gtx/extented_min_max.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/fast_exponential.cpp b/test/gtx/fast_exponential.cpp new file mode 100644 index 00000000..82cdc43d --- /dev/null +++ b/test/gtx/fast_exponential.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/fast_square_root.cpp b/test/gtx/fast_square_root.cpp new file mode 100644 index 00000000..ebb7443c --- /dev/null +++ b/test/gtx/fast_square_root.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/fast_trigonometry.cpp b/test/gtx/fast_trigonometry.cpp new file mode 100644 index 00000000..c86e085f --- /dev/null +++ b/test/gtx/fast_trigonometry.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/handed_coordinate_space.cpp b/test/gtx/handed_coordinate_space.cpp new file mode 100644 index 00000000..dd5a3833 --- /dev/null +++ b/test/gtx/handed_coordinate_space.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/inertia.cpp b/test/gtx/inertia.cpp new file mode 100644 index 00000000..b3da6a07 --- /dev/null +++ b/test/gtx/inertia.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/integer.cpp b/test/gtx/integer.cpp new file mode 100644 index 00000000..c94e3e35 --- /dev/null +++ b/test/gtx/integer.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/intersect.cpp b/test/gtx/intersect.cpp new file mode 100644 index 00000000..4514e8bf --- /dev/null +++ b/test/gtx/intersect.cpp @@ -0,0 +1,27 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + void main_gtx_intesect() + { + glm::vec3 Origin = glm::vec3(0.25f, 0.33f, 10.f); + glm::vec3 Direction = glm::vec3(0.0f, 0.0f, -1.f); + + glm::vec3 Vect0 = glm::vec3(0.0f, 0.0f, 0.f); + glm::vec3 Vect1 = glm::vec3(1.0f, 0.0f, 0.f); + glm::vec3 Vect2 = glm::vec3(0.0f, 1.0f, 0.f); + glm::vec3 Position(0.0f); + + bool Result = intersectRayTriangle( + Origin, Direction, + Vect0, Vect1, Vect2, + Position); + + bool End = true; + } + +}//namespace test +}//namespace glm diff --git a/test/gtx/inverse.cpp b/test/gtx/inverse.cpp new file mode 100644 index 00000000..78b43d6a --- /dev/null +++ b/test/gtx/inverse.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/inverse_transpose.cpp b/test/gtx/inverse_transpose.cpp new file mode 100644 index 00000000..9fc5f4c8 --- /dev/null +++ b/test/gtx/inverse_transpose.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matrix_access.cpp b/test/gtx/matrix_access.cpp new file mode 100644 index 00000000..4842e8a8 --- /dev/null +++ b/test/gtx/matrix_access.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matrix_cross_product.cpp b/test/gtx/matrix_cross_product.cpp new file mode 100644 index 00000000..98c3a6c7 --- /dev/null +++ b/test/gtx/matrix_cross_product.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matrix_major_storage.cpp b/test/gtx/matrix_major_storage.cpp new file mode 100644 index 00000000..82b6ddb0 --- /dev/null +++ b/test/gtx/matrix_major_storage.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matrix_projection.cpp b/test/gtx/matrix_projection.cpp new file mode 100644 index 00000000..5dd3958c --- /dev/null +++ b/test/gtx/matrix_projection.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matrix_query.cpp b/test/gtx/matrix_query.cpp new file mode 100644 index 00000000..1c665ab9 --- /dev/null +++ b/test/gtx/matrix_query.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matrix_selection.cpp b/test/gtx/matrix_selection.cpp new file mode 100644 index 00000000..e756af3e --- /dev/null +++ b/test/gtx/matrix_selection.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/matx.cpp b/test/gtx/matx.cpp new file mode 100644 index 00000000..adeabdb0 --- /dev/null +++ b/test/gtx/matx.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/mixed_product.cpp b/test/gtx/mixed_product.cpp new file mode 100644 index 00000000..4c9ecb4e --- /dev/null +++ b/test/gtx/mixed_product.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/norm.cpp b/test/gtx/norm.cpp new file mode 100644 index 00000000..07d99886 --- /dev/null +++ b/test/gtx/norm.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/normal.cpp b/test/gtx/normal.cpp new file mode 100644 index 00000000..b97b9eaf --- /dev/null +++ b/test/gtx/normal.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/normalize_dot.cpp b/test/gtx/normalize_dot.cpp new file mode 100644 index 00000000..5706ceee --- /dev/null +++ b/test/gtx/normalize_dot.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/number_precision.cpp b/test/gtx/number_precision.cpp new file mode 100644 index 00000000..7017831f --- /dev/null +++ b/test/gtx/number_precision.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/optimum_pow.cpp b/test/gtx/optimum_pow.cpp new file mode 100644 index 00000000..cf51c2bf --- /dev/null +++ b/test/gtx/optimum_pow.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/orthonormalize.cpp b/test/gtx/orthonormalize.cpp new file mode 100644 index 00000000..f284a03e --- /dev/null +++ b/test/gtx/orthonormalize.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/perpendicular.cpp b/test/gtx/perpendicular.cpp new file mode 100644 index 00000000..f5e5d392 --- /dev/null +++ b/test/gtx/perpendicular.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/polar_coordinates.cpp b/test/gtx/polar_coordinates.cpp new file mode 100644 index 00000000..98bec2b1 --- /dev/null +++ b/test/gtx/polar_coordinates.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/projection.cpp b/test/gtx/projection.cpp new file mode 100644 index 00000000..48a5c952 --- /dev/null +++ b/test/gtx/projection.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/quaternion.cpp b/test/gtx/quaternion.cpp new file mode 100644 index 00000000..8a79430a --- /dev/null +++ b/test/gtx/quaternion.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/random.cpp b/test/gtx/random.cpp new file mode 100644 index 00000000..a6140e87 --- /dev/null +++ b/test/gtx/random.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/rotate_vector.cpp b/test/gtx/rotate_vector.cpp new file mode 100644 index 00000000..503b93fa --- /dev/null +++ b/test/gtx/rotate_vector.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/safe_limits.cpp b/test/gtx/safe_limits.cpp new file mode 100644 index 00000000..f56df64f --- /dev/null +++ b/test/gtx/safe_limits.cpp @@ -0,0 +1,12 @@ +#include "../precompiled.hpp" +#include +//#include + +namespace glm +{ + namespace test + { + + } +} + diff --git a/test/gtx/spline.cpp b/test/gtx/spline.cpp new file mode 100644 index 00000000..90ae2eab --- /dev/null +++ b/test/gtx/spline.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/statistics_operation.cpp b/test/gtx/statistics_operation.cpp new file mode 100644 index 00000000..56c3e744 --- /dev/null +++ b/test/gtx/statistics_operation.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/std_based_type.cpp b/test/gtx/std_based_type.cpp new file mode 100644 index 00000000..651997ce --- /dev/null +++ b/test/gtx/std_based_type.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/string_cast.cpp b/test/gtx/string_cast.cpp new file mode 100644 index 00000000..f7a6f645 --- /dev/null +++ b/test/gtx/string_cast.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/transform.cpp b/test/gtx/transform.cpp new file mode 100644 index 00000000..5af0d87f --- /dev/null +++ b/test/gtx/transform.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/transform2.cpp b/test/gtx/transform2.cpp new file mode 100644 index 00000000..ffb9550c --- /dev/null +++ b/test/gtx/transform2.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/transpose.cpp b/test/gtx/transpose.cpp new file mode 100644 index 00000000..93e08a0b --- /dev/null +++ b/test/gtx/transpose.cpp @@ -0,0 +1,10 @@ +#include "../precompiled.hpp" +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/unsigned_int.cpp b/test/gtx/unsigned_int.cpp new file mode 100644 index 00000000..f35bf67c --- /dev/null +++ b/test/gtx/unsigned_int.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/vector_access.cpp b/test/gtx/vector_access.cpp new file mode 100644 index 00000000..7a7a4270 --- /dev/null +++ b/test/gtx/vector_access.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/vector_angle.cpp b/test/gtx/vector_angle.cpp new file mode 100644 index 00000000..babfcd10 --- /dev/null +++ b/test/gtx/vector_angle.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/vector_query.cpp b/test/gtx/vector_query.cpp new file mode 100644 index 00000000..711d8d33 --- /dev/null +++ b/test/gtx/vector_query.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/vecx.cpp b/test/gtx/vecx.cpp new file mode 100644 index 00000000..35b8d13f --- /dev/null +++ b/test/gtx/vecx.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +//#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/gtx/verbose_operator.cpp b/test/gtx/verbose_operator.cpp new file mode 100644 index 00000000..e23b8129 --- /dev/null +++ b/test/gtx/verbose_operator.cpp @@ -0,0 +1,11 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm +{ + namespace test + { + + } +} diff --git a/test/header.cpp b/test/header.cpp new file mode 100644 index 00000000..c59d2fc3 --- /dev/null +++ b/test/header.cpp @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +//#include +//#include +//#include + +//#ifdef GCC + +//template +//< +// std::size_t N, +// typename T, +// template +// < +// std::size_t, +// typename +// > class C +//> +//struct trait +//{ +// typedef T value_type; +// typedef std::size_t size_type; +// static size_type const value_size; +//}; +// +//template +//< +// std::size_t N, +// typename T, +// template +// < +// std::size_t N2, +// typename T2 +// > class C +//> +//typename trait::size_type const trait::value_size = N; +// +//template +//struct base : public trait +//{ +// typename trait::value_type Data[trait::value_size]; +//}; +// +//template +//struct base<4, T> : public trait<4, T, base> +//{ +// value_type Data[value_size]; +//}; + +template +struct test +{ + struct mem + { + T data; + }; +}; + +#if(defined(GLM_COMPILER) && !(GLM_COMPILER & GLM_COMPILER_VC)) +int main() +{ + glm::quat q1 = glm::angleAxis(45.f, glm::vec3(0, 0, 1)); +} +#endif//(GLM_COMPILER == GLM_COMPILER_VC) +//#endif//GCC \ No newline at end of file diff --git a/test/img.cpp b/test/img.cpp new file mode 100644 index 00000000..a3195fb4 --- /dev/null +++ b/test/img.cpp @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-10-27 +// Updated : 2009-10-27 +// Licence : This source is under MIT License +// File : test/glm/img.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "img.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_img() + { + bool Success = true; + + Success = Success && main_img_multiple(); + assert(Success); + + Success = Success && main_img_wrap(); + assert(Success); + + return Success; + } + +}//namespace test +}//namespace glm diff --git a/test/img.hpp b/test/img.hpp new file mode 100644 index 00000000..0b18a205 --- /dev/null +++ b/test/img.hpp @@ -0,0 +1,24 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-10-27 +// Updated : 2009-10-27 +// Licence : This source is under MIT License +// File : test/glm/img.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_test_img +#define glm_test_img + +namespace glm{ +namespace test +{ + bool main_img(); + +}//namespace test +}//namespace glm + +#endif//glm_test_img diff --git a/test/img/multiple.cpp b/test/img/multiple.cpp new file mode 100644 index 00000000..fb456698 --- /dev/null +++ b/test/img/multiple.cpp @@ -0,0 +1,127 @@ +#include "../precompiled.hpp" +#include +#include + +namespace glm{ +namespace test +{ + bool main_img_multiple() + { + bool Success = true; + + { + glm::detail::thalf Source(24.f); + glm::detail::thalf Multiple(16.f); + + glm::detail::thalf Value = glm::higherMultiple(Source, Multiple); + float ExpectedResult(32.f); + float ValueFloat = Value; + + Success = Success && ExpectedResult == ValueFloat; + assert(Success); + } + + { + float Source(24.f); + float Multiple(16.f); + + float Value = glm::higherMultiple(Source, Multiple); + float ExpectedResult(32.f); + + Success = Success && ExpectedResult == Value; + assert(Success); + } + + { + glm::ivec4 Source(16, 24, 47, 65); + glm::ivec4 Multiple(16); + + glm::ivec4 Value = glm::higherMultiple(Source, Multiple); + glm::ivec4 ExpectedResult(16, 32, 48, 80); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::vec2 Source(16, 24); + glm::vec2 Multiple(16); + + glm::vec2 Value = glm::higherMultiple(Source, Multiple); + glm::vec2 ExpectedResult(16, 32); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::vec3 Source(16, 24, 47); + glm::vec3 Multiple(16); + + glm::vec3 Value = glm::higherMultiple(Source, Multiple); + glm::vec3 ExpectedResult(16, 32, 48); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::vec4 Source(16, 24, 47, 65); + glm::vec4 Multiple(16); + + glm::vec4 Value = glm::higherMultiple(Source, Multiple); + glm::vec4 ExpectedResult(16, 32, 48, 80); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::ivec4 Source(16, 24, 47, 65); + glm::ivec4 Multiple(16); + + glm::ivec4 Value = glm::lowerMultiple(Source, Multiple); + glm::ivec4 ExpectedResult(16, 16, 32, 64); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::vec2 Source(16, 24); + glm::vec2 Multiple(16); + + glm::vec2 Value = glm::lowerMultiple(Source, Multiple); + glm::vec2 ExpectedResult(16, 16); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::vec3 Source(16, 24, 47); + glm::vec3 Multiple(16); + + glm::vec3 Value = glm::lowerMultiple(Source, Multiple); + glm::vec3 ExpectedResult(16, 16, 32); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + { + glm::vec4 Source(16, 24, 47, 65); + glm::vec4 Multiple(16); + + glm::vec4 Value = glm::lowerMultiple(Source, Multiple); + glm::vec4 ExpectedResult(16, 16, 32, 64); + + Success = Success && glm::all(glm::equal(ExpectedResult, Value)); + assert(Success); + } + + return Success; + } + +}//namespace test +}//namespace glm diff --git a/test/img/wrap.cpp b/test/img/wrap.cpp new file mode 100644 index 00000000..ce7caadb --- /dev/null +++ b/test/img/wrap.cpp @@ -0,0 +1,141 @@ +//#include "../precompiled.hpp" +#include "../../glm/glm.hpp" +#include "../../glm/gtc/half_float.hpp" +#include "../../glm/gtc/double_float.hpp" +#include "../../glm/img/wrap.hpp" + +namespace glm{ +namespace test +{ + static float const epsilon = 0.001f; + + bool main_img_wrap() + { + bool Success = true; + + // mirrorRepeat + { + float A = mirrorRepeat(0.0f); // 0.0f + Success = Success && (A - 0.0f) < epsilon; + assert(Success); + + float B = mirrorRepeat(0.2f); // 0.2f + Success = Success && (B - 0.2f) < epsilon; + assert(Success); + + float C = mirrorRepeat(0.5f); // 0.5f + Success = Success && (C - 0.5f) < epsilon; + assert(Success); + + float D = mirrorRepeat(1.0f); // 1.0f + Success = Success && (D - 1.0f) < epsilon; + assert(Success); + + float E = mirrorRepeat(1.2f); // 0.8f + Success = Success && (E - 0.8f) < epsilon; + assert(Success); + + float F = mirrorRepeat(1.5f); // 0.5f + Success = Success && (F - 0.5f) < epsilon; + assert(Success); + + float G = mirrorRepeat(1.6f); // 0.4f + Success = Success && (G - 0.4f) < epsilon; + assert(Success); + + float H = mirrorRepeat(2.0f); // 0.0f + Success = Success && (H - 0.0f) < epsilon; + assert(Success); + + float I = mirrorRepeat(2.1f); // 0.1f + Success = Success && (I - 0.1f) < epsilon; + assert(Success); + + float J = mirrorRepeat(3.0f); // 1.0f + Success = Success && (J - 1.0f) < epsilon; + assert(Success); + + float K = mirrorRepeat(3.9f); // 0.1f + Success = Success && (K - 0.1f) < epsilon; + assert(Success); + + float L = mirrorRepeat(4.2f); // 0.2f + Success = Success && (L - 0.2f) < epsilon; + assert(Success); + + float M = mirrorRepeat(3.9f); // 0.1f + Success = Success && (M - 0.1f) < epsilon; + assert(Success); + + float N = mirrorRepeat(4.2f); // 0.2f + Success = Success && (N - 0.2f) < epsilon; + assert(Success); + + float O = mirrorRepeat(5.2f); // 0.8f + Success = Success && (O - 0.8f) < epsilon; + assert(Success); + + float P = mirrorRepeat(5.8f); // 0.2f + Success = Success && (P - 0.2f) < epsilon; + assert(Success); + + float Q = mirrorRepeat(6.2f); // 0.2f + Success = Success && (Q - 0.2f) < epsilon; + assert(Success); + + float R = mirrorRepeat(6.8f); // 0.8f + Success = Success && (R - 0.8f) < epsilon; + assert(Success); + + float S = mirrorRepeat(7.0f); // 1.0f + Success = Success && (S - 1.0f) < epsilon; + assert(Success); + } + + { + glm::vec2 A = mirrorRepeat(glm::vec2(0.0f)); // 0.0f + Success = Success && glm::all(glm::lessThan((A - 0.0f), glm::vec2(epsilon))); + assert(Success); + + glm::vec3 B = mirrorRepeat(glm::vec3(0.2f)); // 0.2f + Success = Success && glm::all(glm::lessThan((B - 0.2f), glm::vec3(epsilon))); + assert(Success); + + glm::vec4 C = mirrorRepeat(glm::vec4(1.2f)); // 0.8f + Success = Success && glm::all(glm::lessThan((C - 0.8f), glm::vec4(epsilon))); + assert(Success); + } + + { + glm::hvec2 A = mirrorRepeat(glm::hvec2(0.0f)); // 0.0f + Success = Success && glm::all(glm::lessThan((A - glm::half(0.0f)), glm::hvec2(epsilon))); + assert(Success); + + glm::hvec3 B = mirrorRepeat(glm::hvec3(0.2f)); // 0.2f + Success = Success && glm::all(glm::lessThan((B - glm::half(0.2f)), glm::hvec3(epsilon))); + assert(Success); + + glm::hvec4 C = mirrorRepeat(glm::hvec4(1.2f)); // 0.8f + Success = Success && glm::all(glm::lessThan((C - glm::half(0.8f)), glm::hvec4(epsilon))); + assert(Success); + } + + { + glm::dvec2 A = mirrorRepeat(glm::dvec2(0.0f)); // 0.0f + Success = Success && glm::all(glm::lessThan((A - double(0.0f)), glm::dvec2(epsilon))); + assert(Success); + + glm::dvec3 B = mirrorRepeat(glm::dvec3(0.2f)); // 0.2f + Success = Success && glm::all(glm::lessThan((B - double(0.2f)), glm::dvec3(epsilon))); + assert(Success); + + glm::dvec4 C = mirrorRepeat(glm::dvec4(1.2f)); // 0.8f + Success = Success && glm::all(glm::lessThan((C - double(0.8f)), glm::dvec4(epsilon))); + assert(Success); + } + + return Success; + } + +}//namespace test +}//namespace glm diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 00000000..c0ba48ff --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,2313 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-01-12 +// Updated : 2006-12-03 +// Licence : This source is under MIT License +// File : main.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "precompiled.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core.hpp" +#include "img.hpp" +#include "gtc.hpp" +#include "gtx.hpp" + +#include + +//namespace glm +//{ + // using GLM_GTX_double_float; + // using GLM_GTX_inverse; + // using GLM_GTX_integer; + // using GLM_GTX_unsigned_int; + //using GLM_GTX_bit; +// using GLM_GTX_fast_square_root; +// using GLM_GTX_number_precision; +// using GLM_GTX_color_cast; +// using GLM_GTX_quaternion; +// using GLM_GTX_inverse_transpose; +// using GLM_GTX_transform; +// using GLM_GTX_transform2; +// using GLM_GTX_intersect; +// using GLM_GTX_random; +// using GLM_GTX_gradient_paint; +// using GLM_GTX_perpendicular; + //using GLM_GTX_compatibility; + //using GLM_GTX_quaternion; + //using GLM_GTX_string_cast; + //using GLM_GTX_fast_square_root; + //using GLM_GTX_half_float; + //using GLM_GTX_vector_angle; + //using GLM_GTX_matrix_projection; +//} + +unsigned int GetCpuCycle() +{ + unsigned int LowWord = 0; + unsigned int HighWord = 0; +// _asm +// { +// cpuid +// // Insert Real Time Stamp Counter opcodes +// _emit 0x0F +// _emit 0x31 +// mov HighWord, edx +// mov LowWord, eax +// } +// return ((__int64)(HighWord) << 32) + LowWord; + return 0; +} + + +//namespace wip +//{ +// inline glm::detail::fvec4SIMD rcp(glm::detail::fvec4SIMD const & v) +// { +// return glm::detail::fvec4SIMD(_mm_rcp_ps(v.Data)); +// } +// +// inline glm::detail::fvec4SIMD sqrt(glm::detail::fvec4SIMD const & v) +// { +// return glm::detail::fvec4SIMD(_mm_sqrt_ps(v.Data)); +// } +// +// inline glm::detail::fvec4SIMD inversesqrt(glm::detail::fvec4SIMD const & v) +// { +// return glm::detail::fvec4SIMD(_mm_rsqrt_ps(v.Data)); +// } +// +// inline glm::detail::fvec4SIMD min(glm::detail::fvec4SIMD const & v1, glm::detail::fvec4SIMD const & v2) +// { +// return glm::detail::fvec4SIMD(_mm_min_ps(v1.Data, v2.Data)); +// } +// +// inline glm::detail::fvec4SIMD max(glm::detail::fvec4SIMD const & v1, glm::detail::fvec4SIMD const & v2) +// { +// return glm::detail::fvec4SIMD(_mm_max_ps(v1.Data, v2.Data)); +// } +//}//namespace wip + +void test_simd() +{ + glm::detail::fvec4SIMD v1(1.0f, 2.0f, 3.0f, 4.0f); + glm::detail::fvec4SIMD v2(5.0f, 6.0f, 7.0f, 8.0f); + + bool end = true; +} + +namespace a +{ + namespace b{} +} + +namespace c = a::b; + +//#include + +#include +#include +#include +//#include + +//#include + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +//#include "test/sse_vec4.h" +//#include "test/sse_mat4.h" + +/* +inline float fastExp0(float x) +{ + return 1.0f + x + (x * x * 0.5f) + (x * x * x * 0.1666666667f) + (x * x * x * x * 0.041666667f) + (x * x * x * x * x * 0.008333333333f) + (x * x * x * x * x * x * 0.00138888888888f) + (x * x * x * x * x * x * x * 0.000198412698f) + (x * x * x * x * x * x * x * x * 0.0000248015873f); +} + +inline float fastExp1(float x) +{ + float x2 = x * x; + float x3 = x2 * x; + float x4 = x3 * x; + float x5 = x4 * x; + float x6 = x5 * x; + float x7 = x6 * x; + float x8 = x7 * x; + return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f) + (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f); +} + +inline float fastExp2(float x) +{ + float x2 = x * x; + float x3 = x2 * x; + float x4 = x3 * x; + float x5 = x4 * x; + return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f); +} + +inline float fastExp3(float x) +{ + return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); +} + +inline float fastExp4(float x) +{ + if(x >= 0.0f && x <= 1.0f) + { + float x2 = x * x; + float x3 = x2 * x; + float x4 = x3 * x; + float x5 = x4 * x; + return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f); + } + else + { + float e = 2.718281828f; + float IntegerPart = glm::floor(x); + float FloatPart = x - IntegerPart; + float z = e; + + for(int i = 1; i < int(IntegerPart); ++i) + z *= e; + + float x2 = FloatPart * FloatPart; + float x3 = x2 * FloatPart; + float x4 = x3 * FloatPart; + float x5 = x4 * FloatPart; + return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)); + } +} + +__forceinline float fastExp5(float x) +{ + const float e = 2.718281828f; + const float IntegerPart = glm::floor(x); + const float FloatPart = x - IntegerPart; + float z = 1.f; + + //for(int i = 0; i < int(IntegerPart); ++i) + // z *= e; + + const float x2 = FloatPart * FloatPart; + const float x3 = x2 * FloatPart; + const float x4 = x3 * FloatPart; + const float x5 = x4 * FloatPart; + return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)); +} + +inline float fastLn0(float x) +{ + float y1 = (x - 1.0f) / (x + 1.0f); + float y2 = y1 * y1; + float y4 = y2 * y2; + float y6 = y4 * y2; + float y8 = y4 * y4; + return 2.0f * y1 * (1.0f + y2 * 0.3333333333f + y4 * 0.2f + y6 * 0.1428571429f);// + y8 * 0.1111111111f); +} + +inline float fastLn1(float x) +{ + float y1 = (x - 1.0f) / (x + 1.0f); + float y2 = y1 * y1; + return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f))); +} +*/ + +using namespace std; +using namespace glm; + +void subtitiution() +{ + //-------------------------------------------------------------------- + //AX=B + mat4 L(0.f); + mat4 U(0.f); + mat4 A = mat4( + vec4(4.f), + vec4(4.f), + vec4(4.f), + vec4(4.f)); + + for(int i=0;i < 4;i++) + for(int j=0;j < 4;j++) + { + if(i>j) + U[i][j]=0; + else if(i==j) + L[i][j]=1; + else + L[i][j]=0; + } + + printf("A:\n"); + for(int j = 0; j < 4; ++j) + { + printf("("); + for(int i = 0; i < 4; ++i) + printf("%f ", A[j][i]); + printf(")\n"); + } + printf("\n"); + + //Decomposition of A into L and U + for(int i = 0; i < 4; ++i) + for(int j = 0; j < 4; ++j) + { + float Sum = 0.f; + if(i <= j) + { + for(int k = 0; k < 4; ++k) + if(k != i) + Sum += L[i][k] * U[k][j]; + U[i][j] = (A[i][j] - Sum);// / U[j][j]; + } + else + { + for(int k = 0; k < 4; k++) + if(k != j) + Sum += L[i][k] * U[k][j]; + L[i][j] = (A[i][j] - Sum) / U[j][j]; + } + } + + printf("L:\n"); + for(int j = 0; j < 4; ++j) + { + printf("("); + for(int i = 0; i < 4; ++i) + printf("%f ", L[j][i]); + printf(")\n"); + } + printf("\n"); + + printf("U:\n"); + for(int j = 0; j < 4; ++j) + { + printf("("); + for(int i = 0; i < 4; ++i) + printf("%f ", U[j][i]); + printf(")\n"); + } + printf("\n"); + + system("pause"); +} + +void LUDecompsition( + const detail::tmat4x4& m, + detail::tmat4x4& l, + detail::tmat4x4& u) +{ + for(int i = 0; i < 4; ++i) + l[i][i] = 1.f; + + for(int j = 0; j < 4; ++j) + { + //for(int i = 0; i <= j; ++i) + for(int i = 0; i < j; ++i) + { + u[j][i] = m[j][i]; + for(int k = 0; k < i - 1; ++k) + //for(int k = 0; k < i; ++k) + u[j][i] -= l[k][i] * u[j][k]; + } + //for(int i = j + 1; i < 4; ++i) + for(int i = j; i < 4; ++i) + { + l[j][i] = m[j][i]; + for(int k = 0; k < j - 1; ++k) + //for(int k = 0; k < j; ++k) + l[j][i] -= l[k][i] * u[j][k]; + } + } +} + +/* +ivec3& operator+=(const ivec3& v, const int s) +{ + ivec3 Result = v; + Result.x &= s; + Result.y &= s; + Result.z &= s; + return Result; +} +*/ + +void g() +{ + mat4 m = glm::inverse(mat4(4.0f)); +} + +void test_gtx_bit() +{ + int Number1 = 76; + int NumberA = glm::highestBit(Number1); + int NumberB = glm::highestBitValue(Number1); + bool NumberC = glm::isPowerOfTwo(Number1); + int NumberD = glm::powerOfTwoAbove(Number1); + int NumberE = glm::powerOfTwoBelow(Number1); + int NumberF = glm::powerOfTwoNearest(Number1); + + int Number2 = 256; + int NumberG = glm::highestBit(Number2); + int NumberH = glm::highestBitValue(Number2); + bool NumberI = glm::isPowerOfTwo(Number2); + int NumberJ = glm::powerOfTwoAbove(Number2); + int NumberK = glm::powerOfTwoBelow(Number2); + int NumberL = glm::powerOfTwoNearest(Number2); + + int NumberZ = 0; +} +/* +struct gni +{ + void constructor(short i) + { + data = i; + } + + gni& assignement(const gni& i) + { + data = i.data; + return *this; + } + + short data; +} + +union pouet +{ + pouet(detail::thalf x, detail::thalf y, detail::thalf z) : + x(x), y(y), z(z) + {} + + struct{detail::thalf x, y, z;}; + struct{detail::thalf r, g, b;}; + struct{detail::thalf s, t, q;}; +}; +*/ + +//#include GLM_EXTENSION(GLM_GTX_compatibility, glm::required); + +vec4 mix_fpu(const vec4& x, const vec4& y, const vec4& a) +{ + return x * (vec4(1) - a) + y * a; +} + +/* +namespace glm +{ + template + struct traits + { + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef std::size_t size_type; + static const size_type value_size; + }; + + template + static const traits::size_type traits::value_size = N; + + template + struct traits + { + typedef Type value_type; + typedef Type* pointer; + typedef Type& reference; + }; + + template + struct traits + { + typedef Type value_type; + typedef const Type* pointer; + typedef const Type& reference; + }; +} +*/ + +vec2 reference_swizzle(const vec3& a, const vec3& b) +{ + return vec2(0.0f); +} + +//void test_random() +//{ +// float Value = gaussRand1GTX(1.0f, 2.0f); +// detail::_xvecxGTX<8, float> vecN; +// vecN = compRandGTX(vecN, vecN); +//} + +void test_matrix() +{ +// glm::mat4 Transform = glm::translateGTX( +// glm::rotateGTX(45.f, glm::core::func_geometric::normalize(glm::vec3(1))), glm::vec3(1, 2, 3)); + glm::vec3 Normalized = glm::normalize(glm::vec3(1)); + + glm::mat4 Transform = glm::gtc::matrix_transform::translate( + glm::gtc::matrix_transform::rotate(glm::mat4(1.0f), 45.f, Normalized), + glm::vec3(1, 2, 3)); + glm::mat4 TransformA = glm::inverse(Transform); + glm::mat4 TransformB = glm::affineInverse(Transform); + glm::mat4 End; +} + +void test_vec4() +{ + { + glm::vec4 v(1.0); + glm::vec4 const* const pv = &v; + glm::vec4 const& rv = v; + + //float const* pointer1 = &v; + //float const* pointer2 = v; + //float const* pointer3 = pv; + //float const* pointer4 = &rv; + //glm::vec4* p = &v; + //glm::vec4 v6 = v + long(3); + + float const* pointer1 = &v[0]; + } + //{ + // glm::mat4 m; + // glm::mat4 const* const pm = &m; + // glm::mat4 const& rm = m; + + // float const* pointer1 = &m; + // float const* pointer2 = m; + // float const* pointer3 = pm; + // float const* pointer4 = &rm; + //} +} + +void test_mat4(const glm::mat4& m) +{ + //glm::mat4 copy = m; + //glLoadMatrix(GL_MODELVIEW, copy); +} + +void test_string_cast() +{ + printf("Test string cast: %s\n", glm::string(glm::vec4(1, 2, 3, 4)).c_str()); +} + +void test_isPowerOfTwo() +{ + bool resultA = glm::isPowerOfTwo(unsigned(512)); + bool resultB = glm::isPowerOfTwo(unsigned(513)); + bool end = true; +} + +//#include +// +//void test_opengl_wrapper() +//{ +// glVertex(glm::vec3(1.0f)); +//} + +void fast_inverse() +{ + float one = fastInverseSqrt(1.0f); + float two = fastInverseSqrt(2.0f); + float result = 1.0f; +} + +//void test_desk() +//{ +// typedef glm::detail::desc::value_type vec4_type; +// vec4_type Test(1.0f); +// +// glm::detail::desc::size_type Size = glm::detail::desc::value_size(); +// +// int end = 0; +//} + +//template +//genType TemplateFuncMin(const genType& Type1, const genType& Type2) +//{ +// genType Result; +// for +// ( +// glm::detail::desc::size_type i = glm::detail::desc::size_type(0); +// i < glm::detail::desc::value_size; +// ++i +// ) +// { +// Result[i] = Type1[i] < Type2[i] ? Type1[i] : Type2[i]; +// } +// +// return Result; +//} +// +//void test_genType() +//{ +// glm::vec1 Result1 = TemplateFuncMin(glm::vec1(1), glm::vec1(2)); +//// float ResultF = TemplateFuncMin(1.f, 2.f); +// vec4 Result4 = TemplateFuncMin(glm::vec4(1), glm::vec4(2)); +// +// bool end = true; +//} + +namespace test_ac +{ + struct C1 + { + C1() : + data(76) + {} + + int data; + }; + + struct C2 + { + C2(){} + C2(const C1& c1) : + data(c1.data) + {} + + int data; + }; + + C2 operator+ (const C2& a, const C2& b) + { + C2 result; + result.data = a.data + b.data; + return result; + } + +} + +void test_auto_cast() +{ + test_ac::C1 c1; + test_ac::C2 c2 = c1; + test_ac::C2 c3 = c2 + c1; + +// +// glm::vec3 Data = glm::vec2(1.f)._yxy(); +} + +template +genType abs(const genType& v) +{ + genType Result; + for(typename genType::size_type i = 0; i < genType::size_value; ++i) + Result[i] = Result[i] < typename genType::value_type(0) ? -Result[i] : Result[i]; + return Result; +} + +void test_quaternion() +{ + glm::vec3 tan(1.0f); + glm::quat q; + tan = glm::cross(q, tan); +} + +void test_swizzle() +{ + glm::vec2 a(1, 2); + glm::vec4 b = a.swizzle(X, Y, X, Y); + glm::vec4 c(0); + c.swizzle(X, Y, Z, W) = b.swizzle(X, Y, Z, W); + + //a.xyz = b.xyz; + + bool end = true; +} + +void test_angle() +{ + //float angle1 = glm::angle(0.1f, 0.2f); + float angle2 = glm::angle(glm::vec2(0.1f), glm::vec2(0.2f)); + + return; +} + +void test_half() +{ + hmat2 hmatrix1(half(1.f)); + hmat2 hmatrix2(half(2.f)); + hmat2 hmatrix3 = hmatrix1 + hmatrix2; + half hscalar = hmatrix3[0].x; + double fscalar = hscalar; + + hvec2::size_type Size = hvec2::value_size(); + + return; +} + +template +valType func_profile(glm::detail::tvec3 const & x, valType y) +{ + return glm::dot(x, glm::detail::tvec3(y)); +} + +template <> +float func_profile(glm::vec3 const & x, float y) +{ + return glm::dot(x, glm::vec3(y)); +} + +void test_profile() +{ + + +} + +//template +//class TestType +//{ +//public: +// TestType(valType const & x); +//}; +// +//template +//TestType::TestType(valType const & x) +//{} +// +//template +//class TestType +//{ +//public: +// TestType(valType const & x); +//}; +// +//template +//TestType::TestType(valType const & x) +//{} +// +//typedef TestType _vec4; +// +//void test_type() +//{ +// _vec4 v(1.0); +//} + +void test_fast_inverse() +{ + printf("fastInvSqrt(1.0f) : %f\n", fastInverseSqrt(1.0f)); + printf("fastInvSqrt(1.0f) : %f\n", inversesqrt(1.0f)); + printf("fastInvSqrt(76.0f) : %f\n", fastInverseSqrt(76.f)); + printf("fastInvSqrt(76.0f) : %f\n", inversesqrt(76.f)); + printf("fastInvSqrt(0.01f) : %f\n", fastInverseSqrt(0.01f)); + printf("fastInvSqrt(0.01f) : %f\n", inversesqrt(0.01f)); +} + +namespace ns_hint +{ + struct hint + {}; + + struct see : public hint + {}; + + struct see2 : public see + {}; + + template + vecType func(vecType const & v, hint) + { + return v * v; + } + + template + vecType func(vecType const & v, see2) + { + return v * v; + } + + template + struct vec4 + { + vec4() + { + int i = 0; + } + + valType data; + }; + + template + struct vec4 + { + vec4() + { + int i = 0; + } + + valType data; + }; + + //enum hint + //{ + // fast, + // nice, + // see, + // see2, + // see3, + // see4 + //}; + + //template + //vecType func(vecType const & v); + + //template + //struct functor + //{ + // template + // vecType operator() (vecType const & v) const + // { + // return v * v; + // } + //}; +} + +void test_hint() +{ + glm::vec3 v1 = glm::vec3(2.0f); + glm::vec3 v2 = ns_hint::func(v1, ns_hint::see()); +// ns_hint::vec4 v3; +// ns_hint::vec4 v4; + //glm::vec3 v2 = ns_hint::functor()(v1); + //glm::vec3 v2 = hint::func(v1); +} + +void test_const_call +( + glm::mat4 const & m, + glm::vec4 const & v +) +{ + float const & Value = m[0][0]; + glm::vec4 const & Vector = m[0]; + float const & VecRef = v[0]; + + float const * const ValuePtr = &m[0][0]; + glm::vec4 const * const VectorPtr = &m[0]; + float const * VecPtr = &v[0]; +} + +void test_const() +{ + test_const_call( + glm::mat4(1.0), + glm::vec4(1.0)); +} + +void test_transform() +{ + glm::vec2 QMin(-1024,+1024); + //glm::vec2 QMax(+1024,-1024); + glm::vec2 QMax(-1024 + 640, 1024); + + std::size_t const ValueSize = 6; + glm::vec3 ValueOut[ValueSize]; + glm::vec3 ValueData[ValueSize]; + ValueData[0] = glm::vec3(QMin.x, QMin.y, 1);//(0, 0) + ValueData[1] = glm::vec3(QMax.x, QMin.y, 1);//(1, 0) + ValueData[2] = glm::vec3(QMax.x, QMax.y, 1);//(1, 1) + ValueData[3] = glm::vec3(QMin.x, QMax.y, 1);//(0, 1) + ValueData[4] = glm::vec3(QMin.x, QMax.y / 4.f, 1);//(0, 0.25f) + ValueData[5] = glm::vec3(QMin.x / 4.f, QMax.y, 1);//(0.25f, 0.25f) + + glm::mat3 Q2Norm(1.0f); + Q2Norm[0] = glm::vec3( + 1.0f / (QMax.x - QMin.x), + 0.0f, + 0.0f); + Q2Norm[1] = glm::vec3( + 0.0f, + 1.0f / (QMax.y - QMin.y), + 0.0f); + Q2Norm[2] = glm::vec3( + - QMin.x / (QMax.x - QMin.x), + - QMin.y / (QMax.y - QMin.y), + 1.0f); + + glm::vec2 FBMin(0, 0); + glm::vec2 FBMax(640, 480); + glm::mat3 Norm2FB(1.0f); + Norm2FB[0] = glm::vec3(FBMax.x - FBMin.x, 0, 0); + Norm2FB[1] = glm::vec3(0, FBMax.y - FBMin.y, 0); + Norm2FB[2] = glm::vec3(0, 0, 1); + + for(std::size_t i = 0; i < ValueSize; ++i) + ValueOut[i] = Norm2FB * Q2Norm * ValueData[i]; + + bool End = true; +} + +//namespace +//{ +// template +// valType radialGradient( +// glm::detail::tvec2 const & Center, +// valType const & Radius, +// glm::detail::tvec2 const & Focal, +// glm::detail::tvec2 const & Position) +// { +// glm::detail::tvec2 F = Focal - Center; +// glm::detail::tvec2 D = Position - Focal; +// +// valType Numerator = (D.x * F.x + D.y * F.y) + glm::sqrt((Radius * Radius) * (D.x * D.x + D.y * D.y) - (D.x * F.y - D.y * F.x) * (D.x * F.y - D.y * F.x)); +// valType Denominator = (Radius * Radius) - (F.x * F.x + F.y * F.y); +// return Numerator / Denominator; +// } +//} + +void test_radial() +{ + glm::vec2 Center(0); + float Radius = 1.0f; + glm::vec2 Focal(0); + glm::vec2 PositionA(0); + glm::vec2 PositionB(0, 1); + glm::vec2 PositionC(1, 0); + glm::vec2 PositionD(0.5f, 0.0f); + + float GradA = glm::radialGradient(Center, Radius, Focal, PositionA); + float GradB = glm::radialGradient(Center, Radius, Focal, PositionB); + float GradC = glm::radialGradient(Center, Radius, Focal, PositionC); + float GradD = glm::radialGradient(Center, Radius, Focal, PositionD); + + bool End = true; +} + +void test_quat() +{ + glm::quat q1(1.0f, glm::vec3(0)); + float Roll = glm::roll(q1); +} +// +//void _mm_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]) +//{ +// { +// out[0] = _mm_add_ps(in1[0], in2[0]); +// out[1] = _mm_add_ps(in1[1], in2[1]); +// out[2] = _mm_add_ps(in1[2], in2[2]); +// out[3] = _mm_add_ps(in1[3], in2[3]); +// } +//} +// +//void _mm_sub_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]) +//{ +// { +// out[0] = _mm_sub_ps(in1[0], in2[0]); +// out[1] = _mm_sub_ps(in1[1], in2[1]); +// out[2] = _mm_sub_ps(in1[2], in2[2]); +// out[3] = _mm_sub_ps(in1[3], in2[3]); +// } +//} +// +//inline __m128 _mm_mul_ps(__m128 m[4], __m128 v) +//{ +// __m128 v0 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 v1 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 v2 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 v3 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 m0 = _mm_mul_ps(m[0], v0); +// __m128 m1 = _mm_mul_ps(m[1], v1); +// __m128 m2 = _mm_mul_ps(m[2], v2); +// __m128 m3 = _mm_mul_ps(m[3], v3); +// +// __m128 a0 = _mm_add_ps(m0, m1); +// __m128 a1 = _mm_add_ps(m2, m3); +// __m128 a2 = _mm_add_ps(a0, a1); +// +// return a2; +//} +// +//inline __m128 _mm_mul_ps(__m128 v, __m128 m[4]) +//{ +// __m128 i0 = m[0]; +// __m128 i1 = m[1]; +// __m128 i2 = m[2]; +// __m128 i3 = m[3]; +// +// __m128 m0 = _mm_mul_ps(v, i0); +// __m128 m1 = _mm_mul_ps(v, i1); +// __m128 m2 = _mm_mul_ps(v, i2); +// __m128 m3 = _mm_mul_ps(v, i3); +// +// __m128 u0 = _mm_unpacklo_ps(m0, m1); +// __m128 u1 = _mm_unpackhi_ps(m0, m1); +// __m128 a0 = _mm_add_ps(u0, u1); +// +// __m128 u2 = _mm_unpacklo_ps(m2, m3); +// __m128 u3 = _mm_unpackhi_ps(m2, m3); +// __m128 a1 = _mm_add_ps(u2, u3); +// +// __m128 f0 = _mm_movelh_ps(a0, a1); +// __m128 f1 = _mm_movehl_ps(a1, a0); +// __m128 f2 = _mm_add_ps(f0, f1); +// +// return f2; +//} +// +//inline void _mm_mul_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]) +//{ +// glm::uint64 TimeStart = GetCpuCycle(); +// +// { +// __m128 e0 = _mm_shuffle_ps(in2[0], in2[0], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 e1 = _mm_shuffle_ps(in2[0], in2[0], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 e2 = _mm_shuffle_ps(in2[0], in2[0], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 e3 = _mm_shuffle_ps(in2[0], in2[0], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 m0 = _mm_mul_ps(in1[0], e0); +// __m128 m1 = _mm_mul_ps(in1[1], e1); +// __m128 m2 = _mm_mul_ps(in1[2], e2); +// __m128 m3 = _mm_mul_ps(in1[3], e3); +// +// __m128 a0 = _mm_add_ps(m0, m1); +// __m128 a1 = _mm_add_ps(m2, m3); +// __m128 a2 = _mm_add_ps(a0, a1); +// +// out[0] = a2; +// } +// +// { +// __m128 e0 = _mm_shuffle_ps(in2[1], in2[1], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 e1 = _mm_shuffle_ps(in2[1], in2[1], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 e2 = _mm_shuffle_ps(in2[1], in2[1], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 e3 = _mm_shuffle_ps(in2[1], in2[1], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 m0 = _mm_mul_ps(in1[0], e0); +// __m128 m1 = _mm_mul_ps(in1[1], e1); +// __m128 m2 = _mm_mul_ps(in1[2], e2); +// __m128 m3 = _mm_mul_ps(in1[3], e3); +// +// __m128 a0 = _mm_add_ps(m0, m1); +// __m128 a1 = _mm_add_ps(m2, m3); +// __m128 a2 = _mm_add_ps(a0, a1); +// +// out[1] = a2; +// } +// +// { +// __m128 e0 = _mm_shuffle_ps(in2[2], in2[2], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 e1 = _mm_shuffle_ps(in2[2], in2[2], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 e2 = _mm_shuffle_ps(in2[2], in2[2], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 e3 = _mm_shuffle_ps(in2[2], in2[2], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 m0 = _mm_mul_ps(in1[0], e0); +// __m128 m1 = _mm_mul_ps(in1[1], e1); +// __m128 m2 = _mm_mul_ps(in1[2], e2); +// __m128 m3 = _mm_mul_ps(in1[3], e3); +// +// __m128 a0 = _mm_add_ps(m0, m1); +// __m128 a1 = _mm_add_ps(m2, m3); +// __m128 a2 = _mm_add_ps(a0, a1); +// +// out[2] = a2; +// } +// +// { +// //(__m128&)_mm_shuffle_epi32(__m128i&)in2[0], _MM_SHUFFLE(3, 3, 3, 3)) +// __m128 e0 = _mm_shuffle_ps(in2[3], in2[3], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 e1 = _mm_shuffle_ps(in2[3], in2[3], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 e2 = _mm_shuffle_ps(in2[3], in2[3], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 e3 = _mm_shuffle_ps(in2[3], in2[3], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 m0 = _mm_mul_ps(in1[0], e0); +// __m128 m1 = _mm_mul_ps(in1[1], e1); +// __m128 m2 = _mm_mul_ps(in1[2], e2); +// __m128 m3 = _mm_mul_ps(in1[3], e3); +// +// __m128 a0 = _mm_add_ps(m0, m1); +// __m128 a1 = _mm_add_ps(m2, m3); +// __m128 a2 = _mm_add_ps(a0, a1); +// +// out[3] = a2; +// } +// +// glm::uint64 TimeEnd = GetCpuCycle(); +// +// printf("Ticks mul: %d\n", TimeEnd - TimeStart); +//} +// +//inline void _mm_transpose_ps(__m128 const in[4], __m128 out[4]) +//{ +// __m128 tmp0 = _mm_shuffle_ps(in[0], in[1], 0x44); +// __m128 tmp2 = _mm_shuffle_ps(in[0], in[1], 0xEE); +// __m128 tmp1 = _mm_shuffle_ps(in[2], in[3], 0x44); +// __m128 tmp3 = _mm_shuffle_ps(in[2], in[3], 0xEE); +// +// out[0] = _mm_shuffle_ps(tmp0, tmp1, 0x88); +// out[1] = _mm_shuffle_ps(tmp0, tmp1, 0xDD); +// out[2] = _mm_shuffle_ps(tmp2, tmp3, 0x88); +// out[3] = _mm_shuffle_ps(tmp2, tmp3, 0xDD); +//} + +//void _mm_inverse_ps(__m128 const in[4], __m128 out[4]) +//{ +// // Swp00 = _mm_shuffle_ps(in[1], in[2], _MM_SHUFFLE(2, 2, 2, 2)); +// // SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// // SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// // SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; +// // SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; +// // + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02), +// // - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02), +// // + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08), +// // - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15), +// +// __m128 Sfc00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 Sfc0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(3, 2, 3, 2)); +// __m128 Sfc01 = _mm_shuffle_ps(Sfc0a, Sfc0a, _MM_SHUFFLE(2, 3, 1, 1)); +// __m128 Sfc02 = _mm_shuffle_ps(Sfc0a, Sfc0a, _MM_SHUFFLE(3, 2, 0, 0)); +// __m128 Sfc03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 SfcM0 = _mm_mul_ps(Sfc00, Sfc01); +// __m128 SfcM1 = _mm_mul_ps(Sfc02, Sfc03); +// __m128 SfcM2 = _mm_sub_ps(SfcM0, SfcM1); +// // SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// // SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// // SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; +// // SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; +// // + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02), +// // - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02), +// // + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08), +// // - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15), +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[2], _MM_SHUFFLE(3, 0, 1, 2)); +// __m128 Swp01 = _mm_shuffle_ps(in[3], in[3], _MM_SHUFFLE(3, 3, 3, 3)); +// __m128 Swp02 = _mm_shuffle_ps(in[3], in[3], _MM_SHUFFLE(3, 0, 1, 2)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[2], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 Swp04 = _mm_shuffle_ps(in[2], in[2], _MM_SHUFFLE(3, 0, 0, 1)); +// __m128 Swp05 = _mm_shuffle_ps(in[3], in[3], _MM_SHUFFLE(3, 1, 2, 2)); +// __m128 Swp06 = _mm_shuffle_ps(in[3], in[3], _MM_SHUFFLE(3, 0, 0, 1)); +// __m128 Swp07 = _mm_shuffle_ps(in[2], in[2], _MM_SHUFFLE(3, 1, 2, 2)); +// +// __m128 Swp08 = _mm_shuffle_ps(in[1], in[1], _MM_SHUFFLE(3, 0, 1, 2)); +// __m128 Swp09 = _mm_shuffle_ps(in[1], in[1], _MM_SHUFFLE(3, 3, 3, 3)); +// __m128 Swp10 = _mm_shuffle_ps(in[1], in[1], _MM_SHUFFLE(3, 0, 0, 1)); +// __m128 Swp11 = _mm_shuffle_ps(in[1], in[1], _MM_SHUFFLE(3, 1, 2, 2)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// __m128 Fac00 = _mm_sub_ps(Mul00, Mul01); +// +// //valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// //valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; +// //valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; +// +// __m128 Mul02 = _mm_mul_ps(Swp04, Swp05); +// __m128 Mul03 = _mm_mul_ps(Swp06, Swp07); +// __m128 Fac01 = _mm_sub_ps(Mul02, Mul03); +// +// //valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; +// //valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; +// //valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; +// +// __m128 Mul04 = _mm_mul_ps(Swp08, Swp01); +// __m128 Mul05 = _mm_mul_ps(Swp02, Swp09); +// __m128 Fac02 = _mm_sub_ps(Mul04, Mul05); +// +// //valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; +// //valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; +// //valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; +// +// __m128 Mul06 = _mm_mul_ps(Swp10, Swp05); +// __m128 Mul07 = _mm_mul_ps(Swp06, Swp11); +// __m128 Fac03 = _mm_sub_ps(Mul06, Mul07); +// +// //valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; +// //valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; +// //valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; +// +// __m128 Mul08 = _mm_mul_ps(Swp08, Swp03); +// __m128 Mul09 = _mm_mul_ps(Swp00, Swp09); +// __m128 Fac04 = _mm_sub_ps(Mul08, Mul09); +// +// //valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; +// //valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; +// //valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; +// +// __m128 Mul10 = _mm_mul_ps(Swp10, Swp07); +// __m128 Mul11 = _mm_mul_ps(Swp04, Swp11); +// __m128 Fac05 = _mm_sub_ps(Mul10, Mul11); +// +// //valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; +// //valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; +// //valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; +// +// bool end = true; +//} + +//template +//inline detail::tmat4x4 inverse +//( +// detail::tmat4x4 const & m +//) +//{ + +//inline __m128 _mm_dot_ps(__m128 v1, __m128 v2) +//{ +// __m128 mul0 = _mm_mul_ps(v1, v2); +// __m128 swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1)); +// __m128 add0 = _mm_add_ps(mul0, swp0); +// __m128 swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3)); +// __m128 add1 = _mm_add_ps(add0, swp1); +// return add1; +//} +// +//inline void _mm_inverse_ps(__m128 const in[4], __m128 out[4]) +//{ +// glm::uint64 TimeStart = GetCpuCycle(); +// +// __m128 Fac0; +// { +// // valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// // valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; +// // valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; +// // valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; +// +// __m128 Swp0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(3, 3, 3, 3)); +// __m128 Swp0b = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(2, 2, 2, 2)); +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 Swp01 = _mm_shuffle_ps(Swp0a, Swp0a, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp02 = _mm_shuffle_ps(Swp0b, Swp0b, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// Fac0 = _mm_sub_ps(Mul00, Mul01); +// +// bool stop = true; +// } +// +// __m128 Fac1; +// { +// // valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; +// // valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; +// // valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3]; +// // valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3]; +// +// __m128 Swp0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(3, 3, 3, 3)); +// __m128 Swp0b = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(1, 1, 1, 1)); +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 Swp01 = _mm_shuffle_ps(Swp0a, Swp0a, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp02 = _mm_shuffle_ps(Swp0b, Swp0b, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// Fac1 = _mm_sub_ps(Mul00, Mul01); +// +// bool stop = true; +// } +// +// +// __m128 Fac2; +// { +// // valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; +// // valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; +// // valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2]; +// // valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2]; +// +// __m128 Swp0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 Swp0b = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(1, 1, 1, 1)); +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 Swp01 = _mm_shuffle_ps(Swp0a, Swp0a, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp02 = _mm_shuffle_ps(Swp0b, Swp0b, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(2, 2, 2, 2)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// Fac2 = _mm_sub_ps(Mul00, Mul01); +// +// bool stop = true; +// } +// +// __m128 Fac3; +// { +// // valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; +// // valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3]; +// // valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3]; +// // valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3]; +// +// __m128 Swp0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(3, 3, 3, 3)); +// __m128 Swp0b = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(0, 0, 0, 0)); +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 Swp01 = _mm_shuffle_ps(Swp0a, Swp0a, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp02 = _mm_shuffle_ps(Swp0b, Swp0b, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(3, 3, 3, 3)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// Fac3 = _mm_sub_ps(Mul00, Mul01); +// +// bool stop = true; +// } +// +// __m128 Fac4; +// { +// // valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; +// // valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2]; +// // valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2]; +// // valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2]; +// +// __m128 Swp0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 Swp0b = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(0, 0, 0, 0)); +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 Swp01 = _mm_shuffle_ps(Swp0a, Swp0a, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp02 = _mm_shuffle_ps(Swp0b, Swp0b, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(2, 2, 2, 2)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// Fac4 = _mm_sub_ps(Mul00, Mul01); +// +// bool stop = true; +// } +// +// __m128 Fac5; +// { +// // valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; +// // valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1]; +// // valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1]; +// // valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1]; +// +// __m128 Swp0a = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 Swp0b = _mm_shuffle_ps(in[3], in[2], _MM_SHUFFLE(0, 0, 0, 0)); +// +// __m128 Swp00 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 Swp01 = _mm_shuffle_ps(Swp0a, Swp0a, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp02 = _mm_shuffle_ps(Swp0b, Swp0b, _MM_SHUFFLE(2, 0, 0, 0)); +// __m128 Swp03 = _mm_shuffle_ps(in[2], in[1], _MM_SHUFFLE(1, 1, 1, 1)); +// +// __m128 Mul00 = _mm_mul_ps(Swp00, Swp01); +// __m128 Mul01 = _mm_mul_ps(Swp02, Swp03); +// Fac5 = _mm_sub_ps(Mul00, Mul01); +// +// bool stop = true; +// } +// +// __m128 SignA = _mm_set_ps( 1.0f,-1.0f, 1.0f,-1.0f); +// __m128 SignB = _mm_set_ps(-1.0f, 1.0f,-1.0f, 1.0f); +// +// // m[1][0] +// // m[0][0] +// // m[0][0] +// // m[0][0] +// __m128 Temp0 = _mm_shuffle_ps(in[1], in[0], _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 Vec0 = _mm_shuffle_ps(Temp0, Temp0, _MM_SHUFFLE(2, 2, 2, 0)); +// +// // m[1][1] +// // m[0][1] +// // m[0][1] +// // m[0][1] +// __m128 Temp1 = _mm_shuffle_ps(in[1], in[0], _MM_SHUFFLE(1, 1, 1, 1)); +// __m128 Vec1 = _mm_shuffle_ps(Temp1, Temp1, _MM_SHUFFLE(2, 2, 2, 0)); +// +// // m[1][2] +// // m[0][2] +// // m[0][2] +// // m[0][2] +// __m128 Temp2 = _mm_shuffle_ps(in[1], in[0], _MM_SHUFFLE(2, 2, 2, 2)); +// __m128 Vec2 = _mm_shuffle_ps(Temp2, Temp2, _MM_SHUFFLE(2, 2, 2, 0)); +// +// // m[1][3] +// // m[0][3] +// // m[0][3] +// // m[0][3] +// __m128 Temp3 = _mm_shuffle_ps(in[1], in[0], _MM_SHUFFLE(3, 3, 3, 3)); +// __m128 Vec3 = _mm_shuffle_ps(Temp3, Temp3, _MM_SHUFFLE(2, 2, 2, 0)); +// +// // col0 +// // + (Vec1[0] * Fac0[0] - Vec2[0] * Fac1[0] + Vec3[0] * Fac2[0]), +// // - (Vec1[1] * Fac0[1] - Vec2[1] * Fac1[1] + Vec3[1] * Fac2[1]), +// // + (Vec1[2] * Fac0[2] - Vec2[2] * Fac1[2] + Vec3[2] * Fac2[2]), +// // - (Vec1[3] * Fac0[3] - Vec2[3] * Fac1[3] + Vec3[3] * Fac2[3]), +// __m128 Mul00 = _mm_mul_ps(Vec1, Fac0); +// __m128 Mul01 = _mm_mul_ps(Vec2, Fac1); +// __m128 Mul02 = _mm_mul_ps(Vec3, Fac2); +// __m128 Sub00 = _mm_sub_ps(Mul00, Mul01); +// __m128 Add00 = _mm_add_ps(Sub00, Mul02); +// __m128 Inv0 = _mm_mul_ps(SignB, Add00); +// +// // col1 +// // - (Vec0[0] * Fac0[0] - Vec2[0] * Fac3[0] + Vec3[0] * Fac4[0]), +// // + (Vec0[0] * Fac0[1] - Vec2[1] * Fac3[1] + Vec3[1] * Fac4[1]), +// // - (Vec0[0] * Fac0[2] - Vec2[2] * Fac3[2] + Vec3[2] * Fac4[2]), +// // + (Vec0[0] * Fac0[3] - Vec2[3] * Fac3[3] + Vec3[3] * Fac4[3]), +// __m128 Mul03 = _mm_mul_ps(Vec0, Fac0); +// __m128 Mul04 = _mm_mul_ps(Vec2, Fac3); +// __m128 Mul05 = _mm_mul_ps(Vec3, Fac4); +// __m128 Sub01 = _mm_sub_ps(Mul03, Mul04); +// __m128 Add01 = _mm_add_ps(Sub01, Mul05); +// __m128 Inv1 = _mm_mul_ps(SignA, Add01); +// +// // col2 +// // + (Vec0[0] * Fac1[0] - Vec1[0] * Fac3[0] + Vec3[0] * Fac5[0]), +// // - (Vec0[0] * Fac1[1] - Vec1[1] * Fac3[1] + Vec3[1] * Fac5[1]), +// // + (Vec0[0] * Fac1[2] - Vec1[2] * Fac3[2] + Vec3[2] * Fac5[2]), +// // - (Vec0[0] * Fac1[3] - Vec1[3] * Fac3[3] + Vec3[3] * Fac5[3]), +// __m128 Mul06 = _mm_mul_ps(Vec0, Fac1); +// __m128 Mul07 = _mm_mul_ps(Vec1, Fac3); +// __m128 Mul08 = _mm_mul_ps(Vec3, Fac5); +// __m128 Sub02 = _mm_sub_ps(Mul06, Mul07); +// __m128 Add02 = _mm_add_ps(Sub02, Mul08); +// __m128 Inv2 = _mm_mul_ps(SignB, Add02); +// +// // col3 +// // - (Vec1[0] * Fac2[0] - Vec1[0] * Fac4[0] + Vec2[0] * Fac5[0]), +// // + (Vec1[0] * Fac2[1] - Vec1[1] * Fac4[1] + Vec2[1] * Fac5[1]), +// // - (Vec1[0] * Fac2[2] - Vec1[2] * Fac4[2] + Vec2[2] * Fac5[2]), +// // + (Vec1[0] * Fac2[3] - Vec1[3] * Fac4[3] + Vec2[3] * Fac5[3])); +// __m128 Mul09 = _mm_mul_ps(Vec0, Fac2); +// __m128 Mul10 = _mm_mul_ps(Vec1, Fac4); +// __m128 Mul11 = _mm_mul_ps(Vec2, Fac5); +// __m128 Sub03 = _mm_sub_ps(Mul09, Mul10); +// __m128 Add03 = _mm_add_ps(Sub03, Mul11); +// __m128 Inv3 = _mm_mul_ps(SignA, Add03); +// +// __m128 Row0 = _mm_shuffle_ps(Inv0, Inv1, _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 Row1 = _mm_shuffle_ps(Inv2, Inv3, _MM_SHUFFLE(0, 0, 0, 0)); +// __m128 Row2 = _mm_shuffle_ps(Row0, Row1, _MM_SHUFFLE(2, 0, 2, 0)); +// +// // valType Determinant = m[0][0] * Inverse[0][0] +// // + m[0][1] * Inverse[1][0] +// // + m[0][2] * Inverse[2][0] +// // + m[0][3] * Inverse[3][0]; +// __m128 Det0 = _mm_dot_ps(in[0], Row2); +// +// // Inverse /= Determinant; +// out[0] = _mm_div_ps(Inv0, Det0); +// out[1] = _mm_div_ps(Inv1, Det0); +// out[2] = _mm_div_ps(Inv2, Det0); +// out[3] = _mm_div_ps(Inv3, Det0); +// +// glm::uint64 TimeEnd = GetCpuCycle(); +// +// printf("Ticks inv: %d\n", TimeEnd - TimeStart); +// +// bool stop = true; +//} + +//#include + +void test_mat4_mul() +{ +/* + { + __m128 v1 = _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f); + __m128 m0[4]; + m0[0] = _mm_set_ps(3.0f, 2.0f, 1.0f, 0.0f); + m0[1] = _mm_set_ps(4.0f, 5.0f, 6.0f, 7.0f); + m0[2] = _mm_set_ps(0.3f, 0.2f, 0.1f, 0.0f); + m0[3] = _mm_set_ps(0.4f, 0.5f, 0.6f, 0.7f); + + __m128 v2 = _mm_mul_ps(v1, m0); + + bool stop = true; + } + { + glm::vec4 v1(0.0f, 1.0f, 2.0f, 3.0f); + + glm::mat4 m0; + m0[0] = glm::vec4(0.0f, 1.0f, 2.0f, 3.0f); + m0[1] = glm::vec4(7.0f, 6.0f, 5.0f, 4.0f); + m0[2] = glm::vec4(0.0f, 0.1f, 0.2f, 0.3f); + m0[3] = glm::vec4(0.7f, 0.6f, 0.5f, 0.4f); + glm::vec4 v2 = v1 * m0; + + bool stop = true; + } +*/ + { + __m128 a = _mm_setr_ps(0.0f, 1.0f, 2.0f, 3.0f); + __m128 b = _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 2, 1, 0)); + + bool stop = true; + } + + { + __m128 v1 = _mm_setr_ps(0.3f, 0.2f, 0.1f, 1.0f); + __m128 m0[4]; + m0[0] = _mm_setr_ps(2.0f, 0.2f, 0.1f,-1.4f); + m0[1] = _mm_setr_ps(0.5f, 2.0f, 0.3f,-1.2f); + m0[2] = _mm_setr_ps(0.6f, 0.4f, 2.0f,-1.1f); + m0[3] = _mm_setr_ps(1.4f, 1.2f, 1.1f, 1.0f); + + __m128 v2 = _mm_mul_ps(v1, m0); + + bool stop = true; + } + + { + glm::vec4 v1(0.3f, 0.2f, 0.1f, 1.0f); + + glm::mat4 m0; + m0[0] = glm::vec4(2.0f, 0.2f, 0.1f,-1.4f); + m0[1] = glm::vec4(0.5f, 2.0f, 0.3f,-1.2f); + m0[2] = glm::vec4(0.6f, 0.4f, 2.0f,-1.1f); + m0[3] = glm::vec4(1.4f, 1.2f, 1.1f, 1.0f); + glm::vec4 v2 = v1 * m0; + + bool stop = true; + } + + { + glm::vec4 v1(1.0f, 0.5f,-0.5f,-1.0f); + + glm::mat4 m0; + m0[0] = glm::vec4(2.0f,-1.0f,-1.0f, 4.0f); + m0[1] = glm::vec4(2.0f, 1.0f, 4.0f, 1.0f); + m0[2] = glm::vec4(2.0f, 4.0f, 1.0f, 1.0f); + m0[3] = glm::vec4(4.0f, 1.0f, 1.0f, 1.0f); + m0 = glm::transpose(m0); + glm::vec4 v2 = m0 * v1; + + bool stop = true; + } + + { + glm::mat4 MatA; + MatA[0] = glm::vec4(0.2f, 0.1f, 0.3f, 0.4f); + MatA[1] = glm::vec4(1.0f, 0.3f, 0.2f, 0.3f); + MatA[2] = glm::vec4(3.0f, 2.0f, 0.4f, 0.2f); + MatA[3] = glm::vec4(4.0f, 3.0f, 2.0f, 1.0f); + + glm::mat4 InvA = glm::inverse(MatA); + glm::mat4 IndA = MatA * InvA; +// glm::mat4 InvB = glm::inverseOgre(MatA); +// glm::mat4 IndB = MatA * InvB; +// glm::mat4 InvD = glm::inverseSIMD(MatA); +// glm::mat4 IndD = MatA * InvD; +// glm::mat4 InvE = glm::inverseDev(MatA); +// glm::mat4 IndE = MatA * InvE; + + __m128 MatC[4]; + MatC[0] = _mm_setr_ps(0.2f, 0.1f, 0.3f, 0.4f); + MatC[1] = _mm_setr_ps(1.0f, 0.3f, 0.2f, 0.3f); + MatC[2] = _mm_setr_ps(3.0f, 2.0f, 0.4f, 0.2f); + MatC[3] = _mm_setr_ps(4.0f, 3.0f, 2.0f, 1.0f); + __m128 InvC[4]; + _mm_inverse_ps(MatC, InvC); + + __m128 IndC[4]; + _mm_mul_ps(MatC, InvC, IndC); + + __m128 Mul2[4]; + _mm_mul_ps(MatC, MatC, Mul2); + + bool stop = true; + } + + { + glm::dmat4 Mat; + Mat[0] = glm::dvec4(0.0f, 1.0f, 2.0f, 3.0f); + Mat[1] = glm::dvec4(0.1f, 1.1f, 2.1f, 3.1f); + Mat[2] = glm::dvec4(0.2f, 1.2f, 2.2f, 3.2f); + Mat[3] = glm::dvec4(0.3f, 1.3f, 2.3f, 3.3f); + glm::dmat4 Inv = glm::inverse(Mat); + glm::dmat4 Ind = Mat * Inv; + + glm::dmat4 MatB; + MatB[0] = glm::dvec4(0.0f, 1.0f, 2.0f, 3.0f); + MatB[1] = glm::dvec4(0.1f, 1.1f, 2.1f, 3.1f); + MatB[2] = glm::dvec4(0.2f, 1.2f, 2.2f, 3.2f); + MatB[3] = glm::dvec4(0.3f, 1.3f, 2.3f, 3.3f); +// glm::dmat4 InvB = glm::inverseOgre(MatB); +// glm::dmat4 IndB = MatB * InvB; + + bool stop = true; + } + + { + glm::mat3 Mat; + Mat[0] = glm::vec3(0.0f, 1.0f, 2.0f); + Mat[1] = glm::vec3(0.1f, 1.1f, 2.1f); + Mat[2] = glm::vec3(0.2f, 1.2f, 2.2f); + glm::mat3 Inv = glm::inverse(Mat); + glm::mat3 Ind = Mat * Inv; + + bool stop = true; + } + + bool stop = true; +} + +void test_vec4_mul() +{ + glm::vec4 v1(1.0f, 2.0f, 3.0f, 4.0f); + glm::mat4 m1; + m1[0] = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) * 0.1f; + m1[1] = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) * 0.2f; + m1[2] = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) * 0.3f; + m1[3] = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) * 0.4f; + glm::vec4 vA = m1 * v1; + glm::vec4 vC = v1 * m1; + + __m128 v2 = _mm_setr_ps(1.0f, 2.0f, 3.0f, 4.0f); + __m128 m2[4]; + m2[0] = _mm_mul_ps(_mm_setr_ps(1.0f, 2.0f, 3.0f, 4.0f), _mm_set_ps1(0.1f)); + m2[1] = _mm_mul_ps(_mm_setr_ps(1.0f, 2.0f, 3.0f, 4.0f), _mm_set_ps1(0.2f)); + m2[2] = _mm_mul_ps(_mm_setr_ps(1.0f, 2.0f, 3.0f, 4.0f), _mm_set_ps1(0.3f)); + m2[3] = _mm_mul_ps(_mm_setr_ps(1.0f, 2.0f, 3.0f, 4.0f), _mm_set_ps1(0.4f)); + __m128 vB = _mm_mul_ps(m2, v2); + __m128 vD = _mm_mul_ps(v2, m2); + + bool stop = true; +} + +void test_mat4_tick() +{ + __m128 MatC[4]; + MatC[0] = _mm_setr_ps(0.2f, 0.1f, 0.3f, 0.4f); + MatC[1] = _mm_setr_ps(1.0f, 0.3f, 0.2f, 0.3f); + MatC[2] = _mm_setr_ps(3.0f, 2.0f, 0.4f, 0.2f); + MatC[3] = _mm_setr_ps(4.0f, 3.0f, 2.0f, 1.0f); + + int CPUInfo[4]; + int InfoType; + + for(std::size_t i = 0; i < 10; ++i) + { + __m128 InvC[4]; + __m128 IndC[4]; + + { +// __cpuid(CPUInfo, InfoType); +// __rdtsc(); +// __cpuid(CPUInfo, InfoType); +// __rdtsc(); +// __cpuid(CPUInfo, InfoType); + + //glm::uint64 ClockStart = GetCpuCycle(); + _mm_inverse_ps(MatC, InvC); + //glm::uint64 ClockEnd = GetCpuCycle(); + //printf("inv: %d\n", ClockEnd - ClockStart); + } + + { +// __cpuid(CPUInfo, InfoType); +// __rdtsc(); +// __cpuid(CPUInfo, InfoType); +// __rdtsc(); +// __cpuid(CPUInfo, InfoType); + + //glm::uint64 ClockStart = GetCpuCycle(); + _mm_mul_ps(MatC, InvC, IndC); + //glm::uint64 ClockEnd = GetCpuCycle(); + //printf("mul: %d\n", ClockEnd - ClockStart); + } + } +} + +int firstBit(int Binary) +{ + for(std::size_t i = 0; i < 32; ++i) + if(Binary & (1 << i)) + return i; + assert(0); + return 0; +} + +void test_exp_golomb() +{ + //0 => 1 => 1 + //1 => 10 => 010 + //2 => 11 => 011 + //3 => 100 => 00100 + //4 => 101 => 00101 + //5 => 110 => 00110 + //6 => 111 => 00111 + //7 => 1000 => 0001000 + //8 => 1001 => 0001001 + + // - Take the number in binary except for the last k digits + // and add 1 to it (arithmetically). Write this down. + // - Count the bits written, subtract one, + // - Write that number of starting zero bits preceding the previous bit string. + // - Write the last k bits in binary. + + std::size_t Bit00 = glm::highestBit(0); + std::size_t Bit01 = glm::highestBit(1); + std::size_t Bit02 = glm::highestBit(2); + std::size_t Bit04 = glm::highestBit(4); + std::size_t Bit08 = glm::highestBit(8); + std::size_t Bit16 = glm::highestBit(16); + std::size_t Bit32 = glm::highestBit(32); + + std::vector Size(256); + std::vector Data(256); + std::vector Conv(256); + + for(std::size_t i = 0; i < 256; ++i) + { + glm::uint32 Binary = i + 1; + glm::uint32 HighestBit = glm::highestBit(Binary); + glm::uint32 CodeSize = (HighestBit << 1) + 1; + glm::uint32 Swift = 32 - CodeSize; + glm::uint32 Temp = glm::bitRevert(Binary << Swift); + //glm::uint32 Temp = Binary << Swift; + + Data[i] = Temp; + Size[i] = HighestBit * 2 + 1; + + printf("Binary(%d, %d): ", Swift, CodeSize); + for(std::size_t k = 0; k < 32; ++k) + printf("%d", glm::uint32((Binary & (1 << k)) != 0)); + printf(" (%d)\n", Binary); + + printf("Temp(%d, %d) : ", Swift, CodeSize); + for(std::size_t k = 0; k < 32; ++k) + printf("%d", glm::uint32((Temp & (1 << k)) != 0)); + printf(" (%d)\n", Temp); + + printf("Value(%d): ", i); + for(std::size_t k = 0; k < 8; ++k) + printf("%d", glm::uint32((i & (1 << k)) != 0)); + printf("; "); + + printf("Code: "); + for(std::size_t k = 0; k < Size[i]; ++k) + printf("%d", glm::uint32((Data[i] & (1 << k)) != 0)); + printf("\n"); + + { + glm::uint32 Temp = Data[i]; + glm::uint32 CodeSize2 = (firstBit(Temp) << 1) + 1; + glm::uint32 Swift2 = 32 - CodeSize2; + glm::uint32 Binary = glm::bitRevert(Temp) >> Swift2; + Conv[i] = Binary - 1; + } + + printf("Conv (%d, %d): ", Swift, CodeSize); + for(std::size_t k = 0; k < 32; ++k) + printf("%d", glm::uint32((Conv[i] & (1 << k)) != 0)); + printf(" (%d)\n\n", Conv[i]); + + bool stop = true; + } + + bool stop = true; +} +/* +int main(int argc, char* argv[]) +{ + test_mat4_mul(); + test_exp_golomb(); + //test_mat4_tick(); + test_quat(); + test_simd(); + test_transform(); + test_const(); + test_radial(); + test_vec4_mul(); + + glm::uint LowestBit = glm::lowestBit(8); + + glm::test::main_core_func_common(); + glm::test::main_core_func_exponential(); + glm::test::main_core_func_geometric(); + glm::test::main_core_func_matrix(); + glm::test::main_core_func_noise(); + glm::test::main_core_func_trigonometric(); + glm::test::main_core_func_vector_relational(); + glm::test::main_gtx_intesect(); + + { + glm::vec3 Normal(1, 0, 0); + + glm::vec3 x = glm::rotate(glm::vec3(1,0,0),180.f,Normal); + glm::vec3 y = glm::rotate(glm::vec3(1,1,0),180.f,Normal); + + bool Stop = true; + } + + glm::mat4 m1 = glm::inverseTranspose( + glm::gtc::matrix_transform::translate( + glm::gtc::matrix_transform::rotate( + glm::mat4(1.0f), + 90.f, + glm::normalize(glm::vec3(1.0f, 0.5f, 0.2f))), + glm::vec3(1.f, 2.f, 3.f))); + + glm::mat4 m2 = glm::transpose( + glm::inverse( + glm::gtc::matrix_transform::translate( + glm::gtc::matrix_transform::rotate( + glm::mat4(1.0f), + 90.f, + glm::normalize(glm::vec3(1.0f, 0.5f, 0.2f))), + glm::vec3(1.f, 2.f, 3.f)))); + + test_hint(); + test_fast_inverse(); + //test_type(); + test_profile(); +// glm::greaterThan(); + test_angle(); + + test_half(); + test_swizzle(); + + test::main_vec2(); + + test_quaternion(); + test_auto_cast(); + + //detail::test_half_type(); + + glm::vec2 Result = glm::perp(glm::vec2(1.0, 0.0), glm::vec2(0.0, 1.0)); + +// test_genType(); +// test_desk(); + //radians(1); + + glm::mat4 LookAt = glm::lookAt(glm::vec3(1), glm::vec3(1), glm::vec3(1)); + + fast_inverse(); + test_string_cast(); + test_isPowerOfTwo(); + + { + float fast0 = glm::fastLength(glm::vec3(1.0f)); + float fast1 = 0.0f; + } + + vec4 v76 = 1.f * vec4(1.0f); + + test_matrix(); + //test_random(); + //test_sse_vec4(); + //test_sse_mat4(); + + { + float f1 = glm::mix(100.f, 1000.f, 0.5f); + vec3 f2 = glm::mix(vec3(100.f), vec3(1000.f), 0.5f); + ivec3 f3 = glm::mix(ivec3(100), ivec3(1000), 0.5f); + ivec3 f4 = glm::mix(ivec3(100), ivec3(1000), vec3(0.5f)); + } + + { + mat4 Projection = glm::frustum(-1.0f, 1.0f, -1.0f, 1.0f, 0.1f, 1.0f); + + //glm_traits::value_type vec(1.0f); + } + + { + glm::vec2 v1(1.0f); + glm::vec2 v2(2.0f); + glm::vec2 v3(3.0f); + +// v1.xy += v2 + v3.xy; + } + + { + bool b = true; + glm::vec4 v4(b); + } + + { + glm::quat q1; + q1 = glm::inverse(q1); + } + + //test_cast(); + //test_half_full(); + + //test_sse(); + //__hvec2GTX Pouet; + //pouet Pouet(1, 2, 3); + glm::dmat4 dm = glm::dmat4(1.0); + glm::mat4 fm1 = glm::mat4(dm); + glm::mat4 fm2(dm); + //glm::hmat4 hm = glm::hmat4(1.0); + //glm::mat4 fm3(hm); + //glm::dmat4 dm2(hm); + + { + glm::quat q1; + glm::vec4 v1; + glm::vec4 r1; + r1 = q1 * v1; + + r1++; + //q1 = glm::absGTX(q1); + } + + { + glm::vec3 v1(1.0f); + ++v1; + v1++; + } + + { + glm::vec4 v1(1.0f); + --v1; + v1--; + } + + { + glm::vec4 v1(1.0f); + ++v1; + v1++; + } + + { + ivec3 testVec = ivec3(3,35,4); + const ivec3 testVec2 = ivec3(13,15,14); + //testVec = testVec2.zyx; + //testVec = testVec2.xyy; + //testVec = testVec2.rrr; + //ivec4 textVec4 = testVec2.zzxx; + //ivec2 textVec2 = testVec2.gr; + + //half h1 = half(1.0f); + //hvec2 hv2 = hvec2(h1); + //hvec3 hv3 = hvec3(h1); + //hvec4 hv4 = hvec4(h1); + } + + vec2 Stuff = glm::mix(vec2(1), vec2(0), 0.5f); + + test_gtx_bit(); + + vec2 Max = glm::max(vec2(0.f), vec2(1.f)); + vec2 Truc = radians(vec2(1)); +// ivec3 v(1); +// v = operator &=((1 << 0)); + + ivec3 v(1); + v &= (1 << 0); + + + vec4 Color = glm::f32_rgba_cast(glm::uint32(0)); + + vec3 Normal = glm::normalizedRand3(); + //__hvec3GTX hCos = cos(__hvec3GTX(1.0f)); + //__hvec3GTX hNormal = normalizedRand3(); + + //quat Quat; + //Quat = sqrt(Quat); + +#if(defined(GLM_SWIZZLE) && GLM_SWIZZLE & GLM_SWIZZLE_FUNC) + vec4 ColorRGBA = vec4(1.0, 0.5, 0.0, 1.0)._xyzw(); +#endif//GLM_SWIZZLE + + hvec2 v1(1.0f, 2.0f); + hvec2 v2(3.0f, 4.0f); + v2 = v1; + v2 += half(1.0f); + v2 += detail::thalf(1.0f); + v2 = v1 - v2; + half hcos1 = glm::cos(half(1.0)); + hvec2 hcos2 = glm::cos(hvec2(1.0)); + + //test_associated_min_max(); + + system("pause"); + return 0; +} +*/ + +#define CPUID __asm __emit 0fh __asm __emit 0a2h +#define RDTSC __asm __emit 0fh __asm __emit 031h + +unsigned test_sse() +{ + glm::mat4 MatA; + MatA[0] = glm::vec4(0.2f, 0.1f, 0.3f, 0.4f); + MatA[1] = glm::vec4(1.0f, 0.3f, 0.2f, 0.3f); + MatA[2] = glm::vec4(3.0f, 2.0f, 0.4f, 0.2f); + MatA[3] = glm::vec4(4.0f, 3.0f, 2.0f, 1.0f); + glm::mat4 MulA; + glm::mat4 InvA; + unsigned cycles; + + __m128 MatC[4]; + MatC[0] = _mm_setr_ps(0.2f, 0.1f, 0.3f, 0.4f); + MatC[1] = _mm_setr_ps(1.0f, 0.3f, 0.2f, 0.3f); + MatC[2] = _mm_setr_ps(3.0f, 2.0f, 0.4f, 0.2f); + MatC[3] = _mm_setr_ps(4.0f, 3.0f, 2.0f, 1.0f); + __m128 MatR[4]; +/* + __asm + { + pushad + + CPUID + RDTSC + mov cycles, eax + + popad + } +*/ + //MulA = MatA * MatA; + //_mm_mul_ps(MatC, MatC, MatR); + //InvA = glm::inverse(MatA); + //_mm_inverse_ps(MatC, MatR); + _mm_inverse_fast_ps(MatC, MatR); + //glm::mat4 IndA = MatA * InvA; + //glm::mat4 InvB = glm::inverseOgre(MatA); + //glm::mat4 IndB = MatA * InvB; +// glm::mat4 InvD = glm::inverseSIMD(MatA); +// glm::mat4 IndD = MatA * InvD; +// glm::mat4 InvE = glm::inverseDev(MatA); +// glm::mat4 IndE = MatA * InvE; + + //__m128 MatC[4]; + //MatC[0] = _mm_setr_ps(0.2f, 0.1f, 0.3f, 0.4f); + //MatC[1] = _mm_setr_ps(1.0f, 0.3f, 0.2f, 0.3f); + //MatC[2] = _mm_setr_ps(3.0f, 2.0f, 0.4f, 0.2f); + //MatC[3] = _mm_setr_ps(4.0f, 3.0f, 2.0f, 1.0f); + //__m128 InvC[4]; + //_mm_inverse_ps(MatC, InvC); + + //__m128 IndC[4]; + //_mm_mul_ps(MatC, InvC, IndC); + + //__m128 Mul2[4]; + //_mm_mul_ps(MatC, MatC, Mul2); +/* + __asm + { + pushad + + CPUID + RDTSC + sub eax, cycles + mov cycles, eax + + popad + } +*/ + return cycles; +} + +unsigned test_mat4_translate() +{ + glm::mat4 MatA; + MatA[0] = glm::vec4(0.2f, 0.1f, 0.3f, 0.4f); + MatA[1] = glm::vec4(1.0f, 0.3f, 0.2f, 0.3f); + MatA[2] = glm::vec4(3.0f, 2.0f, 0.4f, 0.2f); + MatA[3] = glm::vec4(4.0f, 3.0f, 2.0f, 1.0f); + glm::mat4 Transform; + + __m128 MatC[4]; + MatC[0] = _mm_setr_ps(0.2f, 0.1f, 0.3f, 0.4f); + MatC[1] = _mm_setr_ps(1.0f, 0.3f, 0.2f, 0.3f); + MatC[2] = _mm_setr_ps(3.0f, 2.0f, 0.4f, 0.2f); + MatC[3] = _mm_setr_ps(4.0f, 3.0f, 2.0f, 1.0f); + __m128 MatR[4]; + float v[] = {1, 2, 3}; + + unsigned cycles; +/* + __asm + { + pushad + + CPUID + RDTSC + mov cycles, eax + + popad + } +*/ + _mm_rotate_ps(MatC, 45.f, v, MatR); + //Transform = glm::rotate(MatA, 45.f, glm::vec3(1, 2, 3)); +/* + __asm + { + pushad + + CPUID + RDTSC + sub eax, cycles + mov cycles, eax + + popad + } +*/ + return cycles; +} + +void test_vec4_simd() +{ + glm::vec4SIMD v1(1.0f, 2.0f, 3.0f, 4.0f); + glm::vec4SIMD v2(5.0f, 6.0f, 7.0f, 8.0f); + glm::vec4SIMD v3 = v1 + v2; + + bool end = true; +} + +bool main_test() +{ + bool Result = true; + + Result = Result && glm::test::main_bug(); + assert(Result); + Result = Result && glm::test::main_type_half(); + assert(Result); + Result = Result && glm::test::main_img(); + assert(Result); + + return true; +} +/* +template