diff options
author | saurabhb17 | 2020-02-26 16:14:17 +0530 |
---|---|---|
committer | GitHub | 2020-02-26 16:14:17 +0530 |
commit | 003d02608917e7a69d1a98438837e94ccf68352a (patch) | |
tree | 1392c90227aeea231c1d86371131e04c40382918 /include/gal/opengl/glm/gtx | |
parent | 886d9cb772e81d2e5262284bc3082664f084337f (diff) | |
parent | e255d0622297488c1c52755be670733418c994cf (diff) | |
download | KiCad-eSim-003d02608917e7a69d1a98438837e94ccf68352a.tar.gz KiCad-eSim-003d02608917e7a69d1a98438837e94ccf68352a.tar.bz2 KiCad-eSim-003d02608917e7a69d1a98438837e94ccf68352a.zip |
Merge pull request #3 from saurabhb17/master
secondary files
Diffstat (limited to 'include/gal/opengl/glm/gtx')
116 files changed, 14764 insertions, 0 deletions
diff --git a/include/gal/opengl/glm/gtx/associated_min_max.hpp b/include/gal/opengl/glm/gtx/associated_min_max.hpp new file mode 100644 index 0000000..7283b69 --- /dev/null +++ b/include/gal/opengl/glm/gtx/associated_min_max.hpp @@ -0,0 +1,106 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_associated_min_max +/// @file glm/gtx/associated_min_max.hpp +/// @date 2008-03-10 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_associated_min_max GLM_GTX_associated_min_max +/// @ingroup gtx +/// +/// @brief Min and max functions that return associated values not the compared onces. +/// <glm/gtx/associated_min_max.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_associated_min_max +#define GLM_GTX_associated_min_max GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_associated_min_max extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_associated_min_max + /// @{ + + /// Min comparison between 2 variables + /// @see gtx_associated_min_max + template<typename genTypeT, typename genTypeU> + genTypeU associatedMin( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b); + + /// Min comparison between 3 variables + /// @see gtx_associated_min_max + template<typename genTypeT, typename genTypeU> + genTypeU associatedMin( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c); + + /// Min comparison between 4 variables + /// @see gtx_associated_min_max + template<typename genTypeT, typename genTypeU> + genTypeU associatedMin( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c, + const genTypeT& w, const genTypeU& d); + + /// Max comparison between 2 variables + /// @see gtx_associated_min_max + template<typename genTypeT, typename genTypeU> + genTypeU associatedMax( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b); + + /// Max comparison between 3 variables + /// @see gtx_associated_min_max + template<typename genTypeT, typename genTypeU> + genTypeU associatedMax( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c); + + /// Max comparison between 4 variables + /// @see gtx_associated_min_max + template<typename genTypeT, typename genTypeU> + genTypeU associatedMax( + const genTypeT& x, const genTypeU& a, + const genTypeT& y, const genTypeU& b, + const genTypeT& z, const genTypeU& c, + const genTypeT& w, const genTypeU& d); + + /// @} +} //namespace glm + +#include "associated_min_max.inl" + +#endif//GLM_GTX_associated_min_max diff --git a/include/gal/opengl/glm/gtx/associated_min_max.inl b/include/gal/opengl/glm/gtx/associated_min_max.inl new file mode 100644 index 0000000..ffaa1ef --- /dev/null +++ b/include/gal/opengl/glm/gtx/associated_min_max.inl @@ -0,0 +1,912 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-03-10 +// Updated : 2008-03-15 +// Licence : This source is under MIT License +// File : gtx_associated_min_max.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ + +// Min comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER U associatedMin(T x, U a, T y, U b) +{ + return x < y ? a : b; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + const detail::tvec2<T>& x, const detail::tvec2<U>& a, + const detail::tvec2<T>& y, const detail::tvec2<U>& b +) +{ + detail::tvec2<U> Result; + //Result.x = x[0] < y[0] ? a[0] : b[0]; + //Result.y = x[1] < y[1] ? a[1] : b[1]; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + const detail::tvec3<T>& x, const detail::tvec3<U>& a, + const detail::tvec3<T>& y, const detail::tvec3<U>& b +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + const detail::tvec4<T>& x, const detail::tvec4<U>& a, + const detail::tvec4<T>& y, const detail::tvec4<U>& b +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x[i] < y[i] ? a[i] : b[i]; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + T x, const detail::tvec2<U>& a, + T y, const detail::tvec2<U>& b +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + T x, const detail::tvec3<U>& a, + T y, const detail::tvec3<U>& b +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + T x, const detail::tvec4<U>& a, + T y, const detail::tvec4<U>& b +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x < y ? a[i] : b[i]; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + const detail::tvec2<T>& x, U a, + const detail::tvec2<T>& y, U b +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + const detail::tvec3<T>& x, U a, + const detail::tvec3<T>& y, U b +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + const detail::tvec4<T>& x, U a, + const detail::tvec4<T>& y, U b +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + Result[i] = x[i] < y[i] ? a : b; + return Result; +} + +// Min comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER U associatedMin +( + T x, U a, + T y, U b, + T z, U c +) +{ + U Result = x < y ? (x < z ? a : c) : (y < z ? b : c); + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + const detail::tvec2<T>& x, const detail::tvec2<U>& a, + const detail::tvec2<T>& y, const detail::tvec2<U>& b, + const detail::tvec2<T>& z, const detail::tvec2<U>& c +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + const detail::tvec3<T>& x, const detail::tvec3<U>& a, + const detail::tvec3<T>& y, const detail::tvec3<U>& b, + const detail::tvec3<T>& z, const detail::tvec3<U>& c +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; +} + +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + const detail::tvec4<T>& x, const detail::tvec4<U>& a, + const detail::tvec4<T>& y, const detail::tvec4<U>& b, + const detail::tvec4<T>& z, const detail::tvec4<U>& c +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER U associatedMin +( + T x, U a, + T y, U b, + T z, U c, + T w, U d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w);; + U Result1 = x < y ? a : b; + U Result2 = z < w ? c : d; + U Result = Test1 < Test2 ? Result1 : Result2; + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + const detail::tvec2<T>& x, const detail::tvec2<U>& a, + const detail::tvec2<T>& y, const detail::tvec2<U>& b, + const detail::tvec2<T>& z, const detail::tvec2<U>& c, + const detail::tvec2<T>& w, const detail::tvec2<U>& d +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + const detail::tvec3<T>& x, const detail::tvec3<U>& a, + const detail::tvec3<T>& y, const detail::tvec3<U>& b, + const detail::tvec3<T>& z, const detail::tvec3<U>& c, + const detail::tvec3<T>& w, const detail::tvec3<U>& d +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + const detail::tvec4<T>& x, const detail::tvec4<U>& a, + const detail::tvec4<T>& y, const detail::tvec4<U>& b, + const detail::tvec4<T>& z, const detail::tvec4<U>& c, + const detail::tvec4<T>& w, const detail::tvec4<U>& d +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]); + U Result1 = x[i] < y[i] ? a[i] : b[i]; + U Result2 = z[i] < w[i] ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + T x, const detail::tvec2<U>& a, + T y, const detail::tvec2<U>& b, + T z, const detail::tvec2<U>& c, + T w, const detail::tvec2<U>& d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + { + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + T x, const detail::tvec3<U>& a, + T y, const detail::tvec3<U>& b, + T z, const detail::tvec3<U>& c, + T w, const detail::tvec3<U>& d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + { + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + T x, const detail::tvec4<U>& a, + T y, const detail::tvec4<U>& b, + T z, const detail::tvec4<U>& c, + T w, const detail::tvec4<U>& d +) +{ + T Test1 = min(x, y); + T Test2 = min(z, w); + + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + { + U Result1 = x < y ? a[i] : b[i]; + U Result2 = z < w ? c[i] : d[i]; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMin +( + const detail::tvec2<T>& x, U a, + const detail::tvec2<T>& y, U b, + const detail::tvec2<T>& z, U c, + const detail::tvec2<T>& w, U d +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMin +( + const detail::tvec3<T>& x, U a, + const detail::tvec3<T>& y, U b, + const detail::tvec3<T>& z, U c, + const detail::tvec3<T>& w, U d +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Min comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMin +( + const detail::tvec4<T>& x, U a, + const detail::tvec4<T>& y, U b, + const detail::tvec4<T>& z, U c, + const detail::tvec4<T>& w, U d +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + { + T Test1 = min(x[i], y[i]); + T Test2 = min(z[i], w[i]);; + U Result1 = x[i] < y[i] ? a : b; + U Result2 = z[i] < w[i] ? c : d; + Result[i] = Test1 < Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER U associatedMax(T x, U a, T y, U b) +{ + return x > y ? a : b; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + const detail::tvec2<T>& x, const detail::tvec2<U>& a, + const detail::tvec2<T>& y, const detail::tvec2<U>& b +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + const detail::tvec3<T>& x, const detail::tvec3<U>& a, + const detail::tvec3<T>& y, const detail::tvec3<U>& b +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + const detail::tvec4<T>& x, const detail::tvec4<U>& a, + const detail::tvec4<T>& y, const detail::tvec4<U>& b +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x[i] > y[i] ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + T x, const detail::tvec2<U>& a, + T y, const detail::tvec2<U>& b +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + T x, const detail::tvec3<U>& a, + T y, const detail::tvec3<U>& b +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + T x, const detail::tvec4<U>& a, + T y, const detail::tvec4<U>& b +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x > y ? a[i] : b[i]; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + const detail::tvec2<T>& x, U a, + const detail::tvec2<T>& y, U b +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + const detail::tvec3<T>& x, U a, + const detail::tvec3<T>& y, U b +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; +} + +// Max comparison between 2 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + const detail::tvec4<T>& x, U a, + const detail::tvec4<T>& y, U b +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + Result[i] = x[i] > y[i] ? a : b; + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER U associatedMax +( + T x, U a, + T y, U b, + T z, U c +) +{ + U Result = x > y ? (x > z ? a : c) : (y > z ? b : c); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + const detail::tvec2<T>& x, const detail::tvec2<U>& a, + const detail::tvec2<T>& y, const detail::tvec2<U>& b, + const detail::tvec2<T>& z, const detail::tvec2<U>& c +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + const detail::tvec3<T>& x, const detail::tvec3<U>& a, + const detail::tvec3<T>& y, const detail::tvec3<U>& b, + const detail::tvec3<T>& z, const detail::tvec3<U>& c +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + const detail::tvec4<T>& x, const detail::tvec4<U>& a, + const detail::tvec4<T>& y, const detail::tvec4<U>& b, + const detail::tvec4<T>& z, const detail::tvec4<U>& c +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + T x, const detail::tvec2<U>& a, + T y, const detail::tvec2<U>& b, + T z, const detail::tvec2<U>& c +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + T x, const detail::tvec3<U>& a, + T y, const detail::tvec3<U>& b, + T z, const detail::tvec3<U>& c +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + T x, const detail::tvec4<U>& a, + T y, const detail::tvec4<U>& b, + T z, const detail::tvec4<U>& c +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + const detail::tvec2<T>& x, U a, + const detail::tvec2<T>& y, U b, + const detail::tvec2<T>& z, U c +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + const detail::tvec3<T>& x, U a, + const detail::tvec3<T>& y, U b, + const detail::tvec3<T>& z, U c +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; +} + +// Max comparison between 3 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + const detail::tvec4<T>& x, U a, + const detail::tvec4<T>& y, U b, + const detail::tvec4<T>& z, U c +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER U associatedMax +( + T x, U a, + T y, U b, + T z, U c, + T w, U d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w);; + U Result1 = x > y ? a : b; + U Result2 = z > w ? c : d; + U Result = Test1 > Test2 ? Result1 : Result2; + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + const detail::tvec2<T>& x, const detail::tvec2<U>& a, + const detail::tvec2<T>& y, const detail::tvec2<U>& b, + const detail::tvec2<T>& z, const detail::tvec2<U>& c, + const detail::tvec2<T>& w, const detail::tvec2<U>& d +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + const detail::tvec3<T>& x, const detail::tvec3<U>& a, + const detail::tvec3<T>& y, const detail::tvec3<U>& b, + const detail::tvec3<T>& z, const detail::tvec3<U>& c, + const detail::tvec3<T>& w, const detail::tvec3<U>& d +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + const detail::tvec4<T>& x, const detail::tvec4<U>& a, + const detail::tvec4<T>& y, const detail::tvec4<U>& b, + const detail::tvec4<T>& z, const detail::tvec4<U>& c, + const detail::tvec4<T>& w, const detail::tvec4<U>& d +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]); + U Result1 = x[i] > y[i] ? a[i] : b[i]; + U Result2 = z[i] > w[i] ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + T x, const detail::tvec2<U>& a, + T y, const detail::tvec2<U>& b, + T z, const detail::tvec2<U>& c, + T w, const detail::tvec2<U>& d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::tvec2<U> Result; + for(typename detail::tvec2<U>::size_type i = 0; i < detail::tvec2<U>::value_size; ++i) + { + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + T x, const detail::tvec3<U>& a, + T y, const detail::tvec3<U>& b, + T z, const detail::tvec3<U>& c, + T w, const detail::tvec3<U>& d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::tvec3<U> Result; + for(typename detail::tvec3<U>::size_type i = 0; i < detail::tvec3<U>::value_size; ++i) + { + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + T x, const detail::tvec4<U>& a, + T y, const detail::tvec4<U>& b, + T z, const detail::tvec4<U>& c, + T w, const detail::tvec4<U>& d +) +{ + T Test1 = max(x, y); + T Test2 = max(z, w); + + detail::tvec4<U> Result; + for(typename detail::tvec4<U>::size_type i = 0; i < detail::tvec4<U>::value_size; ++i) + { + U Result1 = x > y ? a[i] : b[i]; + U Result2 = z > w ? c[i] : d[i]; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec2<U> associatedMax +( + const detail::tvec2<T>& x, U a, + const detail::tvec2<T>& y, U b, + const detail::tvec2<T>& z, U c, + const detail::tvec2<T>& w, U d +) +{ + detail::tvec2<U> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec3<U> associatedMax +( + const detail::tvec3<T>& x, U a, + const detail::tvec3<T>& y, U b, + const detail::tvec3<T>& z, U c, + const detail::tvec3<T>& w, U d +) +{ + detail::tvec3<U> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +// Max comparison between 4 variables +template<typename T, typename U> +GLM_FUNC_QUALIFIER detail::tvec4<U> associatedMax +( + const detail::tvec4<T>& x, U a, + const detail::tvec4<T>& y, U b, + const detail::tvec4<T>& z, U c, + const detail::tvec4<T>& w, U d +) +{ + detail::tvec4<U> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + { + T Test1 = max(x[i], y[i]); + T Test2 = max(z[i], w[i]);; + U Result1 = x[i] > y[i] ? a : b; + U Result2 = z[i] > w[i] ? c : d; + Result[i] = Test1 > Test2 ? Result1 : Result2; + } + return Result; +} + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/bit.hpp b/include/gal/opengl/glm/gtx/bit.hpp new file mode 100644 index 0000000..94aaae5 --- /dev/null +++ b/include/gal/opengl/glm/gtx/bit.hpp @@ -0,0 +1,140 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_bit +/// @file glm/gtx/bit.hpp +/// @date 2007-03-14 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// +/// @defgroup gtx_bit GLM_GTX_bit +/// @ingroup gtx +/// +/// @brief Allow to perform bit operations on integer values +/// +/// <glm/gtx/bit.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_bit +#define GLM_GTX_bit GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_bit extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_bit + /// @{ + + /// Build a mask of 'count' bits + /// @see gtx_bit + template <typename genIType> + genIType mask(genIType const & count); + + /// Component wise extraction of bit fields. + /// genType and genIType could be a scalar or a vector. + /// @see gtx_bit + template <typename genIUType, typename sizeType> + GLM_DEPRECATED genIUType extractField( + genIUType const & v, + sizeType const & first, + sizeType const & count); + + //! Find the lowest bit set to 1 in a integer variable. + /// @see gtx_bit + template <typename genType> + GLM_DEPRECATED int lowestBit(genType const & value); + + //! Find the highest bit set to 1 in a integer variable. + /// @see gtx_bit + template <typename genType> + GLM_DEPRECATED int highestBit(genType const & value); + + //! Find the highest bit set to 1 in a integer variable and return its value. + /// @see gtx_bit + template <typename genType> + genType highestBitValue(genType const & value); + + //! Return true if the value is a power of two number. + /// @see gtx_bit + template <typename genType> + bool isPowerOfTwo(genType const & value); + + //! Return the power of two number which value is just higher the input value. + /// @see gtx_bit + template <typename genType> + genType powerOfTwoAbove(genType const & value); + + //! Return the power of two number which value is just lower the input value. + /// @see gtx_bit + template <typename genType> + genType powerOfTwoBelow(genType const & value); + + //! Return the power of two number which value is the closet to the input value. + /// @see gtx_bit + template <typename genType> + genType powerOfTwoNearest(genType const & value); + + //! Revert all bits of any integer based type. + /// @see gtx_bit + template <typename genType> + GLM_DEPRECATED genType bitRevert(genType const & value); + + //! Rotate all bits to the right. + /// @see gtx_bit + template <typename genType> + genType bitRotateRight(genType const & In, std::size_t Shift); + + //! Rotate all bits to the left. + /// @see gtx_bit + template <typename genType> + genType bitRotateLeft(genType const & In, std::size_t Shift); + + //! Set to 1 a range of bits. + /// @see gtx_bit + template <typename genIUType> + genIUType fillBitfieldWithOne( + genIUType const & Value, + int const & FromBit, + int const & ToBit); + + //! Set to 0 a range of bits. + /// @see gtx_bit + template <typename genIUType> + genIUType fillBitfieldWithZero( + genIUType const & Value, + int const & FromBit, + int const & ToBit); + + /// @} +} //namespace glm + +#include "bit.inl" + +#endif//GLM_GTX_bit diff --git a/include/gal/opengl/glm/gtx/bit.inl b/include/gal/opengl/glm/gtx/bit.inl new file mode 100644 index 0000000..27647ae --- /dev/null +++ b/include/gal/opengl/glm/gtx/bit.inl @@ -0,0 +1,600 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-14 +// Updated : 2008-11-14 +// Licence : This source is under MIT License +// File : glm/gtx/bit.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genIType> + GLM_FUNC_QUALIFIER genIType mask + ( + genIType const & count + ) + { + return ((genIType(1) << (count)) - genIType(1)); + } + + VECTORIZE_VEC(mask) + + // extractField + template <typename genIType> + GLM_FUNC_QUALIFIER genIType extractField + ( + half const & value, + genIType const & first, + genIType const & count + ) + { + assert(first + count < sizeof(half)); + return (value._data() << first) >> ((sizeof(half) << 3) - count); + } + + template <typename genIType> + GLM_FUNC_QUALIFIER genIType extractField + ( + float const & value, + genIType const & first, + genIType const & count + ) + { + assert(first + count < sizeof(float)); + return (detail::uif32(value).i << first) >> ((sizeof(float) << 3) - count); + } + + template <typename genIType> + GLM_FUNC_QUALIFIER genIType extractField + ( + double const & value, + genIType const & first, + genIType const & count + ) + { + assert(first + count < sizeof(double)); + return (detail::uif64(value).i << first) >> ((sizeof(double) << genIType(3)) - count); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER genIUType extractField + ( + genIUType const & Value, + sizeType const & First, + sizeType const & Count + ) + { + sizeType GenSize = sizeof(genIUType) << 3; + + assert(First + Count <= GenSize); + + genIUType ShiftLeft = Count ? Value << (GenSize - (Count + First)) : 0; + genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Count); + + return ShiftBack; + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField + ( + detail::tvec2<genIUType> const & value, + sizeType const & first, + sizeType const & count + ) + { + return detail::tvec2<genIUType>( + extractField(value[0], first, count), + extractField(value[1], first, count)); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField + ( + detail::tvec3<genIUType> const & value, + sizeType const & first, + sizeType const & count + ) + { + return detail::tvec3<genIUType>( + extractField(value[0], first, count), + extractField(value[1], first, count), + extractField(value[2], first, count)); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField + ( + detail::tvec4<genIUType> const & value, + sizeType const & first, + sizeType const & count + ) + { + return detail::tvec4<genIUType>( + extractField(value[0], first, count), + extractField(value[1], first, count), + extractField(value[2], first, count), + extractField(value[3], first, count)); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField + ( + detail::tvec2<genIUType> const & value, + detail::tvec2<sizeType> const & first, + detail::tvec2<sizeType> const & count + ) + { + return detail::tvec2<genIUType>( + extractField(value[0], first[0], count[0]), + extractField(value[1], first[1], count[1])); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField + ( + detail::tvec3<genIUType> const & value, + detail::tvec3<sizeType> const & first, + detail::tvec3<sizeType> const & count + ) + { + return detail::tvec3<genIUType>( + extractField(value[0], first[0], count[0]), + extractField(value[1], first[1], count[1]), + extractField(value[2], first[2], count[2])); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField + ( + detail::tvec4<genIUType> const & value, + detail::tvec4<sizeType> const & first, + detail::tvec4<sizeType> const & count + ) + { + return detail::tvec4<genIUType>( + extractField(value[0], first[0], count[0]), + extractField(value[1], first[1], count[1]), + extractField(value[2], first[2], count[2]), + extractField(value[3], first[3], count[3])); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField + ( + genIUType const & value, + detail::tvec2<sizeType> const & first, + detail::tvec2<sizeType> const & count + ) + { + return detail::tvec2<genIUType>( + extractField(value, first[0], count[0]), + extractField(value, first[1], count[1])); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField + ( + genIUType const & value, + detail::tvec3<sizeType> const & first, + detail::tvec3<sizeType> const & count + ) + { + return detail::tvec3<genIUType>( + extractField(value, first[0], count[0]), + extractField(value, first[1], count[1]), + extractField(value, first[2], count[2])); + } + + template <typename genIUType, typename sizeType> + GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField + ( + genIUType const & value, + detail::tvec4<sizeType> const & first, + detail::tvec4<sizeType> const & count + ) + { + return detail::tvec4<genIUType>( + extractField(value, first[0], count[0]), + extractField(value, first[1], count[1]), + extractField(value, first[2], count[2]), + extractField(value, first[3], count[3])); + } + + // lowestBit + template <typename genType> + GLM_FUNC_QUALIFIER int lowestBit + ( + genType const & Value + ) + { + assert(Value != genType(0)); // not valid call + + genType Bit; + for(Bit = genType(0); !(Value & (1 << Bit)); ++Bit){} + return Bit; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<int> lowestBit + ( + detail::tvec2<valType> const & value + ) + { + return detail::tvec2<int>( + lowestBit(value[0]), + lowestBit(value[1])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<int> lowestBit + ( + detail::tvec3<valType> const & value + ) + { + return detail::tvec3<int>( + lowestBit(value[0]), + lowestBit(value[1]), + lowestBit(value[2])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<int> lowestBit + ( + detail::tvec4<valType> const & value + ) + { + return detail::tvec4<int>( + lowestBit(value[0]), + lowestBit(value[1]), + lowestBit(value[2]), + lowestBit(value[3])); + } + + // highestBit + template <typename genType> + GLM_FUNC_QUALIFIER int highestBit + ( + genType const & value + ) + { + assert(value != genType(0)); // not valid call + + genType bit = genType(-1); + for(genType tmp = value; tmp; tmp >>= 1, ++bit){} + return bit; + } + + //template <> + //GLM_FUNC_QUALIFIER int highestBit<int> + //( + // int value + //) + //{ + // int bit = -1; + // for(int tmp = value; tmp; tmp >>= 1, ++bit); + // return bit; + //} + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<int> highestBit + ( + detail::tvec2<valType> const & value + ) + { + return detail::tvec2<int>( + highestBit(value[0]), + highestBit(value[1])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<int> highestBit + ( + detail::tvec3<valType> const & value + ) + { + return detail::tvec3<int>( + highestBit(value[0]), + highestBit(value[1]), + highestBit(value[2])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<int> highestBit + ( + detail::tvec4<valType> const & value + ) + { + return detail::tvec4<int>( + highestBit(value[0]), + highestBit(value[1]), + highestBit(value[2]), + highestBit(value[3])); + } + + // highestBitValue + template <typename genType> + GLM_FUNC_QUALIFIER genType highestBitValue + ( + genType const & value + ) + { + genType tmp = value; + genType result = genType(0); + while(tmp) + { + result = (tmp & (~tmp + 1)); // grab lowest bit + tmp &= ~result; // clear lowest bit + } + return result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<int> highestBitValue + ( + detail::tvec2<valType> const & value + ) + { + return detail::tvec2<int>( + highestBitValue(value[0]), + highestBitValue(value[1])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<int> highestBitValue + ( + detail::tvec3<valType> const & value + ) + { + return detail::tvec3<int>( + highestBitValue(value[0]), + highestBitValue(value[1]), + highestBitValue(value[2])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<int> highestBitValue + ( + detail::tvec4<valType> const & value + ) + { + return detail::tvec4<int>( + highestBitValue(value[0]), + highestBitValue(value[1]), + highestBitValue(value[2]), + highestBitValue(value[3])); + } + + // isPowerOfTwo + template <typename genType> + GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType const & Value) + { + //detail::If<std::numeric_limits<genType>::is_signed>::apply(abs, Value); + //return !(Value & (Value - 1)); + + // For old complier? + genType Result = Value; + if(std::numeric_limits<genType>::is_signed) + Result = abs(Result); + return !(Result & (Result - 1)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<bool> isPowerOfTwo + ( + detail::tvec2<valType> const & value + ) + { + return detail::tvec2<bool>( + isPowerOfTwo(value[0]), + isPowerOfTwo(value[1])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<bool> isPowerOfTwo + ( + detail::tvec3<valType> const & value + ) + { + return detail::tvec3<bool>( + isPowerOfTwo(value[0]), + isPowerOfTwo(value[1]), + isPowerOfTwo(value[2])); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<bool> isPowerOfTwo + ( + detail::tvec4<valType> const & value + ) + { + return detail::tvec4<bool>( + isPowerOfTwo(value[0]), + isPowerOfTwo(value[1]), + isPowerOfTwo(value[2]), + isPowerOfTwo(value[3])); + } + + // powerOfTwoAbove + template <typename genType> + GLM_FUNC_QUALIFIER genType powerOfTwoAbove(genType const & value) + { + return isPowerOfTwo(value) ? value : highestBitValue(value) << 1; + } + + VECTORIZE_VEC(powerOfTwoAbove) + + // powerOfTwoBelow + template <typename genType> + GLM_FUNC_QUALIFIER genType powerOfTwoBelow + ( + genType const & value + ) + { + return isPowerOfTwo(value) ? value : highestBitValue(value); + } + + VECTORIZE_VEC(powerOfTwoBelow) + + // powerOfTwoNearest + template <typename genType> + GLM_FUNC_QUALIFIER genType powerOfTwoNearest + ( + genType const & value + ) + { + if(isPowerOfTwo(value)) + return value; + + genType prev = highestBitValue(value); + genType next = prev << 1; + return (next - value) < (value - prev) ? next : prev; + } + + VECTORIZE_VEC(powerOfTwoNearest) + + template <typename genType> + GLM_FUNC_QUALIFIER genType bitRevert(genType const & In) + { + GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values"); + + genType Out = 0; + std::size_t BitSize = sizeof(genType) * 8; + for(std::size_t i = 0; i < BitSize; ++i) + if(In & (genType(1) << i)) + Out |= genType(1) << (BitSize - 1 - i); + return Out; + } + + VECTORIZE_VEC(bitRevert) + + template <typename genType> + GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift) + { + GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateRight' only accept integer values"); + + std::size_t BitSize = sizeof(genType) * 8; + return (In << Shift) | (In >> (BitSize - Shift)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateRight + ( + detail::tvec2<valType> const & Value, + std::size_t Shift + ) + { + return detail::tvec2<valType>( + bitRotateRight(Value[0], Shift), + bitRotateRight(Value[1], Shift)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateRight + ( + detail::tvec3<valType> const & Value, + std::size_t Shift + ) + { + return detail::tvec3<valType>( + bitRotateRight(Value[0], Shift), + bitRotateRight(Value[1], Shift), + bitRotateRight(Value[2], Shift)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateRight + ( + detail::tvec4<valType> const & Value, + std::size_t Shift + ) + { + return detail::tvec4<valType>( + bitRotateRight(Value[0], Shift), + bitRotateRight(Value[1], Shift), + bitRotateRight(Value[2], Shift), + bitRotateRight(Value[3], Shift)); + } + + template <typename genType> + GLM_FUNC_QUALIFIER genType bitRotateLeft(genType const & In, std::size_t Shift) + { + GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateLeft' only accept integer values"); + + std::size_t BitSize = sizeof(genType) * 8; + return (In >> Shift) | (In << (BitSize - Shift)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateLeft + ( + detail::tvec2<valType> const & Value, + std::size_t Shift + ) + { + return detail::tvec2<valType>( + bitRotateLeft(Value[0], Shift), + bitRotateLeft(Value[1], Shift)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateLeft + ( + detail::tvec3<valType> const & Value, + std::size_t Shift + ) + { + return detail::tvec3<valType>( + bitRotateLeft(Value[0], Shift), + bitRotateLeft(Value[1], Shift), + bitRotateLeft(Value[2], Shift)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateLeft + ( + detail::tvec4<valType> const & Value, + std::size_t Shift + ) + { + return detail::tvec4<valType>( + bitRotateLeft(Value[0], Shift), + bitRotateLeft(Value[1], Shift), + bitRotateLeft(Value[2], Shift), + bitRotateLeft(Value[3], Shift)); + } + + template <typename genIUType> + GLM_FUNC_QUALIFIER genIUType fillBitfieldWithOne + ( + genIUType const & Value, + int const & FromBit, + int const & ToBit + ) + { + assert(FromBit <= ToBit); + assert(ToBit <= sizeof(genIUType) * std::size_t(8)); + + genIUType Result = Value; + for(std::size_t i = 0; i <= ToBit; ++i) + Result |= (1 << i); + return Result; + } + + template <typename genIUType> + GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero + ( + genIUType const & Value, + int const & FromBit, + int const & ToBit + ) + { + assert(FromBit <= ToBit); + assert(ToBit <= sizeof(genIUType) * std::size_t(8)); + + genIUType Result = Value; + for(std::size_t i = 0; i <= ToBit; ++i) + Result &= ~(1 << i); + return Result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/closest_point.hpp b/include/gal/opengl/glm/gtx/closest_point.hpp new file mode 100644 index 0000000..7f79556 --- /dev/null +++ b/include/gal/opengl/glm/gtx/closest_point.hpp @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_bit +/// @file glm/gtx/bit.hpp +/// @date 2005-12-30 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_closest_point GLM_GTX_closest_point +/// @ingroup gtx +/// +/// @brief Find the point on a straight line which is the closet of a point. +/// +/// <glm/gtx/closest_point.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_closest_point +#define GLM_GTX_closest_point GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_closest_point extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_closest_point + /// @{ + + /// Find the point on a straight line which is the closet of a point. + /// @see gtx_closest_point + template <typename T> + detail::tvec3<T> closestPointOnLine( + detail::tvec3<T> const & point, + detail::tvec3<T> const & a, + detail::tvec3<T> const & b); + + /// @} +}// namespace glm + +#include "closest_point.inl" + +#endif//GLM_GTX_closest_point diff --git a/include/gal/opengl/glm/gtx/closest_point.inl b/include/gal/opengl/glm/gtx/closest_point.inl new file mode 100644 index 0000000..d018c1d --- /dev/null +++ b/include/gal/opengl/glm/gtx/closest_point.inl @@ -0,0 +1,36 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-30 +// Updated : 2008-10-05 +// Licence : This source is under MIT License +// File : glm/gtx/closest_point.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_gtx_closest_point +#define glm_gtx_closest_point + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine + ( + detail::tvec3<valType> const & point, + detail::tvec3<valType> const & a, + detail::tvec3<valType> const & b + ) + { + valType LineLength = distance(a, b); + detail::tvec3<valType> Vector = point - a; + detail::tvec3<valType> LineDirection = (b - a) / LineLength; + + // Project Vector to LineDirection to get the distance of point from a + valType Distance = dot(Vector, LineDirection); + + if(Distance <= valType(0)) return a; + if(Distance >= LineLength) return b; + return a + LineDirection * Distance; + } +}//namespace glm + +#endif//glm_gtx_closest_point diff --git a/include/gal/opengl/glm/gtx/color_cast.hpp b/include/gal/opengl/glm/gtx/color_cast.hpp new file mode 100644 index 0000000..5dada88 --- /dev/null +++ b/include/gal/opengl/glm/gtx/color_cast.hpp @@ -0,0 +1,124 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_color_cast +/// @file glm/gtx/color_cast.hpp +/// @date 2007-06-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_number_precision (dependence) +/// +/// @defgroup gtx_color_cast GLM_GTX_color_cast +/// @ingroup gtx +/// +/// @brief Conversion between two color types. +/// +/// <glm/gtx/color_cast.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_color_cast +#define GLM_GTX_color_cast GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/number_precision.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_color_cast extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_color_cast + /// @{ + + //! Conversion of a floating value into a 8bit unsigned int value. + /// @see gtx_color_cast + template <typename valType> uint8 u8channel_cast(valType a); + + /// Conversion of a floating value into a 16bit unsigned int value. + /// @see gtx_color_cast + template <typename valType> uint16 u16channel_cast(valType a); + + template <typename T> uint32 u32_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint32 u32_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint32 u32_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint32 u32_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + + template <typename T> uint32 u32_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint32 u32_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint32 u32_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint32 u32_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 32bit unsigned int value. (From GLM_GTX_color_cast extension) + + template <typename T> uint64 u64_rgbx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint64 u64_xrgb_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint64 u64_bgrx_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint64 u64_xbgr_cast(const detail::tvec3<T>& c); //!< \brief Conversion of a 3 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + + template <typename T> uint64 u64_rgba_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint64 u64_argb_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint64 u64_bgra_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + template <typename T> uint64 u64_abgr_cast(const detail::tvec4<T>& c); //!< \brief Conversion of a 4 components color into an 64bit unsigned int value. (From GLM_GTX_color_cast extension) + + template <typename T> f16 f16_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template <typename T> f16vec3 f16_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f16vec3 f16_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f16vec3 f16_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f16vec3 f16_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template <typename T> f16vec4 f16_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f16vec4 f16_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f16vec4 f16_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f16vec4 f16_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + template <typename T> f32 f32_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template <typename T> f32vec3 f32_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f32vec3 f32_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f32vec3 f32_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f32vec3 f32_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template <typename T> f32vec4 f32_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f32vec4 f32_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f32vec4 f32_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f32vec4 f32_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + template <typename T> f64 f64_channel_cast(T a); //!< \brief Conversion of a u8 or u16 value to a single channel floating value. (From GLM_GTX_color_cast extension) + + template <typename T> f64vec3 f64_rgbx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f64vec3 f64_xrgb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f64vec3 f64_bgrx_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f64vec3 f64_xbgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 3 components floating color. (From GLM_GTX_color_cast extension) + + template <typename T> f64vec4 f64_rgba_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f64vec4 f64_argb_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f64vec4 f64_bgra_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + template <typename T> f64vec4 f64_abgr_cast(T c); //!< \brief Conversion of a u32 or u64 color into 4 components floating color. (From GLM_GTX_color_cast extension) + + /// @} +}//namespace glm + +#include "color_cast.inl" + +#endif//GLM_GTX_color_cast diff --git a/include/gal/opengl/glm/gtx/color_cast.inl b/include/gal/opengl/glm/gtx/color_cast.inl new file mode 100644 index 0000000..55fd1ce --- /dev/null +++ b/include/gal/opengl/glm/gtx/color_cast.inl @@ -0,0 +1,733 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-06-21 +// Updated : 2007-08-03 +// Licence : This source is under MIT License +// File : glm/gtx/color_cast.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER uint8 u8channel_cast(T a) + { + return static_cast<uint8>(a * T(255)); + } + + template <typename T> + GLM_FUNC_QUALIFIER uint16 u16channel_cast(T a) + { + return static_cast<uint16>(a * T(65535)); + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_rgbx_cast(const detail::tvec3<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 0; + result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 16; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_xrgb_cast(const detail::tvec3<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 24; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_bgrx_cast(const detail::tvec3<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_xbgr_cast(const detail::tvec3<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec3<T>::value_type(255)) << 24; + result += static_cast<uint32>(c.y * detail::tvec3<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.z * detail::tvec3<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.w * detail::tvec3<T>::value_type(255)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_rgba_cast(const detail::tvec4<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 0; + result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 24; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_argb_cast(const detail::tvec4<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 24; + result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_bgra_cast(const detail::tvec4<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 0; + result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 24; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint32 u32_abgr_cast(const detail::tvec4<T>& c) + { + uint32 result = 0; + result += static_cast<uint32>(c.x * detail::tvec4<T>::value_type(255)) << 24; + result += static_cast<uint32>(c.y * detail::tvec4<T>::value_type(255)) << 16; + result += static_cast<uint32>(c.z * detail::tvec4<T>::value_type(255)) << 8; + result += static_cast<uint32>(c.w * detail::tvec4<T>::value_type(255)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u64_rgbx_cast(const detail::tvec3<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 0; + result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 32; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u32_xrgb_cast(const detail::tvec3<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 48; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u32_bgrx_cast(const detail::tvec3<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u32_xbgr_cast(const detail::tvec3<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec3<T>::value_type(65535)) << 48; + result += static_cast<uint64>(c.y * detail::tvec3<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.z * detail::tvec3<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.w * detail::tvec3<T>::value_type(65535)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u64_rgba_cast(const detail::tvec4<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 0; + result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 48; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u64_argb_cast(const detail::tvec4<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 48; + result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 0; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u64_bgra_cast(const detail::tvec4<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 0; + result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 48; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER uint64 u64_abgr_cast(const detail::tvec4<T>& c) + { + uint64 result = 0; + result += static_cast<uint64>(c.x * detail::tvec4<T>::value_type(65535)) << 48; + result += static_cast<uint64>(c.y * detail::tvec4<T>::value_type(65535)) << 32; + result += static_cast<uint64>(c.z * detail::tvec4<T>::value_type(65535)) << 16; + result += static_cast<uint64>(c.w * detail::tvec4<T>::value_type(65535)) << 0; + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16 f16_channel_cast<uint32>(uint32 color) + { + return f16(static_cast<float>(color >> 0) / static_cast<float>(255)); + } + + template <> + GLM_FUNC_QUALIFIER f16vec3 f16_rgbx_cast<uint32>(uint32 color) + { + f16vec3 result; + result.x = f16(static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec3 f16_xrgb_cast<uint32>(uint32 color) + { + f16vec3 result; + result.x = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec3 f16_bgrx_cast<uint32>(uint32 color) + { + f16vec3 result; + result.x = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec3 f16_xbgr_cast<uint32>(uint32 color) + { + f16vec3 result; + result.x = f16(static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec4 f16_rgba_cast<uint32>(uint32 color) + { + f16vec4 result; + result.x = f16(static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.w = f16(static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec4 f16_argb_cast<uint32>(uint32 color) + { + f16vec4 result; + result.x = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255)); + result.w = f16(static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec4 f16_bgra_cast<uint32>(uint32 color) + { + f16vec4 result; + result.x = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255)); + result.w = f16(static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER f16vec4 f16_abgr_cast<uint32>(uint32 color) + { + f16vec4 result; + result.x = f16(static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255)); + result.y = f16(static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255)); + result.z = f16(static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255)); + result.w = f16(static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER float f32_channel_cast<uint8>(uint8 color) + { + return static_cast<float>(color >> 0) / static_cast<float>(255); + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_rgbx_cast<uint32>(uint32 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_xrgb_cast<uint32>(uint32 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_bgrx_cast<uint32>(uint32 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_xbgr_cast<uint32>(uint32 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_rgba_cast<uint32>(uint32 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.w = static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_argb_cast<uint32>(uint32 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255); + result.w = static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_bgra_cast<uint32>(uint32 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255); + result.w = static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_abgr_cast<uint32>(uint32 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 24) & 0xFF) / static_cast<float>(255); + result.y = static_cast<float>((color >> 16) & 0xFF) / static_cast<float>(255); + result.z = static_cast<float>((color >> 8) & 0xFF) / static_cast<float>(255); + result.w = static_cast<float>((color >> 0) & 0xFF) / static_cast<float>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER double f64_channel_cast<uint8>(uint8 color) + { + return static_cast<double>(color >> 0) / static_cast<double>(255); + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_rgbx_cast<uint32>(uint32 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 0) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_xrgb_cast<uint32>(uint32 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 24) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_bgrx_cast<uint32>(uint32 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 0) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_xbgr_cast<uint32>(uint32 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 24) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_rgba_cast<uint32>(uint32 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 0) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.w = static_cast<double>((color >> 24) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_argb_cast<uint32>(uint32 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 24) & 0xFF) / static_cast<double>(255); + result.w = static_cast<double>((color >> 0) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_bgra_cast<uint32>(uint32 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 0) & 0xFF) / static_cast<double>(255); + result.w = static_cast<double>((color >> 24) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_abgr_cast<uint32>(uint32 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 24) & 0xFF) / static_cast<double>(255); + result.y = static_cast<double>((color >> 16) & 0xFF) / static_cast<double>(255); + result.z = static_cast<double>((color >> 8) & 0xFF) / static_cast<double>(255); + result.w = static_cast<double>((color >> 0) & 0xFF) / static_cast<double>(255); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::half f16_channel_cast<uint16>(uint16 color) + { + return detail::half(static_cast<float>(color >> 0) / static_cast<float>(65535)); + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<detail::half> f16_rgbx_cast<uint64>(uint64 color) + { + detail::tvec3<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<detail::half> f16_xrgb_cast<uint64>(uint64 color) + { + detail::tvec3<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<detail::half> f16_bgrx_cast<uint64>(uint64 color) + { + detail::tvec3<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<detail::half> f16_xbgr_cast<uint64>(uint64 color) + { + detail::tvec3<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<detail::half> f16_rgba_cast<uint64>(uint64 color) + { + detail::tvec4<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.w = detail::half(static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<detail::half> f16_argb_cast<uint64>(uint64 color) + { + detail::tvec4<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535)); + result.w = detail::half(static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<detail::half> f16_bgra_cast<uint64>(uint64 color) + { + detail::tvec4<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535)); + result.w = detail::half(static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<detail::half> f16_abgr_cast<uint64>(uint64 color) + { + detail::tvec4<detail::half> result; + result.x = detail::half(static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535)); + result.y = detail::half(static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535)); + result.z = detail::half(static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535)); + result.w = detail::half(static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535)); + return result; + } + + template <> + GLM_FUNC_QUALIFIER float f32_channel_cast<uint16>(uint16 color) + { + return static_cast<float>(color >> 0) / static_cast<float>(65535); + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_rgbx_cast<uint64>(uint64 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_xrgb_cast<uint64>(uint64 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_bgrx_cast<uint64>(uint64 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<float> f32_xbgr_cast<uint64>(uint64 color) + { + detail::tvec3<float> result; + result.x = static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_rgba_cast<uint64>(uint64 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.w = static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_argb_cast<uint64>(uint64 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535); + result.w = static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_bgra_cast<uint64>(uint64 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535); + result.w = static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<float> f32_abgr_cast<uint64>(uint64 color) + { + detail::tvec4<float> result; + result.x = static_cast<float>((color >> 48) & 0xFFFF) / static_cast<float>(65535); + result.y = static_cast<float>((color >> 32) & 0xFFFF) / static_cast<float>(65535); + result.z = static_cast<float>((color >> 16) & 0xFFFF) / static_cast<float>(65535); + result.w = static_cast<float>((color >> 0) & 0xFFFF) / static_cast<float>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER double f64_channel_cast<uint16>(uint16 color) + { + return static_cast<double>(color >> 0) / static_cast<double>(65535); + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_rgbx_cast<uint64>(uint64 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_xrgb_cast<uint64>(uint64 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 48) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_bgrx_cast<uint64>(uint64 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec3<double> f64_xbgr_cast<uint64>(uint64 color) + { + detail::tvec3<double> result; + result.x = static_cast<double>((color >> 48) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_rgba_cast<uint64>(uint64 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.w = static_cast<double>((color >> 48) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_argb_cast<uint64>(uint64 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 48) & 0xFFFF) / static_cast<double>(65535); + result.w = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_bgra_cast<uint64>(uint64 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); + result.w = static_cast<double>((color >> 48) & 0xFFFF) / static_cast<double>(65535); + return result; + } + + template <> + GLM_FUNC_QUALIFIER detail::tvec4<double> f64_abgr_cast<uint64>(uint64 color) + { + detail::tvec4<double> result; + result.x = static_cast<double>((color >> 48) & 0xFFFF) / static_cast<double>(65535); + result.y = static_cast<double>((color >> 32) & 0xFFFF) / static_cast<double>(65535); + result.z = static_cast<double>((color >> 16) & 0xFFFF) / static_cast<double>(65535); + result.w = static_cast<double>((color >> 0) & 0xFFFF) / static_cast<double>(65535); + return result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/color_space.hpp b/include/gal/opengl/glm/gtx/color_space.hpp new file mode 100644 index 0000000..f144378 --- /dev/null +++ b/include/gal/opengl/glm/gtx/color_space.hpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_color_space +/// @file glm/gtx/color_space.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_color_space GLM_GTX_color_space +/// @ingroup gtx +/// +/// @brief Related to RGB to HSV conversions and operations. +/// +/// <glm/gtx/color_space.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_color_space +#define GLM_GTX_color_space GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_color_space extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_color_space + /// @{ + + /// Converts a color from HSV color space to its color in RGB color space. + /// @see gtx_color_space + template <typename valType> + detail::tvec3<valType> rgbColor( + detail::tvec3<valType> const & hsvValue); + + /// Converts a color from RGB color space to its color in HSV color space. + /// @see gtx_color_space + template <typename valType> + detail::tvec3<valType> hsvColor( + detail::tvec3<valType> const & rgbValue); + + /// Build a saturation matrix. + /// @see gtx_color_space + template <typename valType> + detail::tmat4x4<valType> saturation( + valType const s); + + /// Modify the saturation of a color. + /// @see gtx_color_space + template <typename valType> + detail::tvec3<valType> saturation( + valType const s, + detail::tvec3<valType> const & color); + + /// Modify the saturation of a color. + /// @see gtx_color_space + template <typename valType> + detail::tvec4<valType> saturation( + valType const s, + detail::tvec4<valType> const & color); + + /// Compute color luminosity associating ratios (0.33, 0.59, 0.11) to RGB canals. + /// @see gtx_color_space + template <typename valType> + valType luminosity( + detail::tvec3<valType> const & color); + + /// @} +}//namespace glm + +#include "color_space.inl" + +#endif//GLM_GTX_color_space diff --git a/include/gal/opengl/glm/gtx/color_space.inl b/include/gal/opengl/glm/gtx/color_space.inl new file mode 100644 index 0000000..15cdc35 --- /dev/null +++ b/include/gal/opengl/glm/gtx/color_space.inl @@ -0,0 +1,149 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-02-22 +// Licence : This source is under MIT License +// File : glm/gtx/color_space.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor) + { + detail::tvec3<T> hsv = hsvColor; + detail::tvec3<T> rgbColor; + + if(hsv.y == T(0)) + // achromatic (grey) + rgbColor = detail::tvec3<T>(hsv.z); + else + { + T sector = floor(hsv.x / T(60)); + T frac = (hsv.x / T(60)) - sector; + // factorial part of h + T o = hsv.z * (T(1) - hsv.y); + T p = hsv.z * (T(1) - hsv.y * frac); + T q = hsv.z * (T(1) - hsv.y * (T(1) - frac)); + + switch(int(sector)) + { + default: + case 0: + rgbColor.r = hsv.z; + rgbColor.g = q; + rgbColor.b = o; + break; + case 1: + rgbColor.r = p; + rgbColor.g = hsv.z; + rgbColor.b = o; + break; + case 2: + rgbColor.r = o; + rgbColor.g = hsv.z; + rgbColor.b = q; + break; + case 3: + rgbColor.r = o; + rgbColor.g = p; + rgbColor.b = hsv.z; + break; + case 4: + rgbColor.r = q; + rgbColor.g = o; + rgbColor.b = hsv.z; + break; + case 5: + rgbColor.r = hsv.z; + rgbColor.g = o; + rgbColor.b = p; + break; + } + } + + return rgbColor; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor) + { + detail::tvec3<T> hsv = rgbColor; + float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b); + float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b); + float Delta = Max - Min; + + hsv.z = Max; + + if(Max != T(0)) + { + hsv.y = Delta / hsv.z; + T h = T(0); + + if(rgbColor.r == Max) + // between yellow & magenta + h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta; + else if(rgbColor.g == Max) + // between cyan & yellow + h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta; + else + // between magenta & cyan + h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta; + + if(h < T(0)) + hsv.x = h + T(360); + else + hsv.x = h; + } + else + { + // If r = g = b = 0 then s = 0, h is undefined + hsv.y = T(0); + hsv.x = T(0); + } + + return hsv; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s) + { + detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722)); + + T col0 = (T(1) - s) * rgbw.r; + T col1 = (T(1) - s) * rgbw.g; + T col2 = (T(1) - s) * rgbw.b; + + detail::tmat4x4<T> result(T(1)); + result[0][0] = col0 + s; + result[0][1] = col0; + result[0][2] = col0; + result[1][0] = col1; + result[1][1] = col1 + s; + result[1][2] = col1; + result[2][0] = col2; + result[2][1] = col2; + result[2][2] = col2 + s; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color) + { + return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0))); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color) + { + return saturation(s) * color; + } + + template <typename T> + GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color) + { + const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11); + return dot(color, tmp); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/color_space_YCoCg.hpp b/include/gal/opengl/glm/gtx/color_space_YCoCg.hpp new file mode 100644 index 0000000..8ca4b10 --- /dev/null +++ b/include/gal/opengl/glm/gtx/color_space_YCoCg.hpp @@ -0,0 +1,84 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_color_space_YCoCg +/// @file glm/gtx/color_space_YCoCg.hpp +/// @date 2008-10-28 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_color_space_YCoCg GLM_GTX_color_space_YCoCg +/// @ingroup gtx +/// +/// @brief RGB to YCoCg conversions and operations +/// +/// <glm/gtx/color_space_YCoCg.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef glm_gtx_color_space_YCoCg +#define glm_gtx_color_space_YCoCg GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_color_space_YCoCg extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_color_space_YCoCg + /// @{ + + /// Convert a color from RGB color space to YCoCg color space. + /// @see gtx_color_space_YCoCg + template <typename valType> + detail::tvec3<valType> rgb2YCoCg( + detail::tvec3<valType> const & rgbColor); + + /// Convert a color from YCoCg color space to RGB color space. + /// @see gtx_color_space_YCoCg + template <typename valType> + detail::tvec3<valType> YCoCg2rgb( + detail::tvec3<valType> const & YCoCgColor); + + /// Convert a color from RGB color space to YCoCgR color space. + /// @see "YCoCg-R: A Color Space with RGB Reversibility and Low Dynamic Range" + /// @see gtx_color_space_YCoCg + template <typename valType> + detail::tvec3<valType> rgb2YCoCgR( + detail::tvec3<valType> const & rgbColor); + + /// Convert a color from YCoCgR color space to RGB color space. + /// @see "YCoCg-R: A Color Space with RGB Reversibility and Low Dynamic Range" + /// @see gtx_color_space_YCoCg + template <typename valType> + detail::tvec3<valType> YCoCgR2rgb( + detail::tvec3<valType> const & YCoCgColor); + + /// @} +}//namespace glm + +#include "color_space_YCoCg.inl" + +#endif//glm_gtx_color_space_YCoCg diff --git a/include/gal/opengl/glm/gtx/color_space_YCoCg.inl b/include/gal/opengl/glm/gtx/color_space_YCoCg.inl new file mode 100644 index 0000000..08d8440 --- /dev/null +++ b/include/gal/opengl/glm/gtx/color_space_YCoCg.inl @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-10-28 +// Updated : 2008-10-28 +// Licence : This source is under MIT License +// File : glm/gtx/color_space_YCoCg.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg + ( + detail::tvec3<valType> const & rgbColor + ) + { + detail::tvec3<valType> result; + result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4); + result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2); + result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4); + return result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR + ( + detail::tvec3<valType> const & rgbColor + ) + { + detail::tvec3<valType> result; + result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4); + result.y/*Co*/ = rgbColor.r - rgbColor.b; + result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2); + return result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb + ( + detail::tvec3<valType> const & YCoCgColor + ) + { + detail::tvec3<valType> result; + result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z; + result.g = YCoCgColor.x + YCoCgColor.z; + result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z; + return result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb + ( + detail::tvec3<valType> const & YCoCgRColor + ) + { + detail::tvec3<valType> result; + valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2)); + result.g = YCoCgRColor.z + tmp; + result.b = tmp - (YCoCgRColor.y / valType(2)); + result.r = result.b + YCoCgRColor.y; + return result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/compatibility.hpp b/include/gal/opengl/glm/gtx/compatibility.hpp new file mode 100644 index 0000000..c394a43 --- /dev/null +++ b/include/gal/opengl/glm/gtx/compatibility.hpp @@ -0,0 +1,176 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_compatibility +/// @file glm/gtx/compatibility.hpp +/// @date 2007-01-24 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// +/// @defgroup gtx_compatibility GLM_GTX_compatibility +/// @ingroup gtx +/// +/// @brief Provide functions to increase the compatibility with Cg and HLSL languages +/// +/// <glm/gtx/compatibility.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_compatibility +#define GLM_GTX_compatibility GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtc/quaternion.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_compatibility extension included") +#endif + +#if(GLM_COMPILER & GLM_COMPILER_VC) +# include <cfloat> +#elif(GLM_COMPILER & GLM_COMPILER_GCC) +# include <cmath> +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) +# undef isfinite +# endif +#endif//GLM_COMPILER + +namespace glm +{ + /// @addtogroup gtx_compatibility + /// @{ + + template <typename T> GLM_FUNC_QUALIFIER T lerp(T x, T y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec2<T> lerp(const detail::tvec2<T>& x, const detail::tvec2<T>& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec3<T> lerp(const detail::tvec3<T>& x, const detail::tvec3<T>& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec4<T> lerp(const detail::tvec4<T>& x, const detail::tvec4<T>& y, T a){return mix(x, y, a);} //!< \brief Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec2<T> lerp(const detail::tvec2<T>& x, const detail::tvec2<T>& y, const detail::tvec2<T>& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec3<T> lerp(const detail::tvec3<T>& x, const detail::tvec3<T>& y, const detail::tvec3<T>& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec4<T> lerp(const detail::tvec4<T>& x, const detail::tvec4<T>& y, const detail::tvec4<T>& a){return mix(x, y, a);} //!< \brief Returns the component-wise result of x * (1.0 - a) + y * a, i.e., the linear blend of x and y using vector a. The value for a is not restricted to the range [0, 1]. (From GLM_GTX_compatibility) + + template <typename T> GLM_FUNC_QUALIFIER T slerp(detail::tquat<T> const & x, detail::tquat<T> const & y, T const & a){return mix(x, y, a);} //!< \brief Returns the slurp interpolation between two quaternions. + + template <typename T> GLM_FUNC_QUALIFIER T saturate(T x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec2<T> saturate(const detail::tvec2<T>& x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec3<T> saturate(const detail::tvec3<T>& x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec4<T> saturate(const detail::tvec4<T>& x){return clamp(x, T(0), T(1));} //!< \brief Returns clamp(x, 0, 1) for each component in x. (From GLM_GTX_compatibility) + + template <typename T> GLM_FUNC_QUALIFIER T atan2(T x, T y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec2<T> atan2(const detail::tvec2<T>& x, const detail::tvec2<T>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec3<T> atan2(const detail::tvec3<T>& x, const detail::tvec3<T>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) + template <typename T> GLM_FUNC_QUALIFIER detail::tvec4<T> atan2(const detail::tvec4<T>& x, const detail::tvec4<T>& y){return atan(x, y);} //!< \brief Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0. (From GLM_GTX_compatibility) + + template <typename genType> bool isfinite(genType const & x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template <typename valType> detail::tvec2<bool> isfinite(const detail::tvec2<valType>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template <typename valType> detail::tvec3<bool> isfinite(const detail::tvec3<valType>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + template <typename valType> detail::tvec4<bool> isfinite(const detail::tvec4<valType>& x); //!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility) + + typedef bool bool1; //!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tvec2<bool> bool2; //!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec3<bool> bool3; //!< \brief boolean type with 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec4<bool> bool4; //!< \brief boolean type with 4 components. (From GLM_GTX_compatibility extension) + + typedef bool bool1x1; //!< \brief boolean matrix with 1 x 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x2<bool> bool2x2; //!< \brief boolean matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x3<bool> bool2x3; //!< \brief boolean matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x4<bool> bool2x4; //!< \brief boolean matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x2<bool> bool3x2; //!< \brief boolean matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x3<bool> bool3x3; //!< \brief boolean matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x4<bool> bool3x4; //!< \brief boolean matrix with 3 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x2<bool> bool4x2; //!< \brief boolean matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x3<bool> bool4x3; //!< \brief boolean matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x4<bool> bool4x4; //!< \brief boolean matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) + + typedef int int1; //!< \brief integer vector with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tvec2<int> int2; //!< \brief integer vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec3<int> int3; //!< \brief integer vector with 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec4<int> int4; //!< \brief integer vector with 4 components. (From GLM_GTX_compatibility extension) + + typedef int int1x1; //!< \brief integer matrix with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x2<int> int2x2; //!< \brief integer matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x3<int> int2x3; //!< \brief integer matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x4<int> int2x4; //!< \brief integer matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x2<int> int3x2; //!< \brief integer matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x3<int> int3x3; //!< \brief integer matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x4<int> int3x4; //!< \brief integer matrix with 3 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x2<int> int4x2; //!< \brief integer matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x3<int> int4x3; //!< \brief integer matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x4<int> int4x4; //!< \brief integer matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) + + typedef detail::half half1; //!< \brief half-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tvec2<detail::half> half2; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec3<detail::half> half3; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec4<detail::half> half4; //!< \brief half-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + + typedef detail::half half1x1; //!< \brief half-precision floating-point matrix with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x2<detail::half> half2x2; //!< \brief half-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x3<detail::half> half2x3; //!< \brief half-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x4<detail::half> half2x4; //!< \brief half-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x2<detail::half> half3x2; //!< \brief half-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x3<detail::half> half3x3; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x4<detail::half> half3x4; //!< \brief half-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x2<detail::half> half4x2; //!< \brief half-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x3<detail::half> half4x3; //!< \brief half-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x4<detail::half> half4x4; //!< \brief half-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) + + typedef float float1; //!< \brief single-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tvec2<float> float2; //!< \brief single-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec3<float> float3; //!< \brief single-precision floating-point vector with 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec4<float> float4; //!< \brief single-precision floating-point vector with 4 components. (From GLM_GTX_compatibility extension) + + typedef float float1x1; //!< \brief single-precision floating-point matrix with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x2<float> float2x2; //!< \brief single-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x3<float> float2x3; //!< \brief single-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x4<float> float2x4; //!< \brief single-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x2<float> float3x2; //!< \brief single-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x3<float> float3x3; //!< \brief single-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x4<float> float3x4; //!< \brief single-precision floating-point matrix with 3 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x2<float> float4x2; //!< \brief single-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x3<float> float4x3; //!< \brief single-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x4<float> float4x4; //!< \brief single-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) + + typedef double double1; //!< \brief double-precision floating-point vector with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tvec2<double> double2; //!< \brief double-precision floating-point vector with 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec3<double> double3; //!< \brief double-precision floating-point vector with 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tvec4<double> double4; //!< \brief double-precision floating-point vector with 4 components. (From GLM_GTX_compatibility extension) + + typedef double double1x1; //!< \brief double-precision floating-point matrix with 1 component. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x2<double> double2x2; //!< \brief double-precision floating-point matrix with 2 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x3<double> double2x3; //!< \brief double-precision floating-point matrix with 2 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat2x4<double> double2x4; //!< \brief double-precision floating-point matrix with 2 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x2<double> double3x2; //!< \brief double-precision floating-point matrix with 3 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x3<double> double3x3; //!< \brief double-precision floating-point matrix with 3 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat3x4<double> double3x4; //!< \brief double-precision floating-point matrix with 3 x 4 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x2<double> double4x2; //!< \brief double-precision floating-point matrix with 4 x 2 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x3<double> double4x3; //!< \brief double-precision floating-point matrix with 4 x 3 components. (From GLM_GTX_compatibility extension) + typedef detail::tmat4x4<double> double4x4; //!< \brief double-precision floating-point matrix with 4 x 4 components. (From GLM_GTX_compatibility extension) + + /// @} +}//namespace glm + +#include "compatibility.inl" + +#endif//GLM_GTX_compatibility + diff --git a/include/gal/opengl/glm/gtx/compatibility.inl b/include/gal/opengl/glm/gtx/compatibility.inl new file mode 100644 index 0000000..073c694 --- /dev/null +++ b/include/gal/opengl/glm/gtx/compatibility.inl @@ -0,0 +1,60 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-16 +// Updated : 2008-10-24 +// Licence : This source is under MIT License +// File : glm/gtx/compatibility.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // isfinite + template <typename genType> + GLM_FUNC_QUALIFIER bool isfinite( + genType const & x) + { +# if(GLM_COMPILER & GLM_COMPILER_VC) + return _finite(x); +# elif(GLM_COMPILER & GLM_COMPILER_GCC) +# if(GLM_PLATFORM & GLM_PLATFORM_ANDROID) + return _isfinite(x) != 0; +# else + return std::isfinite(x) != 0; +# endif +# else + return std::isfinite(x) != 0; +# endif + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite( + detail::tvec2<valType> const & x) + { + return detail::tvec2<bool>( + isfinite(x.x), + isfinite(x.y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite( + detail::tvec3<valType> const & x) + { + return detail::tvec3<bool>( + isfinite(x.x), + isfinite(x.y), + isfinite(x.z)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite( + detail::tvec4<valType> const & x) + { + return detail::tvec4<bool>( + isfinite(x.x), + isfinite(x.y), + isfinite(x.z), + isfinite(x.w)); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/component_wise.hpp b/include/gal/opengl/glm/gtx/component_wise.hpp new file mode 100644 index 0000000..d3274be --- /dev/null +++ b/include/gal/opengl/glm/gtx/component_wise.hpp @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_component_wise +/// @file glm/gtx/component_wise.hpp +/// @date 2007-05-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_component_wise GLM_GTX_component_wise +/// @ingroup gtx +/// +/// @brief Operations between components of a type +/// +/// <glm/gtx/component_wise.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_component_wise +#define GLM_GTX_component_wise GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_component_wise extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_component_wise + /// @{ + + /// Add all vector components together. + /// @see gtx_component_wise + template <typename genType> + typename genType::value_type compAdd( + genType const & v); + + /// Multiply all vector components together. + /// @see gtx_component_wise + template <typename genType> + typename genType::value_type compMul( + genType const & v); + + /// Find the minimum value between single vector components. + /// @see gtx_component_wise + template <typename genType> + typename genType::value_type compMin( + genType const & v); + + /// Find the maximum value between single vector components. + /// @see gtx_component_wise + template <typename genType> + typename genType::value_type compMax( + genType const & v); + + /// @} +}//namespace glm + +#include "component_wise.inl" + +#endif//GLM_GTX_component_wise diff --git a/include/gal/opengl/glm/gtx/component_wise.inl b/include/gal/opengl/glm/gtx/component_wise.inl new file mode 100644 index 0000000..8baea62 --- /dev/null +++ b/include/gal/opengl/glm/gtx/component_wise.inl @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-21 +// Updated : 2010-02-12 +// Licence : This source is under MIT License +// File : gtx_component_wise.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v) + { + typename genType::value_type result = typename genType::value_type(0); + for(typename genType::size_type i = 0; i < v.length(); ++i) + result += v[i]; + return result; + } + + template <typename genType> + GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v) + { + typename genType::value_type result = typename genType::value_type(1); + for(typename genType::size_type i = 0; i < v.length(); ++i) + result *= v[i]; + return result; + } + + template <typename genType> + GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v) + { + typename genType::value_type result = typename genType::value_type(v[0]); + for(typename genType::size_type i = 1; i < v.length(); ++i) + result = min(result, v[i]); + return result; + } + + template <typename genType> + GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v) + { + typename genType::value_type result = typename genType::value_type(v[0]); + for(typename genType::size_type i = 1; i < v.length(); ++i) + result = max(result, v[i]); + return result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/constants.hpp b/include/gal/opengl/glm/gtx/constants.hpp new file mode 100644 index 0000000..78356ff --- /dev/null +++ b/include/gal/opengl/glm/gtx/constants.hpp @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_constants +#define GLM_GTX_constants GLM_VERSION + +#include "../gtc/constants.hpp" + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_constants extension is deprecated, include GLM_GTC_constants (glm/gtc/constants.hpp) instead") +#endif + +#endif//GLM_GTX_constants diff --git a/include/gal/opengl/glm/gtx/epsilon.hpp b/include/gal/opengl/glm/gtx/epsilon.hpp new file mode 100644 index 0000000..9cb91cb --- /dev/null +++ b/include/gal/opengl/glm/gtx/epsilon.hpp @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_epsilon extension is deprecated, include GLM_GTC_epsilon (glm/gtc/epsilon) instead") +#endif + +// Promoted: +#include "../gtc/epsilon.hpp" diff --git a/include/gal/opengl/glm/gtx/euler_angles.hpp b/include/gal/opengl/glm/gtx/euler_angles.hpp new file mode 100644 index 0000000..ab04042 --- /dev/null +++ b/include/gal/opengl/glm/gtx/euler_angles.hpp @@ -0,0 +1,156 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_euler_angles +/// @file glm/gtx/euler_angles.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// +/// @defgroup gtx_euler_angles GLM_GTX_euler_angles +/// @ingroup gtx +/// +/// @brief Build matrices from Euler angles. +/// +/// <glm/gtx/euler_angles.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_euler_angles +#define GLM_GTX_euler_angles GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_euler_angles extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_euler_angles + /// @{ + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle X. + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleX( + valType const & angleX); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle Y. + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleY( + valType const & angleY); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from an euler angle Z. + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleZ( + valType const & angleZ); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleXY( + valType const & angleX, + valType const & angleY); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleYX( + valType const & angleY, + valType const & angleX); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Z). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleXZ( + valType const & angleX, + valType const & angleZ); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * X). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleZX( + valType const & angleZ, + valType const & angleX); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * Z). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleYZ( + valType const & angleY, + valType const & angleZ); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Z * Y). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleZY( + valType const & angleZ, + valType const & angleY); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> eulerAngleYXZ( + valType const & yaw, + valType const & pitch, + valType const & roll); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z). + /// @see gtx_euler_angles + template <typename valType> + detail::tmat4x4<valType> yawPitchRoll( + valType const & yaw, + valType const & pitch, + valType const & roll); + + /// Creates a 2D 2 * 2 rotation matrix from an euler angle. + /// @see gtx_euler_angles + template <typename T> + detail::tmat2x2<T> orientate2(T const & angle); + + /// Creates a 2D 4 * 4 homogeneous rotation matrix from an euler angle. + /// @see gtx_euler_angles + template <typename T> + detail::tmat3x3<T> orientate3(T const & angle); + + /// Creates a 3D 3 * 3 rotation matrix from euler angles (Y * X * Z). + /// @see gtx_euler_angles + template <typename T> + detail::tmat3x3<T> orientate3(detail::tvec3<T> const & angles); + + /// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (Y * X * Z). + /// @see gtx_euler_angles + template <typename T> + detail::tmat4x4<T> orientate4(detail::tvec3<T> const & angles); + + /// @} +}//namespace glm + +#include "euler_angles.inl" + +#endif//GLM_GTX_euler_angles diff --git a/include/gal/opengl/glm/gtx/euler_angles.inl b/include/gal/opengl/glm/gtx/euler_angles.inl new file mode 100644 index 0000000..a6ca0ab --- /dev/null +++ b/include/gal/opengl/glm/gtx/euler_angles.inl @@ -0,0 +1,244 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2007-08-14 +// Licence : This source is under MIT License +// File : glm/gtx/euler_angles.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX + ( + valType const & angleX + ) + { + valType cosX = glm::cos(angleX); + valType sinX = glm::sin(angleX); + + return detail::tmat4x4<valType>( + valType(1), valType(0), valType(0), valType(0), + valType(0), cosX, sinX, valType(0), + valType(0),-sinX, cosX, valType(0), + valType(0), valType(0), valType(0), valType(1)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY + ( + valType const & angleY + ) + { + valType cosY = glm::cos(angleY); + valType sinY = glm::sin(angleY); + + return detail::tmat4x4<valType>( + cosY, valType(0),-sinY, valType(0), + valType(0), valType(1), valType(0), valType(0), + sinY, valType(0), cosY, valType(0), + valType(0), valType(0), valType(0), valType(1)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ + ( + valType const & angleZ + ) + { + valType cosZ = glm::cos(angleZ); + valType sinZ = glm::sin(angleZ); + + return detail::tmat4x4<valType>( + cosZ, sinZ, valType(0), valType(0), + -sinZ, cosZ, valType(0), valType(0), + valType(0), valType(0), valType(1), valType(0), + valType(0), valType(0), valType(0), valType(1)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY + ( + valType const & angleX, + valType const & angleY + ) + { + valType cosX = glm::cos(angleX); + valType sinX = glm::sin(angleX); + valType cosY = glm::cos(angleY); + valType sinY = glm::sin(angleY); + + return detail::tmat4x4<valType>( + cosY, -sinX * sinY, cosX * sinY, valType(0), + valType(0), cosX, sinX, valType(0), + -sinY , -sinX * cosY, cosX * cosY, valType(0), + valType(0), valType(0), valType(0), valType(1)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX + ( + valType const & angleY, + valType const & angleX + ) + { + valType cosX = glm::cos(angleX); + valType sinX = glm::sin(angleX); + valType cosY = glm::cos(angleY); + valType sinY = glm::sin(angleY); + + return detail::tmat4x4<valType>( + cosY, valType(0), sinY, valType(0), + -sinX * sinY, cosX, sinX * cosY, valType(0), + -cosX * sinY, -sinX, cosX * cosY, valType(0), + valType(0), valType(0), valType(0), valType(1)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ + ( + valType const & angleX, + valType const & angleZ + ) + { + return eulerAngleX(angleX) * eulerAngleZ(angleZ); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX + ( + valType const & angleZ, + valType const & angleX + ) + { + return eulerAngleZ(angleZ) * eulerAngleX(angleX); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ + ( + valType const & yaw, + valType const & pitch, + valType const & roll + ) + { + valType tmp_ch = glm::cos(yaw); + valType tmp_sh = glm::sin(yaw); + valType tmp_cp = glm::cos(pitch); + valType tmp_sp = glm::sin(pitch); + valType tmp_cb = glm::cos(roll); + valType tmp_sb = glm::sin(roll); + + detail::tmat4x4<valType> Result; + Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb; + Result[0][1] = tmp_sb * tmp_cp; + Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb; + Result[0][3] = valType(0); + Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb; + Result[1][1] = tmp_cb * tmp_cp; + Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb; + Result[1][3] = valType(0); + Result[2][0] = tmp_sh * tmp_cp; + Result[2][1] = -tmp_sp; + Result[2][2] = tmp_ch * tmp_cp; + Result[2][3] = valType(0); + Result[3][0] = valType(0); + Result[3][1] = valType(0); + Result[3][2] = valType(0); + Result[3][3] = valType(1); + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll + ( + valType const & yaw, + valType const & pitch, + valType const & roll + ) + { + valType tmp_ch = glm::cos(yaw); + valType tmp_sh = glm::sin(yaw); + valType tmp_cp = glm::cos(pitch); + valType tmp_sp = glm::sin(pitch); + valType tmp_cb = glm::cos(roll); + valType tmp_sb = glm::sin(roll); + + detail::tmat4x4<valType> Result; + Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb; + Result[0][1] = tmp_sb * tmp_cp; + Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb; + Result[0][3] = valType(0); + Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb; + Result[1][1] = tmp_cb * tmp_cp; + Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb; + Result[1][3] = valType(0); + Result[2][0] = tmp_sh * tmp_cp; + Result[2][1] = -tmp_sp; + Result[2][2] = tmp_ch * tmp_cp; + Result[2][3] = valType(0); + Result[3][0] = valType(0); + Result[3][1] = valType(0); + Result[3][2] = valType(0); + Result[3][3] = valType(1); + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2 + ( + valType const & angle + ) + { + valType c = glm::cos(angle); + valType s = glm::sin(angle); + + detail::tmat2x2<valType> Result; + Result[0][0] = c; + Result[0][1] = s; + Result[1][0] = -s; + Result[1][1] = c; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3 + ( + valType const & angle + ) + { + valType c = glm::cos(angle); + valType s = glm::sin(angle); + + detail::tmat3x3<valType> Result; + Result[0][0] = c; + Result[0][1] = s; + Result[0][2] = 0.0f; + Result[1][0] = -s; + Result[1][1] = c; + Result[1][2] = 0.0f; + Result[2][0] = 0.0f; + Result[2][1] = 0.0f; + Result[2][2] = 1.0f; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3 + ( + detail::tvec3<valType> const & angles + ) + { + return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4 + ( + detail::tvec3<valType> const & angles + ) + { + return yawPitchRoll(angles.z, angles.x, angles.y); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/extend.hpp b/include/gal/opengl/glm/gtx/extend.hpp new file mode 100644 index 0000000..d23beba --- /dev/null +++ b/include/gal/opengl/glm/gtx/extend.hpp @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_extend +/// @file glm/gtx/extend.hpp +/// @date 2006-01-07 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_extend GLM_GTX_extend +/// @ingroup gtx +/// +/// @brief Extend a position from a source to a position at a defined length. +/// +/// <glm/gtx/extend.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_extend +#define GLM_GTX_extend GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_extend extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_extend + /// @{ + + /// Extends of Length the Origin position using the (Source - Origin) direction. + /// @see gtx_extend + template <typename genType> + genType extend( + genType const & Origin, + genType const & Source, + typename genType::value_type const Length); + + /// @} +}//namespace glm + +#include "extend.inl" + +#endif//GLM_GTX_extend diff --git a/include/gal/opengl/glm/gtx/extend.inl b/include/gal/opengl/glm/gtx/extend.inl new file mode 100644 index 0000000..9827401 --- /dev/null +++ b/include/gal/opengl/glm/gtx/extend.inl @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-07 +// Updated : 2008-10-05 +// Licence : This source is under MIT License +// File : glm/gtx/extend.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + genType extend + ( + genType const & Origin, + genType const & Source, + genType const & Distance + ) + { + return Origin + (Source - Origin) * Distance; + } + + template <typename valType> + detail::tvec2<valType> extend + ( + detail::tvec2<valType> const & Origin, + detail::tvec2<valType> const & Source, + valType const & Distance + ) + { + return Origin + (Source - Origin) * Distance; + } + + template <typename valType> + detail::tvec3<valType> extend + ( + detail::tvec3<valType> const & Origin, + detail::tvec3<valType> const & Source, + valType const & Distance + ) + { + return Origin + (Source - Origin) * Distance; + } + + template <typename valType> + detail::tvec4<valType> extend + ( + detail::tvec4<valType> const & Origin, + detail::tvec4<valType> const & Source, + valType const & Distance + ) + { + return Origin + (Source - Origin) * Distance; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/extented_min_max.hpp b/include/gal/opengl/glm/gtx/extented_min_max.hpp new file mode 100644 index 0000000..c623409 --- /dev/null +++ b/include/gal/opengl/glm/gtx/extented_min_max.hpp @@ -0,0 +1,194 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_extented_min_max +/// @file glm/gtx/extented_min_max.hpp +/// @date 2007-03-14 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_half_float (dependence) +/// +/// @defgroup gtx_extented_min_max GLM_GTX_extented_min_max +/// @ingroup gtx +/// +/// Min and max functions for 3 to 4 parameters. +/// +/// <glm/gtx/extented_min_max.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_extented_min_max +#define GLM_GTX_extented_min_max GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_extented_min_max extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_extented_min_max + /// @{ + + /// Return the minimum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template <typename T> + T min( + T const & x, + T const & y, + T const & z); + + /// Return the minimum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> min( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z); + + /// Return the minimum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> min( + C<T> const & x, + C<T> const & y, + C<T> const & z); + + /// Return the minimum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template <typename T> + T min( + T const & x, + T const & y, + T const & z, + T const & w); + + /// Return the minimum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> min( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z, + typename C<T>::value_type const & w); + + /// Return the minimum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> min( + C<T> const & x, + C<T> const & y, + C<T> const & z, + C<T> const & w); + + /// Return the maximum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template <typename T> + T max( + T const & x, + T const & y, + T const & z); + + /// Return the maximum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> max( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z); + + /// Return the maximum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> max( + C<T> const & x, + C<T> const & y, + C<T> const & z); + + /// Return the maximum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template <typename T> + T max( + T const & x, + T const & y, + T const & z, + T const & w); + + /// Return the maximum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> max( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z, + typename C<T>::value_type const & w); + + /// Return the maximum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template + < + typename T, + template <typename> class C + > + C<T> max( + C<T> const & x, + C<T> const & y, + C<T> const & z, + C<T> const & w); + + /// @} +}//namespace glm + +#include "extented_min_max.inl" + +#endif//GLM_GTX_extented_min_max diff --git a/include/gal/opengl/glm/gtx/extented_min_max.inl b/include/gal/opengl/glm/gtx/extented_min_max.inl new file mode 100644 index 0000000..d0a74ef --- /dev/null +++ b/include/gal/opengl/glm/gtx/extented_min_max.inl @@ -0,0 +1,178 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-14 +// Updated : 2010-02-19 +// Licence : This source is under MIT License +// File : gtx_extented_min_max.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER T min( + T const & x, + T const & y, + T const & z) + { + return glm::min(glm::min(x, y), z); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> min + ( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z + ) + { + return glm::min(glm::min(x, y), z); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> min + ( + C<T> const & x, + C<T> const & y, + C<T> const & z + ) + { + return glm::min(glm::min(x, y), z); + } + + template <typename T> + GLM_FUNC_QUALIFIER T min + ( + T const & x, + T const & y, + T const & z, + T const & w + ) + { + return glm::min(glm::min(x, y), glm::min(z, w)); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> min + ( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z, + typename C<T>::value_type const & w + ) + { + return glm::min(glm::min(x, y), glm::min(z, w)); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> min + ( + C<T> const & x, + C<T> const & y, + C<T> const & z, + C<T> const & w + ) + { + return glm::min(glm::min(x, y), glm::min(z, w)); + } + + template <typename T> + GLM_FUNC_QUALIFIER T max( + T const & x, + T const & y, + T const & z) + { + return glm::max(glm::max(x, y), z); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> max + ( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z + ) + { + return glm::max(glm::max(x, y), z); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> max + ( + C<T> const & x, + C<T> const & y, + C<T> const & z + ) + { + return glm::max(glm::max(x, y), z); + } + + template <typename T> + GLM_FUNC_QUALIFIER T max + ( + T const & x, + T const & y, + T const & z, + T const & w + ) + { + return glm::max(glm::max(x, y), glm::max(z, w)); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> max + ( + C<T> const & x, + typename C<T>::value_type const & y, + typename C<T>::value_type const & z, + typename C<T>::value_type const & w + ) + { + return glm::max(glm::max(x, y), glm::max(z, w)); + } + + template + < + typename T, + template <typename> class C + > + GLM_FUNC_QUALIFIER C<T> max + ( + C<T> const & x, + C<T> const & y, + C<T> const & z, + C<T> const & w + ) + { + return glm::max(glm::max(x, y), glm::max(z, w)); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/fast_exponential.hpp b/include/gal/opengl/glm/gtx/fast_exponential.hpp new file mode 100644 index 0000000..ff50eec --- /dev/null +++ b/include/gal/opengl/glm/gtx/fast_exponential.hpp @@ -0,0 +1,99 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_fast_exponential +/// @file glm/gtx/fast_exponential.hpp +/// @date 2006-01-09 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_half_float (dependence) +/// +/// @defgroup gtx_fast_exponential GLM_GTX_fast_exponential +/// @ingroup gtx +/// +/// @brief Fast but less accurate implementations of exponential based functions. +/// +/// <glm/gtx/fast_exponential.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_fast_exponential +#define GLM_GTX_fast_exponential GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_fast_exponential extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_fast_exponential + /// @{ + + /// Faster than the common pow function but less accurate. + /// @see gtx_fast_exponential + template <typename genType> + genType fastPow( + genType const & x, + genType const & y); + + /// Faster than the common pow function but less accurate. + /// @see gtx_fast_exponential + template <typename genTypeT, typename genTypeU> + genTypeT fastPow( + genTypeT const & x, + genTypeU const & y); + + /// Faster than the common exp function but less accurate. + /// @see gtx_fast_exponential + template <typename T> + T fastExp(const T& x); + + /// Faster than the common log function but less accurate. + /// @see gtx_fast_exponential + template <typename T> + T fastLog(const T& x); + + /// Faster than the common exp2 function but less accurate. + /// @see gtx_fast_exponential + template <typename T> + T fastExp2(const T& x); + + /// Faster than the common log2 function but less accurate. + /// @see gtx_fast_exponential + template <typename T> + T fastLog2(const T& x); + + /// Faster than the common ln function but less accurate. + /// @see gtx_fast_exponential + template <typename T> + T fastLn(const T& x); + + /// @} +}//namespace glm + +#include "fast_exponential.inl" + +#endif//GLM_GTX_fast_exponential diff --git a/include/gal/opengl/glm/gtx/fast_exponential.inl b/include/gal/opengl/glm/gtx/fast_exponential.inl new file mode 100644 index 0000000..80837ff --- /dev/null +++ b/include/gal/opengl/glm/gtx/fast_exponential.inl @@ -0,0 +1,148 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-09 +// Updated : 2006-01-09 +// Licence : This source is under MIT License +// File : glm/gtx/fast_exponential.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // fastPow: + template <typename genType> + GLM_FUNC_QUALIFIER genType fastPow(genType const & x, genType const & y) + { + return exp(y * log(x)); + } + + VECTORIZE_VEC_VEC(fastPow) + + template <typename T> + GLM_FUNC_QUALIFIER T fastPow(const T x, int y) + { + T f = T(1); + for(int i = 0; i < y; ++i) + f *= x; + return f; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow( + const detail::tvec2<T>& x, + const detail::tvec2<int>& y) + { + return detail::tvec2<T>( + fastPow(x.x, y.x), + fastPow(x.y, y.y)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow( + const detail::tvec3<T>& x, + const detail::tvec3<int>& y) + { + return detail::tvec3<T>( + fastPow(x.x, y.x), + fastPow(x.y, y.y), + fastPow(x.z, y.z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow( + const detail::tvec4<T>& x, + const detail::tvec4<int>& y) + { + return detail::tvec4<T>( + fastPow(x.x, y.x), + fastPow(x.y, y.y), + fastPow(x.z, y.z), + fastPow(x.w, y.w)); + } + + // fastExp + // Note: This function provides accurate results only for value between -1 and 1, else avoid it. + template <typename T> + GLM_FUNC_QUALIFIER T fastExp(const T x) + { + // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. + // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); + T x2 = x * x; + T x3 = x2 * x; + T x4 = x3 * x; + T x5 = x4 * x; + return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333)); + } + /* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance + GLM_FUNC_QUALIFIER float fastExp(float x) + { + const float e = 2.718281828f; + const float IntegerPart = 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)); + } + + // Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers + GLM_FUNC_QUALIFIER float fastExp(float x) + { + // This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower. + // return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f)))); + 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);; + } + */ + + VECTORIZE_VEC(fastExp) + + // fastLog + template <typename genType> + GLM_FUNC_QUALIFIER genType fastLog(genType const & x) + { + return std::log(x); + } + + /* Slower than the VC7.1 function... + GLM_FUNC_QUALIFIER float fastLog(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))); + } + */ + + VECTORIZE_VEC(fastLog) + + //fastExp2, ln2 = 0.69314718055994530941723212145818f + template <typename genType> + GLM_FUNC_QUALIFIER genType fastExp2(genType const & x) + { + return fastExp(0.69314718055994530941723212145818f * x); + } + + VECTORIZE_VEC(fastExp2) + + // fastLog2, ln2 = 0.69314718055994530941723212145818f + template <typename genType> + GLM_FUNC_QUALIFIER genType fastLog2(genType const & x) + { + return fastLog(x) / 0.69314718055994530941723212145818f; + } + + VECTORIZE_VEC(fastLog2) + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/fast_square_root.hpp b/include/gal/opengl/glm/gtx/fast_square_root.hpp new file mode 100644 index 0000000..a49ae94 --- /dev/null +++ b/include/gal/opengl/glm/gtx/fast_square_root.hpp @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_fast_square_root +/// @file glm/gtx/fast_square_root.hpp +/// @date 2006-01-04 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_fast_square_root GLM_GTX_fast_square_root +/// @ingroup gtx +/// +/// @brief Fast but less accurate implementations of square root based functions. +/// - Sqrt optimisation based on Newton's method, +/// www.gamedev.net/community/forums/topic.asp?topic id=139956 +/// +/// <glm/gtx/fast_square_root.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_fast_square_root +#define GLM_GTX_fast_square_root GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_fast_square_root extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_fast_square_root + /// @{ + + //! Faster than the common sqrt function but less accurate. + //! From GLM_GTX_fast_square_root extension. + template <typename genType> + genType fastSqrt(genType const & x); + + //! Faster than the common inversesqrt function but less accurate. + //! From GLM_GTX_fast_square_root extension. + template <typename genType> + genType fastInverseSqrt(genType const & x); + + //! Faster than the common length function but less accurate. + //! From GLM_GTX_fast_square_root extension. + template <typename genType> + typename genType::value_type fastLength(genType const & x); + + //! Faster than the common distance function but less accurate. + //! From GLM_GTX_fast_square_root extension. + template <typename genType> + typename genType::value_type fastDistance(genType const & x, genType const & y); + + //! Faster than the common normalize function but less accurate. + //! From GLM_GTX_fast_square_root extension. + template <typename genType> + genType fastNormalize(genType const & x); + + /// @} +}// namespace glm + +#include "fast_square_root.inl" + +#endif//GLM_GTX_fast_square_root diff --git a/include/gal/opengl/glm/gtx/fast_square_root.inl b/include/gal/opengl/glm/gtx/fast_square_root.inl new file mode 100644 index 0000000..0f51fbb --- /dev/null +++ b/include/gal/opengl/glm/gtx/fast_square_root.inl @@ -0,0 +1,136 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-04 +// Updated : 2011-10-14 +// Licence : This source is under MIT License +// File : glm/gtx/fast_square_root.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // fastSqrt + template <typename genType> + GLM_FUNC_QUALIFIER genType fastSqrt + ( + genType const & x + ) + { + GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'fastSqrt' only accept floating-point input"); + + return genType(1) / fastInverseSqrt(x); + } + + VECTORIZE_VEC(fastSqrt) + + // fastInversesqrt + template <typename genType> + GLM_FUNC_QUALIFIER genType fastInverseSqrt + ( + genType const & x + ) + { + genType tmp = x; + float xhalf = 0.5f * float(tmp); + uint i = *(uint*)&x; + i = 0x5f375a86 - (i >> 1); + //x = *(float*)&i; + //x = *((float*)(char*)&i); + tmp = detail::uif(i).f; + tmp = tmp * (1.5f - xhalf * tmp * tmp); + return genType(tmp); + } + + VECTORIZE_VEC(fastInverseSqrt) + + // fastLength + template <typename genType> + GLM_FUNC_QUALIFIER genType fastLength + ( + genType const & x + ) + { + return abs(x); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType fastLength + ( + detail::tvec2<valType> const & x + ) + { + valType sqr = x.x * x.x + x.y * x.y; + return fastSqrt(sqr); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType fastLength + ( + detail::tvec3<valType> const & x + ) + { + valType sqr = x.x * x.x + x.y * x.y + x.z * x.z; + return fastSqrt(sqr); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType fastLength + ( + detail::tvec4<valType> const & x + ) + { + valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; + return fastSqrt(sqr); + } + + // fastDistance + template <typename genType> + GLM_FUNC_QUALIFIER genType fastDistance + ( + genType const & x, + genType const & y + ) + { + return fastLength(y - x); + } + + // fastNormalize + template <typename genType> + GLM_FUNC_QUALIFIER genType fastNormalize + ( + genType const & x + ) + { + return x > genType(0) ? genType(1) : -genType(1); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<valType> fastNormalize + ( + detail::tvec2<valType> const & x + ) + { + valType sqr = x.x * x.x + x.y * x.y; + return x * fastInverseSqrt(sqr); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> fastNormalize + ( + detail::tvec3<valType> const & x + ) + { + valType sqr = x.x * x.x + x.y * x.y + x.z * x.z; + return x * fastInverseSqrt(sqr); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<valType> fastNormalize + ( + detail::tvec4<valType> const & x + ) + { + valType sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; + return x * fastInverseSqrt(sqr); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/fast_trigonometry.hpp b/include/gal/opengl/glm/gtx/fast_trigonometry.hpp new file mode 100644 index 0000000..16f326d --- /dev/null +++ b/include/gal/opengl/glm/gtx/fast_trigonometry.hpp @@ -0,0 +1,100 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_fast_trigonometry +/// @file glm/gtx/fast_trigonometry.hpp +/// @date 2006-01-08 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_fast_trigonometry GLM_GTX_fast_trigonometry +/// @ingroup gtx +/// +/// @brief Fast but less accurate implementations of trigonometric functions. +/// +/// <glm/gtx/fast_trigonometry.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_fast_trigonometry +#define GLM_GTX_fast_trigonometry GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_fast_trigonometry extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_fast_trigonometry + /// @{ + + //! Faster than the common sin function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastSin(const T& angle); + + //! Faster than the common cos function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastCos(const T& angle); + + //! Faster than the common tan function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastTan(const T& angle); + + //! Faster than the common asin function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastAsin(const T& angle); + + //! Faster than the common acos function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastAcos(const T& angle); + + //! Faster than the common atan function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastAtan(const T& y, const T& x); + + //! Faster than the common atan function but less accurate. + //! Defined between -2pi and 2pi. + //! From GLM_GTX_fast_trigonometry extension. + template <typename T> + T fastAtan(const T& angle); + + /// @} +}//namespace glm + +#include "fast_trigonometry.inl" + +#endif//GLM_GTX_fast_trigonometry diff --git a/include/gal/opengl/glm/gtx/fast_trigonometry.inl b/include/gal/opengl/glm/gtx/fast_trigonometry.inl new file mode 100644 index 0000000..b2179a6 --- /dev/null +++ b/include/gal/opengl/glm/gtx/fast_trigonometry.inl @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-08 +// Updated : 2011-10-14 +// Licence : This source is under MIT License +// File : glm/gtx/fast_trigonometry.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // sin + template <typename T> + GLM_FUNC_QUALIFIER T fastSin(T const & x) + { + return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040)); + } + + VECTORIZE_VEC(fastSin) + + // cos + template <typename T> + GLM_FUNC_QUALIFIER T fastCos(T const & x) + { + return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888)); + } + + VECTORIZE_VEC(fastCos) + + // tan + template <typename T> + GLM_FUNC_QUALIFIER T fastTan(T const & x) + { + return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539)); + } + + VECTORIZE_VEC(fastTan) + + // asin + template <typename T> + GLM_FUNC_QUALIFIER T fastAsin(T const & x) + { + return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159)); + } + + VECTORIZE_VEC(fastAsin) + + // acos + template <typename T> + GLM_FUNC_QUALIFIER T fastAcos(T const & x) + { + return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) + } + + VECTORIZE_VEC(fastAcos) + + // atan + template <typename T> + GLM_FUNC_QUALIFIER T fastAtan(T const & y, T const & x) + { + T sgn = sign(y) * sign(x); + return abs(fastAtan(y / x)) * sgn; + } + + VECTORIZE_VEC_VEC(fastAtan) + + template <typename T> + GLM_FUNC_QUALIFIER T fastAtan(T const & x) + { + return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909)); + } + + VECTORIZE_VEC(fastAtan) + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/gradient_paint.hpp b/include/gal/opengl/glm/gtx/gradient_paint.hpp new file mode 100644 index 0000000..f3bfde7 --- /dev/null +++ b/include/gal/opengl/glm/gtx/gradient_paint.hpp @@ -0,0 +1,76 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_gradient_paint +/// @file glm/gtx/gradient_paint.hpp +/// @date 2009-03-06 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_optimum_pow (dependence) +/// +/// @defgroup gtx_gradient_paint GLM_GTX_gradient_paint +/// @ingroup gtx +/// +/// @brief Functions that return the color of procedural gradient for specific coordinates. +/// <glm/gtx/gradient_paint.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_gradient_paint +#define GLM_GTX_gradient_paint GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/optimum_pow.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_gradient_paint extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_gradient_paint + /// @{ + + /// Return a color from a radial gradient. + /// @see - gtx_gradient_paint + template <typename valType> + valType radialGradient( + detail::tvec2<valType> const & Center, + valType const & Radius, + detail::tvec2<valType> const & Focal, + detail::tvec2<valType> const & Position); + + /// Return a color from a linear gradient. + /// @see - gtx_gradient_paint + template <typename valType> + valType linearGradient( + detail::tvec2<valType> const & Point0, + detail::tvec2<valType> const & Point1, + detail::tvec2<valType> const & Position); + + /// @} +}// namespace glm + +#include "gradient_paint.inl" + +#endif//GLM_GTX_gradient_paint diff --git a/include/gal/opengl/glm/gtx/gradient_paint.inl b/include/gal/opengl/glm/gtx/gradient_paint.inl new file mode 100644 index 0000000..bdf5a65 --- /dev/null +++ b/include/gal/opengl/glm/gtx/gradient_paint.inl @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-03-06 +// Updated : 2009-03-09 +// Licence : This source is under MIT License +// File : glm/gtx/gradient_paint.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename valType> + valType radialGradient + ( + detail::tvec2<valType> const & Center, + valType const & Radius, + detail::tvec2<valType> const & Focal, + detail::tvec2<valType> const & Position + ) + { + detail::tvec2<valType> F = Focal - Center; + detail::tvec2<valType> D = Position - Focal; + valType Radius2 = pow2(Radius); + valType Fx2 = pow2(F.x); + valType Fy2 = pow2(F.y); + + valType Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x)); + valType Denominator = Radius2 - (Fx2 + Fy2); + return Numerator / Denominator; + } + + template <typename valType> + valType linearGradient + ( + detail::tvec2<valType> const & Point0, + detail::tvec2<valType> const & Point1, + detail::tvec2<valType> const & Position + ) + { + detail::tvec2<valType> Dist = Point1 - Point0; + return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/handed_coordinate_space.hpp b/include/gal/opengl/glm/gtx/handed_coordinate_space.hpp new file mode 100644 index 0000000..5ed0b0b --- /dev/null +++ b/include/gal/opengl/glm/gtx/handed_coordinate_space.hpp @@ -0,0 +1,74 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_handed_coordinate_space +/// @file glm/gtx/handed_coordinate_space.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_handed_coordinate_space GLM_GTX_handed_coordinate_space +/// @ingroup gtx +/// +/// @brief To know if a set of three basis vectors defines a right or left-handed coordinate system. +/// +/// <glm/gtx/handed_coordinate_system.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_handed_coordinate_space +#define GLM_GTX_handed_coordinate_space GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_handed_coordinate_space extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_handed_coordinate_space + /// @{ + + //! Return if a trihedron right handed or not. + //! From GLM_GTX_handed_coordinate_space extension. + template <typename T> + bool rightHanded( + detail::tvec3<T> const & tangent, + detail::tvec3<T> const & binormal, + detail::tvec3<T> const & normal); + + //! Return if a trihedron left handed or not. + //! From GLM_GTX_handed_coordinate_space extension. + template <typename T> + bool leftHanded( + detail::tvec3<T> const & tangent, + detail::tvec3<T> const & binormal, + detail::tvec3<T> const & normal); + + /// @} +}// namespace glm + +#include "handed_coordinate_space.inl" + +#endif//GLM_GTX_handed_coordinate_space diff --git a/include/gal/opengl/glm/gtx/handed_coordinate_space.inl b/include/gal/opengl/glm/gtx/handed_coordinate_space.inl new file mode 100644 index 0000000..51a0553 --- /dev/null +++ b/include/gal/opengl/glm/gtx/handed_coordinate_space.inl @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2009-02-19 +// Licence : This source is under MIT License +// File : glm/gtx/handed_coordinate_space.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER bool rightHanded + ( + detail::tvec3<T> const & tangent, + detail::tvec3<T> const & binormal, + detail::tvec3<T> const & normal + ) + { + return dot(cross(normal, tangent), binormal) > T(0); + } + + template <typename T> + GLM_FUNC_QUALIFIER bool leftHanded + ( + detail::tvec3<T> const & tangent, + detail::tvec3<T> const & binormal, + detail::tvec3<T> const & normal + ) + { + return dot(cross(normal, tangent), binormal) < T(0); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/inertia.hpp b/include/gal/opengl/glm/gtx/inertia.hpp new file mode 100644 index 0000000..9133299 --- /dev/null +++ b/include/gal/opengl/glm/gtx/inertia.hpp @@ -0,0 +1,115 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_inertia +/// @file glm/gtx/inertia.hpp +/// @date 2006-04-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_inertia GLM_GTX_inertia +/// @ingroup gtx +/// +/// @brief Create inertia matrices +/// +/// <glm/gtx/inertia.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_inertia +#define GLM_GTX_inertia GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_inertia extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_inertia + /// @{ + + //! Build an inertia matrix for a box. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat3x3<T> boxInertia3( + T const & Mass, + detail::tvec3<T> const & Scale); + + //! Build an inertia matrix for a box. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat4x4<T> boxInertia4( + T const & Mass, + detail::tvec3<T> const & Scale); + + //! Build an inertia matrix for a disk. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat3x3<T> diskInertia3( + T const & Mass, + T const & Radius); + + //! Build an inertia matrix for a disk. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat4x4<T> diskInertia4( + T const & Mass, + T const & Radius); + + //! Build an inertia matrix for a ball. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat3x3<T> ballInertia3( + T const & Mass, + T const & Radius); + + //! Build an inertia matrix for a ball. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat4x4<T> ballInertia4( + T const & Mass, + T const & Radius); + + //! Build an inertia matrix for a sphere. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat3x3<T> sphereInertia3( + T const & Mass, + T const & Radius); + + //! Build an inertia matrix for a sphere. + //! From GLM_GTX_inertia extension. + template <typename T> + detail::tmat4x4<T> sphereInertia4( + T const & Mass, + T const & Radius); + + /// @} +}// namespace glm + +#include "inertia.inl" + +#endif//GLM_GTX_inertia diff --git a/include/gal/opengl/glm/gtx/inertia.inl b/include/gal/opengl/glm/gtx/inertia.inl new file mode 100644 index 0000000..a8f2ad7 --- /dev/null +++ b/include/gal/opengl/glm/gtx/inertia.inl @@ -0,0 +1,114 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-21 +// Updated : 2006-12-06 +// Licence : This source is under MIT License +// File : glm/gtx/inertia.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> boxInertia3 + ( + T const & Mass, + detail::tvec3<T> const & Scale + ) + { + detail::tmat3x3<T> Result(T(1)); + Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); + Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); + Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> boxInertia4 + ( + T const & Mass, + detail::tvec3<T> const & Scale + ) + { + detail::tmat4x4<T> Result(T(1)); + Result[0][0] = (Scale.y * Scale.y + Scale.z * Scale.z) * Mass / T(12); + Result[1][1] = (Scale.x * Scale.x + Scale.z * Scale.z) * Mass / T(12); + Result[2][2] = (Scale.x * Scale.x + Scale.y * Scale.y) * Mass / T(12); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> diskInertia3 + ( + T const & Mass, + T const & Radius + ) + { + T a = Mass * Radius * Radius / T(2); + detail::tmat3x3<T> Result(a); + Result[2][2] *= T(2); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> diskInertia4 + ( + T const & Mass, + T const & Radius + ) + { + T a = Mass * Radius * Radius / T(2); + detail::tmat4x4<T> Result(a); + Result[2][2] *= T(2); + Result[3][3] = T(1); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> ballInertia3 + ( + T const & Mass, + T const & Radius + ) + { + T a = T(2) * Mass * Radius * Radius / T(5); + return detail::tmat3x3<T>(a); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> ballInertia4 + ( + T const & Mass, + T const & Radius + ) + { + T a = T(2) * Mass * Radius * Radius / T(5); + detail::tmat4x4<T> Result(a); + Result[3][3] = T(1); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> sphereInertia3 + ( + T const & Mass, + T const & Radius + ) + { + T a = T(2) * Mass * Radius * Radius / T(3); + return detail::tmat3x3<T>(a); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> sphereInertia4 + ( + T const & Mass, + T const & Radius + ) + { + T a = T(2) * Mass * Radius * Radius / T(3); + detail::tmat4x4<T> Result(a); + Result[3][3] = T(1); + return Result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/int_10_10_10_2.hpp b/include/gal/opengl/glm/gtx/int_10_10_10_2.hpp new file mode 100644 index 0000000..1270481 --- /dev/null +++ b/include/gal/opengl/glm/gtx/int_10_10_10_2.hpp @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_int_10_10_10_2 +/// @file glm/gtx/int_10_10_10_2.hpp +/// @date 2010-07-07 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_raw_data (dependence) +/// +/// @defgroup gtx_int_10_10_10_2 GLM_GTX_int_10_10_10_2 +/// @ingroup gtx +/// +/// @brief Pack vector to 1010102 integers. Storage only. +/// +/// <glm/gtx/int_10_10_10_2.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_int_10_10_10_2 +#define GLM_GTX_int_10_10_10_2 GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/raw_data.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_int_10_10_10_2 extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_int_10_10_10_2 + /// @{ + + //! From GLM_GTX_int_10_10_10_2 extension. + //! Cast a vec4 to an u_10_10_10_2. + dword uint10_10_10_2_cast(glm::vec4 const & v); + + /// @} +}//namespace glm + +#include "int_10_10_10_2.inl" + +#endif//GLM_GTX_int_10_10_10_2 diff --git a/include/gal/opengl/glm/gtx/int_10_10_10_2.inl b/include/gal/opengl/glm/gtx/int_10_10_10_2.inl new file mode 100644 index 0000000..c1ec201 --- /dev/null +++ b/include/gal/opengl/glm/gtx/int_10_10_10_2.inl @@ -0,0 +1,19 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-07-07 +// Updated : 2010-07-07 +// Licence : This source is under MIT License +// File : glm/gtx/int_10_10_10_2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast + ( + glm::vec4 const & v + ) + { + return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/integer.hpp b/include/gal/opengl/glm/gtx/integer.hpp new file mode 100644 index 0000000..b3e21fd --- /dev/null +++ b/include/gal/opengl/glm/gtx/integer.hpp @@ -0,0 +1,104 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_integer +/// @file glm/gtx/integer.hpp +/// @date 2005-12-24 / 2011-10-13 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_integer GLM_GTX_integer +/// @ingroup gtx +/// +/// @brief Add support for integer for core functions +/// +/// <glm/gtx/integer.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_integer +#define GLM_GTX_integer GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_integer extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_integer + /// @{ + + //! Returns x raised to the y power. + //! From GLM_GTX_integer extension. + int pow(int x, int y); + + //! Returns the positive square root of x. + //! From GLM_GTX_integer extension. + int sqrt(int x); + + //! Returns the log2 of x. Can be reliably using to compute mipmap count from the texture size. + //! From GLM_GTX_integer extension. + template <typename genIUType> + genIUType log2(genIUType const & x); + + //! Returns the floor log2 of x. + //! From GLM_GTX_integer extension. + unsigned int floor_log2(unsigned int x); + + //! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. + //! From GLM_GTX_integer extension. + int mod(int x, int y); + + //! Return the factorial value of a number (!12 max, integer only) + //! From GLM_GTX_integer extension. + template <typename genType> + genType factorial(genType const & x); + + //! 32bit signed integer. + //! From GLM_GTX_integer extension. + typedef signed int sint; + + //! Returns x raised to the y power. + //! From GLM_GTX_integer extension. + uint pow(uint x, uint y); + + //! Returns the positive square root of x. + //! From GLM_GTX_integer extension. + uint sqrt(uint x); + + //! Modulus. Returns x - y * floor(x / y) for each component in x using the floating point value y. + //! From GLM_GTX_integer extension. + uint mod(uint x, uint y); + + //! Returns the number of leading zeros. + //! From GLM_GTX_integer extension. + uint nlz(uint x); + + /// @} +}//namespace glm + +#include "integer.inl" + +#endif//GLM_GTX_integer diff --git a/include/gal/opengl/glm/gtx/integer.inl b/include/gal/opengl/glm/gtx/integer.inl new file mode 100644 index 0000000..2478616 --- /dev/null +++ b/include/gal/opengl/glm/gtx/integer.inl @@ -0,0 +1,203 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-24 +// Updated : 2011-10-13 +// Licence : This source is under MIT License +// File : glm/gtx/integer.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + // pow + GLM_FUNC_QUALIFIER int pow(int x, int y) + { + if(y == 0) + return 1; + int result = x; + for(int i = 1; i < y; ++i) + result *= x; + return result; + } + + // sqrt: From Christopher J. Musial, An integer square root, Graphics Gems, 1990, page 387 + GLM_FUNC_QUALIFIER int sqrt(int x) + { + if(x <= 1) return x; + + int NextTrial = x >> 1; + int CurrentAnswer; + + do + { + CurrentAnswer = NextTrial; + NextTrial = (NextTrial + x / NextTrial) >> 1; + } while(NextTrial < CurrentAnswer); + + return CurrentAnswer; + } + +// Henry Gordon Dietz: http://aggregate.org/MAGIC/ +namespace _detail +{ + GLM_FUNC_QUALIFIER unsigned int ones32(unsigned int x) + { + /* 32-bit recursive reduction using SWAR... + but first step is mapping 2-bit values + into sum of 2 1-bit values in sneaky way + */ + x -= ((x >> 1) & 0x55555555); + x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); + x = (((x >> 4) + x) & 0x0f0f0f0f); + x += (x >> 8); + x += (x >> 16); + return(x & 0x0000003f); + } + + template <> + struct _compute_log2<detail::float_or_int_value::GLM_INT> + { + template <typename T> + GLM_FUNC_QUALIFIER T operator() (T const & Value) const + { +#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC)) + return Value <= T(1) ? T(0) : T(32) - nlz(Value - T(1)); +#else + return T(32) - nlz(Value - T(1)); +#endif + } + }; + +}//namespace _detail + + // Henry Gordon Dietz: http://aggregate.org/MAGIC/ +/* + GLM_FUNC_QUALIFIER unsigned int floor_log2(unsigned int x) + { + x |= (x >> 1); + x |= (x >> 2); + x |= (x >> 4); + x |= (x >> 8); + x |= (x >> 16); + + return _detail::ones32(x) >> 1; + } +*/ + // mod + GLM_FUNC_QUALIFIER int mod(int x, int y) + { + return x - y * (x / y); + } + + // factorial (!12 max, integer only) + template <typename genType> + GLM_FUNC_QUALIFIER genType factorial(genType const & x) + { + genType Temp = x; + genType Result; + for(Result = 1; Temp > 1; --Temp) + Result *= Temp; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec2<valType> factorial( + detail::tvec2<valType> const & x) + { + return detail::tvec2<valType>( + factorial(x.x), + factorial(x.y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> factorial( + detail::tvec3<valType> const & x) + { + return detail::tvec3<valType>( + factorial(x.x), + factorial(x.y), + factorial(x.z)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec4<valType> factorial( + detail::tvec4<valType> const & x) + { + return detail::tvec4<valType>( + factorial(x.x), + factorial(x.y), + factorial(x.z), + factorial(x.w)); + } + + GLM_FUNC_QUALIFIER uint pow(uint x, uint y) + { + uint result = x; + for(uint i = 1; i < y; ++i) + result *= x; + return result; + } + + GLM_FUNC_QUALIFIER uint sqrt(uint x) + { + if(x <= 1) return x; + + uint NextTrial = x >> 1; + uint CurrentAnswer; + + do + { + CurrentAnswer = NextTrial; + NextTrial = (NextTrial + x / NextTrial) >> 1; + } while(NextTrial < CurrentAnswer); + + return CurrentAnswer; + } + + GLM_FUNC_QUALIFIER uint mod(uint x, uint y) + { + return x - y * (x / y); + } + +#if(GLM_COMPILER & (GLM_COMPILER_VC | GLM_COMPILER_GCC)) + + GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x) + { + return 31u - findMSB(x); + } + +#else + + // Hackers Delight: http://www.hackersdelight.org/HDcode/nlz.c.txt + GLM_FUNC_QUALIFIER unsigned int nlz(unsigned int x) + { + int y, m, n; + + y = -int(x >> 16); // If left half of x is 0, + m = (y >> 16) & 16; // set n = 16. If left half + n = 16 - m; // is nonzero, set n = 0 and + x = x >> m; // shift x right 16. + // Now x is of the form 0000xxxx. + y = x - 0x100; // If positions 8-15 are 0, + m = (y >> 16) & 8; // add 8 to n and shift x left 8. + n = n + m; + x = x << m; + + y = x - 0x1000; // If positions 12-15 are 0, + m = (y >> 16) & 4; // add 4 to n and shift x left 4. + n = n + m; + x = x << m; + + y = x - 0x4000; // If positions 14-15 are 0, + m = (y >> 16) & 2; // add 2 to n and shift x left 2. + n = n + m; + x = x << m; + + y = x >> 14; // Set y = 0, 1, 2, or 3. + m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp. + return unsigned(n + 2 - m); + } + +#endif//(GLM_COMPILER) + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/intersect.hpp b/include/gal/opengl/glm/gtx/intersect.hpp new file mode 100644 index 0000000..e3319ee --- /dev/null +++ b/include/gal/opengl/glm/gtx/intersect.hpp @@ -0,0 +1,102 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_intersect +/// @file glm/gtx/intersect.hpp +/// @date 2007-04-03 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_closest_point (dependence) +/// +/// @defgroup gtx_intersect GLM_GTX_intersect +/// @ingroup gtx +/// +/// @brief Add intersection functions +/// +/// <glm/gtx/intersect.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_intersect +#define GLM_GTX_intersect GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/closest_point.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_closest_point extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_intersect + /// @{ + + //! Compute the intersection of a ray and a triangle. + //! From GLM_GTX_intersect extension. + template <typename genType> + bool intersectRayTriangle( + genType const & orig, genType const & dir, + genType const & vert0, genType const & vert1, genType const & vert2, + genType & baryPosition); + + //! Compute the intersection of a line and a triangle. + //! From GLM_GTX_intersect extension. + template <typename genType> + bool intersectLineTriangle( + genType const & orig, genType const & dir, + genType const & vert0, genType const & vert1, genType const & vert2, + genType & position); + + //! Compute the intersection distance of a ray and a sphere. + //! The ray direction vector is unit length. + //! From GLM_GTX_intersect extension. + template <typename genType> + bool intersectRaySphere( + genType const & rayStarting, genType const & rayNormalizedDirection, + genType const & sphereCenter, const typename genType::value_type sphereRadiusSquered, + typename genType::value_type & intersectionDistance); + + //! Compute the intersection of a ray and a sphere. + //! From GLM_GTX_intersect extension. + template <typename genType> + bool intersectRaySphere( + genType const & rayStarting, genType const & rayNormalizedDirection, + genType const & sphereCenter, const typename genType::value_type sphereRadius, + genType & intersectionPosition, genType & intersectionNormal); + + //! Compute the intersection of a line and a sphere. + //! From GLM_GTX_intersect extension + template <typename genType> + bool intersectLineSphere( + genType const & point0, genType const & point1, + genType const & sphereCenter, typename genType::value_type sphereRadius, + genType & intersectionPosition1, genType & intersectionNormal1, + genType & intersectionPosition2 = genType(), genType & intersectionNormal2 = genType()); + + /// @} +}//namespace glm + +#include "intersect.inl" + +#endif//GLM_GTX_intersect diff --git a/include/gal/opengl/glm/gtx/intersect.inl b/include/gal/opengl/glm/gtx/intersect.inl new file mode 100644 index 0000000..3fd8cea --- /dev/null +++ b/include/gal/opengl/glm/gtx/intersect.inl @@ -0,0 +1,196 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-04-03 +// Updated : 2009-01-20 +// Licence : This source is under MIT licence +// File : glm/gtx/intersect.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include <cfloat> +#include <limits> + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER bool intersectRayTriangle + ( + genType const & orig, genType const & dir, + genType const & v0, genType const & v1, genType const & v2, + genType & baryPosition + ) + { + genType e1 = v1 - v0; + genType e2 = v2 - v0; + + genType p = glm::cross(dir, e2); + + typename genType::value_type a = glm::dot(e1, p); + + typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); + if(a < Epsilon) + return false; + + typename genType::value_type f = typename genType::value_type(1.0f) / a; + + genType s = orig - v0; + baryPosition.x = f * glm::dot(s, p); + if(baryPosition.x < typename genType::value_type(0.0f)) + return false; + if(baryPosition.x > typename genType::value_type(1.0f)) + return false; + + genType q = glm::cross(s, e1); + baryPosition.y = f * glm::dot(dir, q); + if(baryPosition.y < typename genType::value_type(0.0f)) + return false; + if(baryPosition.y + baryPosition.x > typename genType::value_type(1.0f)) + return false; + + baryPosition.z = f * glm::dot(e2, q); + + return baryPosition.z >= typename genType::value_type(0.0f); + } + + //template <typename genType> + //GLM_FUNC_QUALIFIER bool intersectRayTriangle + //( + // genType const & orig, genType const & dir, + // genType const & vert0, genType const & vert1, genType const & vert2, + // genType & position + //) + //{ + // typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); + // + // genType edge1 = vert1 - vert0; + // genType edge2 = vert2 - vert0; + // + // genType pvec = cross(dir, edge2); + // + // float det = dot(edge1, pvec); + // if(det < Epsilon) + // return false; + // + // genType tvec = orig - vert0; + // + // position.y = dot(tvec, pvec); + // if (position.y < typename genType::value_type(0) || position.y > det) + // return typename genType::value_type(0); + // + // genType qvec = cross(tvec, edge1); + // + // position.z = dot(dir, qvec); + // if (position.z < typename genType::value_type(0) || position.y + position.z > det) + // return typename genType::value_type(0); + // + // position.x = dot(edge2, qvec); + // position *= typename genType::value_type(1) / det; + // + // return typename genType::value_type(1); + //} + + template <typename genType> + GLM_FUNC_QUALIFIER bool intersectLineTriangle + ( + genType const & orig, genType const & dir, + genType const & vert0, genType const & vert1, genType const & vert2, + genType & position + ) + { + typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); + + genType edge1 = vert1 - vert0; + genType edge2 = vert2 - vert0; + + genType pvec = cross(dir, edge2); + + float det = dot(edge1, pvec); + + if (det > -Epsilon && det < Epsilon) + return false; + float inv_det = typename genType::value_type(1) / det; + + genType tvec = orig - vert0; + + position.y = dot(tvec, pvec) * inv_det; + if (position.y < typename genType::value_type(0) || position.y > typename genType::value_type(1)) + return false; + + genType qvec = cross(tvec, edge1); + + position.z = dot(dir, qvec) * inv_det; + if (position.z < typename genType::value_type(0) || position.y + position.z > typename genType::value_type(1)) + return false; + + position.x = dot(edge2, qvec) * inv_det; + + return true; + } + + template <typename genType> + GLM_FUNC_QUALIFIER bool intersectRaySphere + ( + genType const & rayStarting, genType const & rayNormalizedDirection, + genType const & sphereCenter, const typename genType::value_type sphereRadiusSquered, + typename genType::value_type & intersectionDistance + ) + { + typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); + genType diff = sphereCenter - rayStarting; + typename genType::value_type t0 = dot(diff, rayNormalizedDirection); + typename genType::value_type dSquared = dot(diff, diff) - t0 * t0; + if( dSquared > sphereRadiusSquered ) + { + return false; + } + typename genType::value_type t1 = sqrt( sphereRadiusSquered - dSquared ); + intersectionDistance = t0 > t1 + Epsilon ? t0 - t1 : t0 + t1; + return intersectionDistance > Epsilon; + } + + template <typename genType> + GLM_FUNC_QUALIFIER bool intersectRaySphere + ( + genType const & rayStarting, genType const & rayNormalizedDirection, + genType const & sphereCenter, const typename genType::value_type sphereRadius, + genType & intersectionPosition, genType & intersectionNormal + ) + { + typename genType::value_type distance; + if( intersectRaySphere( rayStarting, rayNormalizedDirection, sphereCenter, sphereRadius * sphereRadius, distance ) ) + { + intersectionPosition = rayStarting + rayNormalizedDirection * distance; + intersectionNormal = (intersectionPosition - sphereCenter) / sphereRadius; + return true; + } + return false; + } + + template <typename genType> + GLM_FUNC_QUALIFIER bool intersectLineSphere + ( + genType const & point0, genType const & point1, + genType const & sphereCenter, typename genType::value_type sphereRadius, + genType & intersectionPoint1, genType & intersectionNormal1, + genType & intersectionPoint2, genType & intersectionNormal2 + ) + { + typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); + genType dir = normalize(point1 - point0); + genType diff = sphereCenter - point0; + typename genType::value_type t0 = dot(diff, dir); + typename genType::value_type dSquared = dot(diff, diff) - t0 * t0; + if( dSquared > sphereRadius * sphereRadius ) + { + return false; + } + typename genType::value_type t1 = sqrt( sphereRadius * sphereRadius - dSquared ); + if( t0 < t1 + Epsilon ) + t1 = -t1; + intersectionPoint1 = point0 + dir * (t0 - t1); + intersectionNormal1 = (intersectionPoint1 - sphereCenter) / sphereRadius; + intersectionPoint2 = point0 + dir * (t0 + t1); + intersectionNormal2 = (intersectionPoint2 - sphereCenter) / sphereRadius; + return true; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/log_base.hpp b/include/gal/opengl/glm/gtx/log_base.hpp new file mode 100644 index 0000000..0f2033e --- /dev/null +++ b/include/gal/opengl/glm/gtx/log_base.hpp @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_log_base +/// @file glm/gtx/log_base.hpp +/// @date 2008-10-24 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_log_base GLM_GTX_log_base +/// @ingroup gtx +/// +/// @brief Logarithm for any base. base can be a vector or a scalar. +/// +/// <glm/gtx/log_base.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_log_base +#define GLM_GTX_log_base GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_log_base extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_log_base + /// @{ + + //! Logarithm for any base. + //! From GLM_GTX_log_base. + template <typename genType> + genType log( + genType const & x, + genType const & base); + + /// @} +}//namespace glm + +#include "log_base.inl" + +#endif//GLM_GTX_log_base diff --git a/include/gal/opengl/glm/gtx/log_base.inl b/include/gal/opengl/glm/gtx/log_base.inl new file mode 100644 index 0000000..d8be51e --- /dev/null +++ b/include/gal/opengl/glm/gtx/log_base.inl @@ -0,0 +1,24 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-10-24 +// Updated : 2008-10-24 +// Licence : This source is under MIT License +// File : glm/gtx/log_base.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER genType log( + genType const & x, + genType const & base) + { + assert(x != genType(0)); + + return glm::log(x) / glm::log(base); + } + + VECTORIZE_VEC_SCA(log) + VECTORIZE_VEC_VEC(log) +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/matrix_cross_product.hpp b/include/gal/opengl/glm/gtx/matrix_cross_product.hpp new file mode 100644 index 0000000..a298ab8 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_cross_product.hpp @@ -0,0 +1,71 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_matrix_cross_product +/// @file glm/gtx/matrix_cross_product.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product +/// @ingroup gtx +/// +/// @brief Build cross product matrices +/// +/// <glm/gtx/matrix_cross_product.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_matrix_cross_product +#define GLM_GTX_matrix_cross_product GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_matrix_cross_product extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_matrix_cross_product + /// @{ + + //! Build a cross product matrix. + //! From GLM_GTX_matrix_cross_product extension. + template <typename T> + detail::tmat3x3<T> matrixCross3( + detail::tvec3<T> const & x); + + //! Build a cross product matrix. + //! From GLM_GTX_matrix_cross_product extension. + template <typename T> + detail::tmat4x4<T> matrixCross4( + detail::tvec3<T> const & x); + + /// @} +}//namespace glm + +#include "matrix_cross_product.inl" + +#endif//GLM_GTX_matrix_cross_product diff --git a/include/gal/opengl/glm/gtx/matrix_cross_product.inl b/include/gal/opengl/glm/gtx/matrix_cross_product.inl new file mode 100644 index 0000000..5da4403 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_cross_product.inl @@ -0,0 +1,44 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under MIT License +// File : glm/gtx/matrix_cross_product.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> matrixCross3 + ( + detail::tvec3<T> const & x + ) + { + detail::tmat3x3<T> Result(T(0)); + Result[0][1] = x.z; + Result[1][0] = -x.z; + Result[0][2] = -x.y; + Result[2][0] = x.y; + Result[1][2] = x.x; + Result[2][1] = -x.x; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> matrixCross4 + ( + detail::tvec3<T> const & x + ) + { + detail::tmat4x4<T> Result(T(0)); + Result[0][1] = x.z; + Result[1][0] = -x.z; + Result[0][2] = -x.y; + Result[2][0] = x.y; + Result[1][2] = x.x; + Result[2][1] = -x.x; + return Result; + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/matrix_interpolation.hpp b/include/gal/opengl/glm/gtx/matrix_interpolation.hpp new file mode 100644 index 0000000..75f2047 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_interpolation.hpp @@ -0,0 +1,88 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_matrix_interpolation +/// @file glm/gtx/matrix_interpolation.hpp +/// @date 2011-03-05 / 2011-06-07 +/// @author Ghenadii Ursachi (the.asteroth@gmail.com) +/// +/// @see core (dependence) +/// +/// @defgroup gtx_matrix_interpolation GLM_GTX_matrix_interpolation +/// @ingroup gtx +/// +/// @brief Allows to directly interpolate two exiciting matrices. +/// +/// <glm/gtx/matrix_interpolation.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_matrix_interpolation +#define GLM_GTX_matrix_interpolation GLM_VERSION + +// Dependency: +//#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_matrix_interpolation extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_matrix_interpolation + /// @{ + + //! Get the axis and angle of the rotation from a matrix. + //! From GLM_GTX_matrix_interpolation extension. + template <typename T> + void axisAngle( + detail::tmat4x4<T> const & mat, + detail::tvec3<T> & axis, + T & angle); + + //! Build a matrix from axis and angle. + //! From GLM_GTX_matrix_interpolation extension. + template <typename T> + detail::tmat4x4<T> axisAngleMatrix( + detail::tvec3<T> const & axis, + T const angle); + + //! Extracts the rotation part of a matrix. + //! From GLM_GTX_matrix_interpolation extension. + template <typename T> + detail::tmat4x4<T> extractMatrixRotation( + detail::tmat4x4<T> const & mat); + + //! Build a interpolation of 4 * 4 matrixes. + //! From GLM_GTX_matrix_interpolation extension. + //! Warning! works only with rotation and/or translation matrixes, scale will generate unexpected results. + template <typename T> + detail::tmat4x4<T> interpolate( + detail::tmat4x4<T> const & m1, + detail::tmat4x4<T> const & m2, + T const delta); + + /// @} +}//namespace glm + +#include "matrix_interpolation.inl" + +#endif//GLM_GTX_matrix_interpolation diff --git a/include/gal/opengl/glm/gtx/matrix_interpolation.inl b/include/gal/opengl/glm/gtx/matrix_interpolation.inl new file mode 100644 index 0000000..8ab1343 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_interpolation.inl @@ -0,0 +1,131 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-03-05 +// Updated : 2011-03-05 +// Licence : This source is under MIT License +// File : glm/gtx/matrix_interpolation.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER void axisAngle + ( + detail::tmat4x4<T> const & mat, + detail::tvec3<T> & axis, + T & angle + ) + { + T epsilon = (T)0.01; + T epsilon2 = (T)0.1; + + if ((fabs(mat[1][0] - mat[0][1]) < epsilon) && (fabs(mat[2][0] - mat[0][2]) < epsilon) && (fabs(mat[2][1] - mat[1][2]) < epsilon)) { + if ((fabs(mat[1][0] + mat[0][1]) < epsilon2) && (fabs(mat[2][0] + mat[0][2]) < epsilon2) && (fabs(mat[2][1] + mat[1][2]) < epsilon2) && (fabs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2)) { + angle = (T)0.0; + axis.x = (T)1.0; + axis.y = (T)0.0; + axis.z = (T)0.0; + return; + } + angle = T(3.1415926535897932384626433832795); + T xx = (mat[0][0] + (T)1.0) / (T)2.0; + T yy = (mat[1][1] + (T)1.0) / (T)2.0; + T zz = (mat[2][2] + (T)1.0) / (T)2.0; + T xy = (mat[1][0] + mat[0][1]) / (T)4.0; + T xz = (mat[2][0] + mat[0][2]) / (T)4.0; + T yz = (mat[2][1] + mat[1][2]) / (T)4.0; + if ((xx > yy) && (xx > zz)) { + if (xx < epsilon) { + axis.x = (T)0.0; + axis.y = (T)0.7071; + axis.z = (T)0.7071; + } else { + axis.x = sqrt(xx); + axis.y = xy / axis.x; + axis.z = xz / axis.x; + } + } else if (yy > zz) { + if (yy < epsilon) { + axis.x = (T)0.7071; + axis.y = (T)0.0; + axis.z = (T)0.7071; + } else { + axis.y = sqrt(yy); + axis.x = xy / axis.y; + axis.z = yz / axis.y; + } + } else { + if (zz < epsilon) { + axis.x = (T)0.7071; + axis.y = (T)0.7071; + axis.z = (T)0.0; + } else { + axis.z = sqrt(zz); + axis.x = xz / axis.z; + axis.y = yz / axis.z; + } + } + return; + } + T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1])); + if (glm::abs(s) < T(0.001)) + s = (T)1.0; + angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0); + axis.x = (mat[1][2] - mat[2][1]) / s; + axis.y = (mat[2][0] - mat[0][2]) / s; + axis.z = (mat[0][1] - mat[1][0]) / s; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> axisAngleMatrix + ( + detail::tvec3<T> const & axis, + T const angle + ) + { + T c = cos(angle); + T s = sin(angle); + T t = T(1) - c; + detail::tvec3<T> n = normalize(axis); + + return detail::tmat4x4<T>( + t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, T(0), + t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, T(0), + t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, T(0), + T(0), T(0), T(0), T(1) + ); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> extractMatrixRotation( + detail::tmat4x4<T> const & mat) + { + return detail::tmat4x4<T>( + mat[0][0], mat[0][1], mat[0][2], 0.0, + mat[1][0], mat[1][1], mat[1][2], 0.0, + mat[2][0], mat[2][1], mat[2][2], 0.0, + 0.0, 0.0, 0.0, 1.0 + ); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> interpolate + ( + detail::tmat4x4<T> const & m1, + detail::tmat4x4<T> const & m2, + T const delta + ) + { + detail::tmat4x4<T> m1rot = extractMatrixRotation(m1); + detail::tmat4x4<T> dltRotation = m2 * transpose(m1rot); + detail::tvec3<T> dltAxis; + T dltAngle; + axisAngle(dltRotation, dltAxis, dltAngle); + detail::tmat4x4<T> out = axisAngleMatrix(dltAxis, dltAngle * delta) * m1rot; + out[3][0] = m1[3][0] + delta * (m2[3][0] - m1[3][0]); + out[3][1] = m1[3][1] + delta * (m2[3][1] - m1[3][1]); + out[3][2] = m1[3][2] + delta * (m2[3][2] - m1[3][2]); + return out; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/matrix_major_storage.hpp b/include/gal/opengl/glm/gtx/matrix_major_storage.hpp new file mode 100644 index 0000000..74b5db0 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_major_storage.hpp @@ -0,0 +1,143 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_matrix_major_storage +/// @file glm/gtx/matrix_major_storage.hpp +/// @date 2006-04-19 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_matrix_major_storage GLM_GTX_matrix_major_storage +/// @ingroup gtx +/// +/// @brief Build matrices with specific matrix order, row or column +/// +/// <glm/gtx/matrix_major_storage.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_matrix_major_storage +#define GLM_GTX_matrix_major_storage GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_matrix_major_storage extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_matrix_major_storage + /// @{ + + //! Build a row major matrix from row vectors. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat2x2<T> rowMajor2( + detail::tvec2<T> const & v1, + detail::tvec2<T> const & v2); + + //! Build a row major matrix from other matrix. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat2x2<T> rowMajor2( + detail::tmat2x2<T> const & m); + + //! Build a row major matrix from row vectors. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat3x3<T> rowMajor3( + detail::tvec3<T> const & v1, + detail::tvec3<T> const & v2, + detail::tvec3<T> const & v3); + + //! Build a row major matrix from other matrix. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat3x3<T> rowMajor3( + detail::tmat3x3<T> const & m); + + //! Build a row major matrix from row vectors. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat4x4<T> rowMajor4( + detail::tvec4<T> const & v1, + detail::tvec4<T> const & v2, + detail::tvec4<T> const & v3, + detail::tvec4<T> const & v4); + + //! Build a row major matrix from other matrix. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat4x4<T> rowMajor4( + detail::tmat4x4<T> const & m); + + //! Build a column major matrix from column vectors. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat2x2<T> colMajor2( + detail::tvec2<T> const & v1, + detail::tvec2<T> const & v2); + + //! Build a column major matrix from other matrix. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat2x2<T> colMajor2( + detail::tmat2x2<T> const & m); + + //! Build a column major matrix from column vectors. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat3x3<T> colMajor3( + detail::tvec3<T> const & v1, + detail::tvec3<T> const & v2, + detail::tvec3<T> const & v3); + + //! Build a column major matrix from other matrix. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat3x3<T> colMajor3( + detail::tmat3x3<T> const & m); + + //! Build a column major matrix from column vectors. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat4x4<T> colMajor4( + detail::tvec4<T> const & v1, + detail::tvec4<T> const & v2, + detail::tvec4<T> const & v3, + detail::tvec4<T> const & v4); + + //! Build a column major matrix from other matrix. + //! From GLM_GTX_matrix_major_storage extension. + template <typename T> + detail::tmat4x4<T> colMajor4( + detail::tmat4x4<T> const & m); + + /// @} +}//namespace glm + +#include "matrix_major_storage.inl" + +#endif//GLM_GTX_matrix_major_storage diff --git a/include/gal/opengl/glm/gtx/matrix_major_storage.inl b/include/gal/opengl/glm/gtx/matrix_major_storage.inl new file mode 100644 index 0000000..a12ed36 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_major_storage.inl @@ -0,0 +1,173 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-19 +// Updated : 2009-02-19 +// Licence : This source is under MIT License +// File : glm/gtx/matrix_major_storage.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2 + ( + detail::tvec2<T> const & v1, + detail::tvec2<T> const & v2 + ) + { + detail::tmat2x2<T> Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat2x2<T> rowMajor2( + const detail::tmat2x2<T>& m) + { + detail::tmat2x2<T> Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3( + const detail::tvec3<T>& v1, + const detail::tvec3<T>& v2, + const detail::tvec3<T>& v3) + { + detail::tmat3x3<T> Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[2][0] = v1.z; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + Result[2][1] = v2.z; + Result[0][2] = v3.x; + Result[1][2] = v3.y; + Result[2][2] = v3.z; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> rowMajor3( + const detail::tmat3x3<T>& m) + { + detail::tmat3x3<T> Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[0][2] = m[2][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + Result[1][2] = m[2][1]; + Result[2][0] = m[0][2]; + Result[2][1] = m[1][2]; + Result[2][2] = m[2][2]; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4( + const detail::tvec4<T>& v1, + const detail::tvec4<T>& v2, + const detail::tvec4<T>& v3, + const detail::tvec4<T>& v4) + { + detail::tmat4x4<T> Result; + Result[0][0] = v1.x; + Result[1][0] = v1.y; + Result[2][0] = v1.z; + Result[3][0] = v1.w; + Result[0][1] = v2.x; + Result[1][1] = v2.y; + Result[2][1] = v2.z; + Result[3][1] = v2.w; + Result[0][2] = v3.x; + Result[1][2] = v3.y; + Result[2][2] = v3.z; + Result[3][2] = v3.w; + Result[0][3] = v4.x; + Result[1][3] = v4.y; + Result[2][3] = v4.z; + Result[3][3] = v4.w; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> rowMajor4( + const detail::tmat4x4<T>& m) + { + detail::tmat4x4<T> Result; + Result[0][0] = m[0][0]; + Result[0][1] = m[1][0]; + Result[0][2] = m[2][0]; + Result[0][3] = m[3][0]; + Result[1][0] = m[0][1]; + Result[1][1] = m[1][1]; + Result[1][2] = m[2][1]; + Result[1][3] = m[3][1]; + Result[2][0] = m[0][2]; + Result[2][1] = m[1][2]; + Result[2][2] = m[2][2]; + Result[2][3] = m[3][2]; + Result[3][0] = m[0][3]; + Result[3][1] = m[1][3]; + Result[3][2] = m[2][3]; + Result[3][3] = m[3][3]; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2( + const detail::tvec2<T>& v1, + const detail::tvec2<T>& v2) + { + return detail::tmat2x2<T>(v1, v2); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat2x2<T> colMajor2( + const detail::tmat2x2<T>& m) + { + return detail::tmat2x2<T>(m); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3( + const detail::tvec3<T>& v1, + const detail::tvec3<T>& v2, + const detail::tvec3<T>& v3) + { + return detail::tmat3x3<T>(v1, v2, v3); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> colMajor3( + const detail::tmat3x3<T>& m) + { + return detail::tmat3x3<T>(m); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4( + const detail::tvec4<T>& v1, + const detail::tvec4<T>& v2, + const detail::tvec4<T>& v3, + const detail::tvec4<T>& v4) + { + return detail::tmat4x4<T>(v1, v2, v3, v4); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> colMajor4( + const detail::tmat4x4<T>& m) + { + return detail::tmat4x4<T>(m); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/matrix_operation.hpp b/include/gal/opengl/glm/gtx/matrix_operation.hpp new file mode 100644 index 0000000..8a57324 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_operation.hpp @@ -0,0 +1,112 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_matrix_operation +/// @file glm/gtx/matrix_operation.hpp +/// @date 2009-08-29 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_matrix_operation GLM_GTX_matrix_operation +/// @ingroup gtx +/// +/// @brief Build diagonal matrices from vectors. +/// +/// <glm/gtx/matrix_operation.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_matrix_operation +#define GLM_GTX_matrix_operation GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_matrix_operation extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_matrix_operation + /// @{ + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat2x2<valType> diagonal2x2( + detail::tvec2<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat2x3<valType> diagonal2x3( + detail::tvec2<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat2x4<valType> diagonal2x4( + detail::tvec2<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat3x2<valType> diagonal3x2( + detail::tvec2<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat3x3<valType> diagonal3x3( + detail::tvec3<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat3x4<valType> diagonal3x4( + detail::tvec3<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat4x2<valType> diagonal4x2( + detail::tvec2<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat4x3<valType> diagonal4x3( + detail::tvec3<valType> const & v); + + //! Build a diagonal matrix. + //! From GLM_GTX_matrix_operation extension. + template <typename valType> + detail::tmat4x4<valType> diagonal4x4( + detail::tvec4<valType> const & v); + + /// @} +}//namespace glm + +#include "matrix_operation.inl" + +#endif//GLM_GTX_matrix_operation diff --git a/include/gal/opengl/glm/gtx/matrix_operation.inl b/include/gal/opengl/glm/gtx/matrix_operation.inl new file mode 100644 index 0000000..37b2b02 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_operation.inl @@ -0,0 +1,124 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-08-29 +// Updated : 2009-08-29 +// Licence : This source is under MIT License +// File : glm/gtx/matrix_operation.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat2x2<valType> diagonal2x2 + ( + detail::tvec2<valType> const & v + ) + { + detail::tmat2x2<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat2x3<valType> diagonal2x3 + ( + detail::tvec2<valType> const & v + ) + { + detail::tmat2x3<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat2x4<valType> diagonal2x4 + ( + detail::tvec2<valType> const & v + ) + { + detail::tmat2x4<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat3x2<valType> diagonal3x2 + ( + detail::tvec2<valType> const & v + ) + { + detail::tmat3x2<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat3x3<valType> diagonal3x3 + ( + detail::tvec3<valType> const & v + ) + { + detail::tmat3x3<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat3x4<valType> diagonal3x4 + ( + detail::tvec3<valType> const & v + ) + { + detail::tmat3x4<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x4<valType> diagonal4x4 + ( + detail::tvec4<valType> const & v + ) + { + detail::tmat4x4<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + Result[3][3] = v[3]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x3<valType> diagonal4x3 + ( + detail::tvec3<valType> const & v + ) + { + detail::tmat4x3<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + Result[2][2] = v[2]; + return Result; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tmat4x2<valType> diagonal4x2 + ( + detail::tvec2<valType> const & v + ) + { + detail::tmat4x2<valType> Result(valType(1)); + Result[0][0] = v[0]; + Result[1][1] = v[1]; + return Result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/matrix_query.hpp b/include/gal/opengl/glm/gtx/matrix_query.hpp new file mode 100644 index 0000000..bba233b --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_query.hpp @@ -0,0 +1,117 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_matrix_query +/// @file glm/gtx/matrix_query.hpp +/// @date 2007-03-05 / 2011-08-28 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_vector_query (dependence) +/// +/// @defgroup gtx_matrix_query GLM_GTX_matrix_query +/// @ingroup gtx +/// +/// @brief Query to evaluate matrix properties +/// +/// <glm/gtx/matrix_query.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_matrix_query +#define GLM_GTX_matrix_query GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/vector_query.hpp" +#include <limits> + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_matrix_query extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_matrix_query + /// @{ + + /// Return whether a matrix a null matrix. + /// From GLM_GTX_matrix_query extension. + template<typename T> + bool isNull( + detail::tmat2x2<T> const & m, + T const & epsilon/* = std::numeric_limits<T>::epsilon()*/); + + /// Return whether a matrix a null matrix. + /// From GLM_GTX_matrix_query extension. + template<typename T> + bool isNull( + detail::tmat3x3<T> const & m, + T const & epsilon/* = std::numeric_limits<T>::epsilon()*/); + + /// Return whether a matrix is a null matrix. + /// From GLM_GTX_matrix_query extension. + template<typename T> + bool isNull( + detail::tmat4x4<T> const & m, + T const & epsilon/* = std::numeric_limits<T>::epsilon()*/); + + /// Return whether a matrix is an identity matrix. + /// From GLM_GTX_matrix_query extension. + template<typename genType> + bool isIdentity( + genType const & m, + typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + /// Return whether a matrix is a normalized matrix. + /// From GLM_GTX_matrix_query extension. + template<typename valType> + bool isNormalized( + detail::tmat2x2<valType> const & m, + valType const & epsilon/* = std::numeric_limits<valType>::epsilon()*/); + + /// Return whether a matrix is a normalized matrix. + /// From GLM_GTX_matrix_query extension. + template<typename valType> + bool isNormalized( + detail::tmat3x3<valType> const & m, + valType const & epsilon/* = std::numeric_limits<valType>::epsilon()*/); + + /// Return whether a matrix is a normalized matrix. + /// From GLM_GTX_matrix_query extension. + template<typename valType> + bool isNormalized( + detail::tmat4x4<valType> const & m, + valType const & epsilon/* = std::numeric_limits<valType>::epsilon()*/); + + /// Return whether a matrix is an orthonormalized matrix. + /// From GLM_GTX_matrix_query extension. + template<typename valType, template <typename> class matType> + bool isOrthogonal( + matType<valType> const & m, + valType const & epsilon/* = std::numeric_limits<genType>::epsilon()*/); + + /// @} +}//namespace glm + +#include "matrix_query.inl" + +#endif//GLM_GTX_matrix_query diff --git a/include/gal/opengl/glm/gtx/matrix_query.inl b/include/gal/opengl/glm/gtx/matrix_query.inl new file mode 100644 index 0000000..6db3391 --- /dev/null +++ b/include/gal/opengl/glm/gtx/matrix_query.inl @@ -0,0 +1,154 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-05 +// Updated : 2007-03-05 +// Licence : This source is under MIT License +// File : glm/gtx/matrix_query.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template<typename T> + GLM_FUNC_QUALIFIER bool isNull + ( + detail::tmat2x2<T> const & m, + T const & epsilon) + { + bool result = true; + for(int i = 0; result && i < 2 ; ++i) + result = isNull(m[i], epsilon); + return result; + } + + template<typename T> + GLM_FUNC_QUALIFIER bool isNull + ( + detail::tmat3x3<T> const & m, + T const & epsilon + ) + { + bool result = true; + for(int i = 0; result && i < 3 ; ++i) + result = isNull(m[i], epsilon); + return result; + } + + template<typename T> + GLM_FUNC_QUALIFIER bool isNull + ( + detail::tmat4x4<T> const & m, + T const & epsilon + ) + { + bool result = true; + for(int i = 0; result && i < 4 ; ++i) + result = isNull(m[i], epsilon); + return result; + } + + template<typename genType> + GLM_FUNC_QUALIFIER bool isIdentity + ( + genType const & m, + typename genType::value_type const & epsilon + ) + { + bool result = true; + for(typename genType::size_type i = typename genType::size_type(0); result && i < genType::col_size(); ++i) + { + for(typename genType::size_type j = typename genType::size_type(0); result && j < i ; ++j) + result = abs(m[i][j]) <= epsilon; + if(result) + result = abs(m[i][i] - typename genType::value_type(1)) <= epsilon; + for(typename genType::size_type j = i + typename genType::size_type(1); result && j < genType::row_size(); ++j) + result = abs(m[i][j]) <= epsilon; + } + return result; + } + + template<typename genType> + GLM_FUNC_QUALIFIER bool isNormalized + ( + detail::tmat2x2<genType> const & m, + genType const & epsilon + ) + { + bool result(true); + for(typename detail::tmat2x2<genType>::size_type i(0); result && i < m.length(); ++i) + result = isNormalized(m[i], epsilon); + for(typename detail::tmat2x2<genType>::size_type i(0); result && i < m.length(); ++i) + { + typename detail::tmat2x2<genType>::col_type v; + for(typename detail::tmat2x2<genType>::size_type j(0); j < m.length(); ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } + + template<typename genType> + GLM_FUNC_QUALIFIER bool isNormalized + ( + detail::tmat3x3<genType> const & m, + genType const & epsilon + ) + { + bool result(true); + for(typename detail::tmat3x3<genType>::size_type i(0); result && i < m.length(); ++i) + result = isNormalized(m[i], epsilon); + for(typename detail::tmat3x3<genType>::size_type i(0); result && i < m.length(); ++i) + { + typename detail::tmat3x3<genType>::col_type v; + for(typename detail::tmat3x3<genType>::size_type j(0); j < m.length(); ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } + + template<typename genType> + GLM_FUNC_QUALIFIER bool isNormalized + ( + detail::tmat4x4<genType> const & m, + genType const & epsilon + ) + { + bool result(true); + for(typename detail::tmat4x4<genType>::size_type i(0); result && i < m.length(); ++i) + result = isNormalized(m[i], epsilon); + for(typename detail::tmat4x4<genType>::size_type i(0); result && i < m.length(); ++i) + { + typename detail::tmat4x4<genType>::col_type v; + for(typename detail::tmat4x4<genType>::size_type j(0); j < m.length(); ++j) + v[j] = m[j][i]; + result = isNormalized(v, epsilon); + } + return result; + } + + template<typename genType, template <typename> class matType> + GLM_FUNC_QUALIFIER bool isOrthogonal + ( + matType<genType> const & m, + genType const & epsilon + ) + { + bool result(true); + for(typename matType<genType>::size_type i(0); result && i < m.length() - 1; ++i) + for(typename matType<genType>::size_type j(i + 1); result && j < m.length(); ++j) + result = areOrthogonal(m[i], m[j], epsilon); + + if(result) + { + matType<genType> tmp = transpose(m); + for(typename matType<genType>::size_type i(0); result && i < m.length() - 1 ; ++i) + for(typename matType<genType>::size_type j(i + 1); result && j < m.length(); ++j) + result = areOrthogonal(tmp[i], tmp[j], epsilon); + } + return result; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/mixed_product.hpp b/include/gal/opengl/glm/gtx/mixed_product.hpp new file mode 100644 index 0000000..b222271 --- /dev/null +++ b/include/gal/opengl/glm/gtx/mixed_product.hpp @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_mixed_product +/// @file glm/gtx/mixed_product.hpp +/// @date 2007-04-03 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_mixed_product GLM_GTX_mixed_producte +/// @ingroup gtx +/// +/// @brief Mixed product of 3 vectors. +/// +/// <glm/gtx/mixed_product.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_mixed_product +#define GLM_GTX_mixed_product GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_mixed_product extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_mixed_product + /// @{ + + /// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension) + template <typename valType> + valType mixedProduct( + detail::tvec3<valType> const & v1, + detail::tvec3<valType> const & v2, + detail::tvec3<valType> const & v3); + + /// @} +}// namespace glm + +#include "mixed_product.inl" + +#endif//GLM_GTX_mixed_product diff --git a/include/gal/opengl/glm/gtx/mixed_product.inl b/include/gal/opengl/glm/gtx/mixed_product.inl new file mode 100644 index 0000000..9c3a179 --- /dev/null +++ b/include/gal/opengl/glm/gtx/mixed_product.inl @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-04-03 +// Updated : 2008-09-17 +// Licence : This source is under MIT License +// File : glm/gtx/mixed_product.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER valType mixedProduct + ( + detail::tvec3<valType> const & v1, + detail::tvec3<valType> const & v2, + detail::tvec3<valType> const & v3 + ) + { + return dot(cross(v1, v2), v3); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/multiple.hpp b/include/gal/opengl/glm/gtx/multiple.hpp new file mode 100644 index 0000000..0092802 --- /dev/null +++ b/include/gal/opengl/glm/gtx/multiple.hpp @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_multiple +/// @file glm/gtx/multiple.hpp +/// @date 2009-10-26 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_multiple GLM_GTX_multiple +/// @ingroup gtx +/// +/// @brief Find the closest number of a number multiple of other number. +/// +/// <glm/gtx/multiple.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_multiple +#define GLM_GTX_multiple GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_multiple extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_multiple + /// @{ + + //! Higher Multiple number of Source. + //! From GLM_GTX_multiple extension. + template <typename genType> + genType higherMultiple( + genType const & Source, + genType const & Multiple); + + //! Lower Multiple number of Source. + //! From GLM_GTX_multiple extension. + template <typename genType> + genType lowerMultiple( + genType const & Source, + genType const & Multiple); + + /// @} +}//namespace glm + +#include "multiple.inl" + +#endif//GLM_GTX_multiple diff --git a/include/gal/opengl/glm/gtx/multiple.inl b/include/gal/opengl/glm/gtx/multiple.inl new file mode 100644 index 0000000..e7d25b0 --- /dev/null +++ b/include/gal/opengl/glm/gtx/multiple.inl @@ -0,0 +1,128 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-10-26 +// Updated : 2011-06-07 +// Licence : This source is under MIT License +// File : glm/gtx/multiple.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + ////////////////////// + // higherMultiple + + template <typename genType> + GLM_FUNC_QUALIFIER genType higherMultiple + ( + genType const & Source, + genType const & Multiple + ) + { + if (Source > 0) + { + genType Tmp = Source - 1; + return Tmp + (Multiple - (Tmp % Multiple)); + } + else + return Source + (-Source % Multiple); + } + + template <> + GLM_FUNC_QUALIFIER detail::half higherMultiple + ( + detail::half const & SourceH, + detail::half const & MultipleH + ) + { + float Source = SourceH.toFloat(); + float Multiple = MultipleH.toFloat(); + + int Tmp = int(float(Source)) % int(Multiple); + return detail::half(Tmp ? Source + Multiple - float(Tmp) : Source); + } + + template <> + GLM_FUNC_QUALIFIER float higherMultiple + ( + float const & Source, + float const & Multiple + ) + { + int Tmp = int(Source) % int(Multiple); + return Tmp ? Source + Multiple - float(Tmp) : Source; + } + + template <> + GLM_FUNC_QUALIFIER double higherMultiple + ( + double const & Source, + double const & Multiple + ) + { + long Tmp = long(Source) % long(Multiple); + return Tmp ? Source + Multiple - double(Tmp) : Source; + } + + VECTORIZE_VEC_VEC(higherMultiple) + + ////////////////////// + // lowerMultiple + + template <typename genType> + GLM_FUNC_QUALIFIER genType lowerMultiple + ( + genType const & Source, + genType const & Multiple + ) + { + if (Source >= 0) + return Source - Source % Multiple; + else + { + genType Tmp = Source + 1; + return Tmp - Tmp % Multiple - Multiple; + } + } + + template <> + GLM_FUNC_QUALIFIER detail::half lowerMultiple + ( + detail::half const & SourceH, + detail::half const & MultipleH + ) + { + float Source = SourceH.toFloat(); + float Multiple = MultipleH.toFloat(); + + int Tmp = int(float(Source)) % int(float(Multiple)); + return detail::half(Tmp ? Source - float(Tmp) : Source); + } + + template <> + GLM_FUNC_QUALIFIER float lowerMultiple + ( + float const & Source, + float const & Multiple + ) + { + int Tmp = int(Source) % int(Multiple); + return Tmp ? Source - float(Tmp) : Source; + } + + template <> + GLM_FUNC_QUALIFIER double lowerMultiple + ( + double const & Source, + double const & Multiple + ) + { + long Tmp = long(Source) % long(Multiple); + return Tmp ? Source - double(Tmp) : Source; + } + + VECTORIZE_VEC_VEC(lowerMultiple) +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/noise.hpp b/include/gal/opengl/glm/gtx/noise.hpp new file mode 100644 index 0000000..f081dac --- /dev/null +++ b/include/gal/opengl/glm/gtx/noise.hpp @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_random extension is deprecated, include GLM_GTC_random (glm/gtc/noise.hpp) instead") +#endif + +// Promoted: +#include "../gtc/noise.hpp" diff --git a/include/gal/opengl/glm/gtx/norm.hpp b/include/gal/opengl/glm/gtx/norm.hpp new file mode 100644 index 0000000..2b065f4 --- /dev/null +++ b/include/gal/opengl/glm/gtx/norm.hpp @@ -0,0 +1,133 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_norm +/// @file glm/gtx/norm.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_quaternion (dependence) +/// +/// @defgroup gtx_norm GLM_GTX_norm +/// @ingroup gtx +/// +/// @brief Various ways to compute vector norms. +/// +/// <glm/gtx/norm.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_norm +#define GLM_GTX_norm GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/quaternion.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_norm extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_norm + /// @{ + + //! Returns the squared length of x. + //! From GLM_GTX_norm extension. + template <typename T> + T length2( + T const & x); + + //! Returns the squared length of x. + //! From GLM_GTX_norm extension. + template <typename genType> + typename genType::value_type length2( + genType const & x); + + //! Returns the squared length of x. + //! From GLM_GTX_norm extension. + template <typename T> + T length2( + detail::tquat<T> const & q); + + //! Returns the squared distance between p0 and p1, i.e., length(p0 - p1). + //! From GLM_GTX_norm extension. + template <typename T> + T distance2( + T const & p0, + T const & p1); + + //! Returns the squared distance between p0 and p1, i.e., length(p0 - p1). + //! From GLM_GTX_norm extension. + template <typename genType> + typename genType::value_type distance2( + genType const & p0, + genType const & p1); + + //! Returns the L1 norm between x and y. + //! From GLM_GTX_norm extension. + template <typename T> + T l1Norm( + detail::tvec3<T> const & x, + detail::tvec3<T> const & y); + + //! Returns the L1 norm of v. + //! From GLM_GTX_norm extension. + template <typename T> + T l1Norm( + detail::tvec3<T> const & v); + + //! Returns the L2 norm between x and y. + //! From GLM_GTX_norm extension. + template <typename T> + T l2Norm( + detail::tvec3<T> const & x, + detail::tvec3<T> const & y); + + //! Returns the L2 norm of v. + //! From GLM_GTX_norm extension. + template <typename T> + T l2Norm( + detail::tvec3<T> const & x); + + //! Returns the L norm between x and y. + //! From GLM_GTX_norm extension. + template <typename T> + T lxNorm( + detail::tvec3<T> const & x, + detail::tvec3<T> const & y, + unsigned int Depth); + + //! Returns the L norm of v. + //! From GLM_GTX_norm extension. + template <typename T> + T lxNorm( + detail::tvec3<T> const & x, + unsigned int Depth); + + /// @} +}//namespace glm + +#include "norm.inl" + +#endif//GLM_GTX_norm diff --git a/include/gal/opengl/glm/gtx/norm.inl b/include/gal/opengl/glm/gtx/norm.inl new file mode 100644 index 0000000..427a5a1 --- /dev/null +++ b/include/gal/opengl/glm/gtx/norm.inl @@ -0,0 +1,156 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2008-07-24 +// Licence : This source is under MIT License +// File : glm/gtx/norm.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER T length2 + ( + T const & x + ) + { + return x * x; + } + + template <typename T> + GLM_FUNC_QUALIFIER T length2 + ( + detail::tvec2<T> const & x + ) + { + return dot(x, x); + } + + template <typename T> + GLM_FUNC_QUALIFIER T length2 + ( + detail::tvec3<T> const & x + ) + { + return dot(x, x); + } + + template <typename T> + GLM_FUNC_QUALIFIER T length2 + ( + detail::tvec4<T> const & x + ) + { + return dot(x, x); + } + + template <typename T> + GLM_FUNC_QUALIFIER T length2 + ( + detail::tquat<T> const & q + ) + { + return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; + } + + template <typename T> + GLM_FUNC_QUALIFIER T distance2 + ( + T const & p0, + T const & p1 + ) + { + return length2(p1 - p0); + } + + template <typename T> + GLM_FUNC_QUALIFIER T distance2 + ( + detail::tvec2<T> const & p0, + detail::tvec2<T> const & p1 + ) + { + return length2(p1 - p0); + } + + template <typename T> + GLM_FUNC_QUALIFIER T distance2 + ( + detail::tvec3<T> const & p0, + detail::tvec3<T> const & p1 + ) + { + return length2(p1 - p0); + } + + template <typename T> + GLM_FUNC_QUALIFIER T distance2 + ( + detail::tvec4<T> const & p0, + detail::tvec4<T> const & p1 + ) + { + return length2(p1 - p0); + } + + template <typename T> + GLM_FUNC_QUALIFIER T l1Norm + ( + detail::tvec3<T> const & a, + detail::tvec3<T> const & b + ) + { + return abs(b.x - a.x) + abs(b.y - a.y) + abs(b.z - a.z); + } + + template <typename T> + GLM_FUNC_QUALIFIER T l1Norm + ( + detail::tvec3<T> const & v + ) + { + return abs(v.x) + abs(v.y) + abs(v.z); + } + + template <typename T> + GLM_FUNC_QUALIFIER T l2Norm + ( + detail::tvec3<T> const & a, + detail::tvec3<T> const & b + ) + { + return length(b - a); + } + + template <typename T> + GLM_FUNC_QUALIFIER T l2Norm + ( + detail::tvec3<T> const & v + ) + { + return length(v); + } + + template <typename T> + GLM_FUNC_QUALIFIER T lxNorm + ( + detail::tvec3<T> const & x, + detail::tvec3<T> const & y, + unsigned int Depth + ) + { + return pow(pow(y.x - x.x, T(Depth)) + pow(y.y - x.y, T(Depth)) + pow(y.z - x.z, T(Depth)), T(1) / T(Depth)); + } + + template <typename T> + GLM_FUNC_QUALIFIER T lxNorm + ( + detail::tvec3<T> const & v, + unsigned int Depth + ) + { + return pow(pow(v.x, T(Depth)) + pow(v.y, T(Depth)) + pow(v.z, T(Depth)), T(1) / T(Depth)); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/normal.hpp b/include/gal/opengl/glm/gtx/normal.hpp new file mode 100644 index 0000000..a04e304 --- /dev/null +++ b/include/gal/opengl/glm/gtx/normal.hpp @@ -0,0 +1,67 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_normal +/// @file glm/gtx/normal.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_normal GLM_GTX_normal +/// @ingroup gtx +/// +/// @brief Compute the normal of a triangle. +/// +/// <glm/gtx/normal.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_normal +#define GLM_GTX_normal GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_normal extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_normal + /// @{ + + //! Computes triangle normal from triangle points. + //! From GLM_GTX_normal extension. + template <typename T> + detail::tvec3<T> triangleNormal( + detail::tvec3<T> const & p1, + detail::tvec3<T> const & p2, + detail::tvec3<T> const & p3); + + /// @} +}//namespace glm + +#include "normal.inl" + +#endif//GLM_GTX_normal diff --git a/include/gal/opengl/glm/gtx/normal.inl b/include/gal/opengl/glm/gtx/normal.inl new file mode 100644 index 0000000..5aedcc7 --- /dev/null +++ b/include/gal/opengl/glm/gtx/normal.inl @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2011-06-07 +// Licence : This source is under MIT License +// File : glm/gtx/normal.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> triangleNormal + ( + detail::tvec3<T> const & p1, + detail::tvec3<T> const & p2, + detail::tvec3<T> const & p3 + ) + { + return normalize(cross(p1 - p2, p1 - p3)); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/normalize_dot.hpp b/include/gal/opengl/glm/gtx/normalize_dot.hpp new file mode 100644 index 0000000..1ba027a --- /dev/null +++ b/include/gal/opengl/glm/gtx/normalize_dot.hpp @@ -0,0 +1,76 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_normalize_dot +/// @file glm/gtx/normalize_dot.hpp +/// @date 2007-09-28 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_fast_square_root (dependence) +/// +/// @defgroup gtx_normalize_dot GLM_GTX_normalize_dot +/// @ingroup gtx +/// +/// @brief Dot product of vectors that need to be normalize with a single square root. +/// +/// <glm/gtx/normalized_dot.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_normalize_dot +#define GLM_GTX_normalize_dot GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/fast_square_root.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_normalize_dot extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_normalize_dot + /// @{ + + //! Normalize parameters and returns the dot product of x and y. + //! It's faster that dot(normalize(x), normalize(y)). + //! From GLM_GTX_normalize_dot extension. + template <typename genType> + typename genType::value_type normalizeDot( + genType const & x, + genType const & y); + + //! Normalize parameters and returns the dot product of x and y. + //! Faster that dot(fastNormalize(x), fastNormalize(y)). + //! From GLM_GTX_normalize_dot extension. + template <typename genType> + typename genType::value_type fastNormalizeDot( + genType const & x, + genType const & y); + + /// @} +}//namespace glm + +#include "normalize_dot.inl" + +#endif//GLM_GTX_normalize_dot diff --git a/include/gal/opengl/glm/gtx/normalize_dot.inl b/include/gal/opengl/glm/gtx/normalize_dot.inl new file mode 100644 index 0000000..5058eac --- /dev/null +++ b/include/gal/opengl/glm/gtx/normalize_dot.inl @@ -0,0 +1,115 @@ +////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-09-28 +// Updated : 2008-10-07 +// Licence : This source is under MIT License +// File : glm/gtx/normalize_dot.inl +////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER genType normalizeDot + ( + genType const & x, + genType const & y + ) + { + return + glm::dot(x, y) * + glm::inversesqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType normalizeDot + ( + detail::tvec2<valType> const & x, + detail::tvec2<valType> const & y + ) + { + return + glm::dot(x, y) * + glm::inversesqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType normalizeDot + ( + detail::tvec3<valType> const & x, + detail::tvec3<valType> const & y + ) + { + return + glm::dot(x, y) * + glm::inversesqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType normalizeDot + ( + detail::tvec4<valType> const & x, + detail::tvec4<valType> const & y + ) + { + return + glm::dot(x, y) * + glm::inversesqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename genType> + GLM_FUNC_QUALIFIER genType fastNormalizeDot + ( + genType const & x, + genType const & y + ) + { + return + glm::dot(x, y) * + fastInverseSqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType fastNormalizeDot + ( + detail::tvec2<valType> const & x, + detail::tvec2<valType> const & y + ) + { + return + glm::dot(x, y) * + fastInverseSqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType fastNormalizeDot + ( + detail::tvec3<valType> const & x, + detail::tvec3<valType> const & y + ) + { + return + glm::dot(x, y) * + fastInverseSqrt(glm::dot(x, x) * + glm::dot(y, y)); + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType fastNormalizeDot + ( + detail::tvec4<valType> const & x, + detail::tvec4<valType> const & y + ) + { + return + glm::dot(x, y) * + fastInverseSqrt(glm::dot(x, x) * + glm::dot(y, y)); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/number_precision.hpp b/include/gal/opengl/glm/gtx/number_precision.hpp new file mode 100644 index 0000000..1597936 --- /dev/null +++ b/include/gal/opengl/glm/gtx/number_precision.hpp @@ -0,0 +1,88 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_number_precision +/// @file glm/gtx/number_precision.hpp +/// @date 2007-05-10 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_type_precision (dependence) +/// @see gtc_quaternion (dependence) +/// +/// @defgroup gtx_number_precision GLM_GTX_number_precision +/// @ingroup gtx +/// +/// @brief Defined size types. +/// +/// <glm/gtx/number_precision.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_number_precision +#define GLM_GTX_number_precision GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/type_precision.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_number_precision extension included") +#endif + +namespace glm{ +namespace gtx +{ + ///////////////////////////// + // Unsigned int vector types + + /// @addtogroup gtx_number_precision + /// @{ + + typedef u8 u8vec1; //!< \brief 8bit unsigned integer scalar. (from GLM_GTX_number_precision extension) + typedef u16 u16vec1; //!< \brief 16bit unsigned integer scalar. (from GLM_GTX_number_precision extension) + typedef u32 u32vec1; //!< \brief 32bit unsigned integer scalar. (from GLM_GTX_number_precision extension) + typedef u64 u64vec1; //!< \brief 64bit unsigned integer scalar. (from GLM_GTX_number_precision extension) + + ////////////////////// + // Float vector types + + typedef f16 f16vec1; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f32 f32vec1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f64 f64vec1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) + + ////////////////////// + // Float matrix types + + typedef f16 f16mat1; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f16 f16mat1x1; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f32 f32mat1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f32 f32mat1x1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f64 f64mat1; //!< \brief Double-precision floating-point scalar. (from GLM_GTX_number_precision extension) + typedef f64 f64mat1x1; //!< \brief Double-precision floating-point scalar. (from GLM_GTX_number_precision extension) + + /// @} +}//namespace gtx +}//namespace glm + +#include "number_precision.inl" + +#endif//GLM_GTX_number_precision diff --git a/include/gal/opengl/glm/gtx/number_precision.inl b/include/gal/opengl/glm/gtx/number_precision.inl new file mode 100644 index 0000000..3981856 --- /dev/null +++ b/include/gal/opengl/glm/gtx/number_precision.inl @@ -0,0 +1,13 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-05-10 +// Updated : 2007-05-10 +// Licence : This source is under MIT License +// File : glm/gtx/number_precision.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + +} diff --git a/include/gal/opengl/glm/gtx/ocl_type.hpp b/include/gal/opengl/glm/gtx/ocl_type.hpp new file mode 100644 index 0000000..7e8af09 --- /dev/null +++ b/include/gal/opengl/glm/gtx/ocl_type.hpp @@ -0,0 +1,132 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_ocl_type +/// @file glm/gtx/ocl_type.hpp +/// @date 2009-05-07 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_ocl_type GLM_GTX_ocl_type +/// @ingroup gtx +/// +/// @brief OpenCL types. +/// +/// <glm/gtx/ocl_type.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_ocl_type +#define GLM_GTX_ocl_type GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_ocl_type extension included") +#endif + +namespace glm{ +namespace gtx +{ + /////////////////////////// + // Scalar types + + /// @addtogroup gtx_ocl_type + /// @{ + + typedef detail::int8 cl_char; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::int16 cl_short; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::int32 cl_int; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::int64 cl_long; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + typedef detail::uint8 cl_uchar; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::uint16 cl_ushort; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::uint32 cl_uint; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::uint64 cl_ulong; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + typedef detail::float16 cl_half; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + typedef detail::float32 cl_float; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + + + typedef detail::int8 cl_char1; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::int16 cl_short1; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::int32 cl_int1; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::int64 cl_long1; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + typedef detail::uint8 cl_uchar1; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::uint16 cl_ushort1; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::uint32 cl_uint1; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::uint64 cl_ulong1; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + //typedef detail::float16 cl_half1; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + typedef detail::float32 cl_float1; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + + + typedef detail::tvec2<detail::int8> cl_char2; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::int16> cl_short2; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::int32> cl_int2; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::int64> cl_long2; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + typedef detail::tvec2<detail::uint8> cl_uchar2; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::uint16> cl_ushort2; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::uint32> cl_uint2; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::uint64> cl_ulong2; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + //typedef detail::tvec2<detail::float16> cl_half2; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + typedef detail::tvec2<detail::float32> cl_float2; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + + + typedef detail::tvec3<detail::int8> cl_char3; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::int16> cl_short3; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::int32> cl_int3; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::int64> cl_long3; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + typedef detail::tvec3<detail::uint8> cl_uchar3; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::uint16> cl_ushort3; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::uint32> cl_uint3; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::uint64> cl_ulong3; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + //typedef detail::tvec3<detail::float16> cl_half3; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + typedef detail::tvec3<detail::float32> cl_float3; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + + + typedef detail::tvec4<detail::int8> cl_char4; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::int16> cl_short4; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::int32> cl_int4; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::int64> cl_long4; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::uint8> cl_uchar4; //!< \brief 8bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::uint16> cl_ushort4; //!< \brief 16bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::uint32> cl_uint4; //!< \brief 32bit signed integer. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::uint64> cl_ulong4; //!< \brief 64bit signed integer. (from GLM_GTX_ocl_type extension) + + //typedef detail::tvec4<detail::float16> cl_half4; //!< \brief Half-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + typedef detail::tvec4<detail::float32> cl_float4; //!< \brief Single-precision floating-point scalar. (from GLM_GTX_ocl_type extension) + + /// @} +}//namespace gtx +}//namespace glm + +#include "ocl_type.inl" + +#endif//GLM_GTX_ocl_type diff --git a/include/gal/opengl/glm/gtx/ocl_type.inl b/include/gal/opengl/glm/gtx/ocl_type.inl new file mode 100644 index 0000000..ac15145 --- /dev/null +++ b/include/gal/opengl/glm/gtx/ocl_type.inl @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_ocl_type +/// @file glm/gtx/ocl_type.inl +/// @date 2013-03-16 / 2013-03-16 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// diff --git a/include/gal/opengl/glm/gtx/optimum_pow.hpp b/include/gal/opengl/glm/gtx/optimum_pow.hpp new file mode 100644 index 0000000..d348473 --- /dev/null +++ b/include/gal/opengl/glm/gtx/optimum_pow.hpp @@ -0,0 +1,91 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_optimum_pow +/// @file glm/gtx/optimum_pow.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_optimum_pow GLM_GTX_optimum_pow +/// @ingroup gtx +/// +/// @brief Integer exponentiation of power functions. +/// +/// <glm/gtx/optimum_pow.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_optimum_pow +#define GLM_GTX_optimum_pow GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_optimum_pow extension included") +#endif + +namespace glm{ +namespace gtx +{ + /// @addtogroup gtx_optimum_pow + /// @{ + + //! Returns x raised to the power of 2. + //! From GLM_GTX_optimum_pow extension. + template <typename genType> + genType pow2(const genType& x); + + //! Returns x raised to the power of 3. + //! From GLM_GTX_optimum_pow extension. + template <typename genType> + genType pow3(const genType& x); + + //! Returns x raised to the power of 4. + //! From GLM_GTX_optimum_pow extension. + template <typename genType> + genType pow4(const genType& x); + + //! Checks if the parameter is a power of 2 number. + //! From GLM_GTX_optimum_pow extension. + bool powOfTwo(int num); + + //! Checks to determine if the parameter component are power of 2 numbers. + //! From GLM_GTX_optimum_pow extension. + detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x); + + //! Checks to determine if the parameter component are power of 2 numbers. + //! From GLM_GTX_optimum_pow extension. + detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x); + + //! Checks to determine if the parameter component are power of 2 numbers. + //! From GLM_GTX_optimum_pow extension. + detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x); + + /// @} +}//namespace gtx +}//namespace glm + +#include "optimum_pow.inl" + +#endif//GLM_GTX_optimum_pow diff --git a/include/gal/opengl/glm/gtx/optimum_pow.inl b/include/gal/opengl/glm/gtx/optimum_pow.inl new file mode 100644 index 0000000..1e6f226 --- /dev/null +++ b/include/gal/opengl/glm/gtx/optimum_pow.inl @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-27 +// Licence : This source is under MIT License +// File : glm/gtx/optimum_pow.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER genType pow2(const genType& x) + { + return x * x; + } + + template <typename genType> + GLM_FUNC_QUALIFIER genType pow3(const genType& x) + { + return x * x * x; + } + + template <typename genType> + GLM_FUNC_QUALIFIER genType pow4(const genType& x) + { + return x * x * x * x; + } + + GLM_FUNC_QUALIFIER bool powOfTwo(int x) + { + return !(x & (x - 1)); + } + + GLM_FUNC_QUALIFIER detail::tvec2<bool> powOfTwo(const detail::tvec2<int>& x) + { + return detail::tvec2<bool>( + powOfTwo(x.x), + powOfTwo(x.y)); + } + + GLM_FUNC_QUALIFIER detail::tvec3<bool> powOfTwo(const detail::tvec3<int>& x) + { + return detail::tvec3<bool>( + powOfTwo(x.x), + powOfTwo(x.y), + powOfTwo(x.z)); + } + + GLM_FUNC_QUALIFIER detail::tvec4<bool> powOfTwo(const detail::tvec4<int>& x) + { + return detail::tvec4<bool>( + powOfTwo(x.x), + powOfTwo(x.y), + powOfTwo(x.z), + powOfTwo(x.w)); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/orthonormalize.hpp b/include/gal/opengl/glm/gtx/orthonormalize.hpp new file mode 100644 index 0000000..9f97f66 --- /dev/null +++ b/include/gal/opengl/glm/gtx/orthonormalize.hpp @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_orthonormalize +/// @file glm/gtx/orthonormalize.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_orthonormalize GLM_GTX_orthonormalize +/// @ingroup gtx +/// +/// @brief Orthonormalize matrices. +/// +/// <glm/gtx/orthonormalize.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_orthonormalize +#define GLM_GTX_orthonormalize GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_orthonormalize extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_orthonormalize + /// @{ + + //! Returns the orthonormalized matrix of m. + //! From GLM_GTX_orthonormalize extension. + template <typename T> + detail::tmat3x3<T> orthonormalize( + const detail::tmat3x3<T>& m); + + //! Orthonormalizes x according y. + //! From GLM_GTX_orthonormalize extension. + template <typename T> + detail::tvec3<T> orthonormalize( + const detail::tvec3<T>& x, + const detail::tvec3<T>& y); + + /// @} +}//namespace glm + +#include "orthonormalize.inl" + +#endif//GLM_GTX_orthonormalize diff --git a/include/gal/opengl/glm/gtx/orthonormalize.inl b/include/gal/opengl/glm/gtx/orthonormalize.inl new file mode 100644 index 0000000..ea9ff7f --- /dev/null +++ b/include/gal/opengl/glm/gtx/orthonormalize.inl @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2005-12-21 +// Licence : This source is under MIT License +// File : glm/gtx/orthonormalize.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> orthonormalize + ( + const detail::tmat3x3<T>& m + ) + { + detail::tmat3x3<T> r = m; + + r[0] = normalize(r[0]); + + float d0 = dot(r[0], r[1]); + r[1] -= r[0] * d0; + r[1] = normalize(r[1]); + + float d1 = dot(r[1], r[2]); + d0 = dot(r[0], r[2]); + r[2] -= r[0] * d0 + r[1] * d1; + r[2] = normalize(r[2]); + + return r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> orthonormalize + ( + const detail::tvec3<T>& x, + const detail::tvec3<T>& y + ) + { + return normalize(x - y * dot(y, x)); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/perpendicular.hpp b/include/gal/opengl/glm/gtx/perpendicular.hpp new file mode 100644 index 0000000..f6515ab --- /dev/null +++ b/include/gal/opengl/glm/gtx/perpendicular.hpp @@ -0,0 +1,67 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_perpendicular +/// @file glm/gtx/perpendicular.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_projection (dependence) +/// +/// @defgroup gtx_perpendicular GLM_GTX_perpendicular +/// @ingroup gtx +/// +/// @brief Perpendicular of a vector from other one +/// +/// <glm/gtx/perpendicular.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_perpendicular +#define GLM_GTX_perpendicular GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/projection.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_perpendicular extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_perpendicular + /// @{ + + //! Projects x a perpendicular axis of Normal. + //! From GLM_GTX_perpendicular extension. + template <typename vecType> + vecType perp( + vecType const & x, + vecType const & Normal); + + /// @} +}//namespace glm + +#include "perpendicular.inl" + +#endif//GLM_GTX_perpendicular diff --git a/include/gal/opengl/glm/gtx/perpendicular.inl b/include/gal/opengl/glm/gtx/perpendicular.inl new file mode 100644 index 0000000..c96812a --- /dev/null +++ b/include/gal/opengl/glm/gtx/perpendicular.inl @@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2009-03-06 +// Licence : This source is under MIT License +// File : glm/gtx/perpendicular.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename vecType> + GLM_FUNC_QUALIFIER vecType perp + ( + vecType const & x, + vecType const & Normal + ) + { + return x - proj(x, Normal); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/polar_coordinates.hpp b/include/gal/opengl/glm/gtx/polar_coordinates.hpp new file mode 100644 index 0000000..1cba486 --- /dev/null +++ b/include/gal/opengl/glm/gtx/polar_coordinates.hpp @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_polar_coordinates +/// @file glm/gtx/polar_coordinates.hpp +/// @date 2007-03-06 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates +/// @ingroup gtx +/// +/// @brief Conversion from Euclidean space to polar space and revert. +/// +/// <glm/gtx/polar_coordinates.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_polar_coordinates +#define GLM_GTX_polar_coordinates GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_polar_coordinates extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_polar_coordinates + /// @{ + + /// Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude. + /// + /// @see gtx_polar_coordinates + template <typename T> + detail::tvec3<T> polar( + detail::tvec3<T> const & euclidean); + + /// Convert Polar to Euclidean coordinates. + /// + /// @see gtx_polar_coordinates + template <typename T> + detail::tvec3<T> euclidean( + detail::tvec2<T> const & polar); + + /// @} +}//namespace glm + +#include "polar_coordinates.inl" + +#endif//GLM_GTX_polar_coordinates diff --git a/include/gal/opengl/glm/gtx/polar_coordinates.inl b/include/gal/opengl/glm/gtx/polar_coordinates.inl new file mode 100644 index 0000000..376a31c --- /dev/null +++ b/include/gal/opengl/glm/gtx/polar_coordinates.inl @@ -0,0 +1,55 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-06 +// Updated : 2009-05-01 +// Licence : This source is under MIT License +// File : glm/gtx/polar_coordinates.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> polar + ( + detail::tvec3<T> const & euclidean + ) + { + T const Length(length(euclidean)); + detail::tvec3<T> const tmp(euclidean / Length); + T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z)); + +#ifdef GLM_FORCE_RADIANS + return detail::tvec3<T>( + atan(xz_dist, tmp.y), // latitude + atan(tmp.x, tmp.z), // longitude + xz_dist); // xz distance +#else + return detail::tvec3<T>( + degrees(atan(xz_dist, tmp.y)), // latitude + degrees(atan(tmp.x, tmp.z)), // longitude + xz_dist); // xz distance +#endif + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> euclidean + ( + detail::tvec2<T> const & polar + ) + { +#ifdef GLM_FORCE_RADIANS + T const latitude(polar.x); + T const longitude(polar.y); +#else + T const latitude(radians(polar.x)); + T const longitude(radians(polar.y)); +#endif + + return detail::tvec3<T>( + cos(latitude) * sin(longitude), + sin(latitude), + cos(latitude) * cos(longitude)); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/projection.hpp b/include/gal/opengl/glm/gtx/projection.hpp new file mode 100644 index 0000000..6e20922 --- /dev/null +++ b/include/gal/opengl/glm/gtx/projection.hpp @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_projection +/// @file glm/gtx/projection.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_projection GLM_GTX_projection +/// @ingroup gtx +/// +/// @brief Projection of a vector to other one +/// +/// <glm/gtx/projection.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_projection +#define GLM_GTX_projection GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_projection extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_projection + /// @{ + + //! Projects x on Normal. + //! From GLM_GTX_projection extension. + template <typename vecType> + vecType proj( + vecType const & x, + vecType const & Normal); + + /// @} +}//namespace glm + +#include "projection.inl" + +#endif//GLM_GTX_projection diff --git a/include/gal/opengl/glm/gtx/projection.inl b/include/gal/opengl/glm/gtx/projection.inl new file mode 100644 index 0000000..4107d89 --- /dev/null +++ b/include/gal/opengl/glm/gtx/projection.inl @@ -0,0 +1,21 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2009-03-06 +// Licence : This source is under MIT License +// File : glm/gtx/projection.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename vecType> + GLM_FUNC_QUALIFIER vecType proj + ( + vecType const & x, + vecType const & Normal + ) + { + return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/quaternion.hpp b/include/gal/opengl/glm/gtx/quaternion.hpp new file mode 100644 index 0000000..3c9e8b0 --- /dev/null +++ b/include/gal/opengl/glm/gtx/quaternion.hpp @@ -0,0 +1,195 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_quaternion +/// @file glm/gtx/quaternion.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_quaternion GLM_GTX_quaternion +/// @ingroup gtx +/// +/// @brief Extented quaternion types and functions +/// +/// <glm/gtx/quaternion.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_quaternion +#define GLM_GTX_quaternion GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/quaternion.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_quaternion extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_quaternion + /// @{ + + //! Compute a cross product between a quaternion and a vector. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tvec3<valType> cross( + detail::tquat<valType> const & q, + detail::tvec3<valType> const & v); + + //! Compute a cross product between a vector and a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tvec3<valType> cross( + detail::tvec3<valType> const & v, + detail::tquat<valType> const & q); + + //! Compute a point on a path according squad equation. + //! q1 and q2 are control points; s1 and s2 are intermediate control points. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> squad( + detail::tquat<valType> const & q1, + detail::tquat<valType> const & q2, + detail::tquat<valType> const & s1, + detail::tquat<valType> const & s2, + valType const & h); + + //! Returns an intermediate control point for squad interpolation. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> intermediate( + detail::tquat<valType> const & prev, + detail::tquat<valType> const & curr, + detail::tquat<valType> const & next); + + //! Returns a exp of a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> exp( + detail::tquat<valType> const & q); + + //! Returns a log of a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> log( + detail::tquat<valType> const & q); + + /// Returns x raised to the y power. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> pow( + detail::tquat<valType> const & x, + valType const & y); + + //! Returns quarternion square root. + /// + /// @see gtx_quaternion + //template <typename valType> + //detail::tquat<valType> sqrt( + // detail::tquat<valType> const & q); + + //! Rotates a 3 components vector by a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tvec3<valType> rotate( + detail::tquat<valType> const & q, + detail::tvec3<valType> const & v); + + /// Rotates a 4 components vector by a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tvec4<valType> rotate( + detail::tquat<valType> const & q, + detail::tvec4<valType> const & v); + + /// Extract the real component of a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + valType extractRealComponent( + detail::tquat<valType> const & q); + + /// Converts a quaternion to a 3 * 3 matrix. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tmat3x3<valType> toMat3( + detail::tquat<valType> const & x){return mat3_cast(x);} + + /// Converts a quaternion to a 4 * 4 matrix. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tmat4x4<valType> toMat4( + detail::tquat<valType> const & x){return mat4_cast(x);} + + /// Converts a 3 * 3 matrix to a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> toQuat( + detail::tmat3x3<valType> const & x){return quat_cast(x);} + + /// Converts a 4 * 4 matrix to a quaternion. + /// + /// @see gtx_quaternion + template <typename valType> + detail::tquat<valType> toQuat( + detail::tmat4x4<valType> const & x){return quat_cast(x);} + + /// Quaternion interpolation using the rotation short path. + /// + /// @see gtx_quaternion + template <typename T> + detail::tquat<T> shortMix( + detail::tquat<T> const & x, + detail::tquat<T> const & y, + T const & a); + + /// Quaternion normalized linear interpolation. + /// + /// @see gtx_quaternion + template <typename T> + detail::tquat<T> fastMix( + detail::tquat<T> const & x, + detail::tquat<T> const & y, + T const & a); + + /// @} +}//namespace glm + +#include "quaternion.inl" + +#endif//GLM_GTX_quaternion diff --git a/include/gal/opengl/glm/gtx/quaternion.inl b/include/gal/opengl/glm/gtx/quaternion.inl new file mode 100644 index 0000000..32155ce --- /dev/null +++ b/include/gal/opengl/glm/gtx/quaternion.inl @@ -0,0 +1,208 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2008-11-27 +// Licence : This source is under MIT License +// File : glm/gtx/quaternion.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include <limits> + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> cross + ( + detail::tvec3<valType> const & v, + detail::tquat<valType> const & q + ) + { + return inverse(q) * v; + } + + template <typename valType> + GLM_FUNC_QUALIFIER detail::tvec3<valType> cross + ( + detail::tquat<valType> const & q, + detail::tvec3<valType> const & v + ) + { + return q * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> squad + ( + detail::tquat<T> const & q1, + detail::tquat<T> const & q2, + detail::tquat<T> const & s1, + detail::tquat<T> const & s2, + T const & h) + { + return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * (T(1) - h) * h); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> intermediate + ( + detail::tquat<T> const & prev, + detail::tquat<T> const & curr, + detail::tquat<T> const & next + ) + { + detail::tquat<T> invQuat = inverse(curr); + return exp((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> exp + ( + detail::tquat<T> const & q + ) + { + detail::tvec3<T> u(q.x, q.y, q.z); + float Angle = glm::length(u); + detail::tvec3<T> v(u / Angle); + return detail::tquat<T>(cos(Angle), sin(Angle) * v); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> log + ( + detail::tquat<T> const & q + ) + { + if((q.x == T(0)) && (q.y == T(0)) && (q.z == T(0))) + { + if(q.w > T(0)) + return detail::tquat<T>(log(q.w), T(0), T(0), T(0)); + else if(q.w < T(0)) + return detail::tquat<T>(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0)); + else + return detail::tquat<T>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity()); + } + else + { + T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z); + T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w); + T t = atan(Vec3Len, T(q.w)) / Vec3Len; + return detail::tquat<T>(t * q.x, t * q.y, t * q.z, log(QuatLen)); + } + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> pow + ( + detail::tquat<T> const & x, + T const & y + ) + { + if(abs(x.w) > T(0.9999)) + return x; + float Angle = acos(y); + float NewAngle = Angle * y; + float Div = sin(NewAngle) / sin(Angle); + return detail::tquat<T>( + cos(NewAngle), + x.x * Div, + x.y * Div, + x.z * Div); + } + + //template <typename T> + //GLM_FUNC_QUALIFIER detail::tquat<T> sqrt + //( + // detail::tquat<T> const & q + //) + //{ + // T q0 = T(1) - dot(q, q); + // return T(2) * (T(1) + q0) * q; + //} + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rotate + ( + detail::tquat<T> const & q, + detail::tvec3<T> const & v + ) + { + return q * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> rotate + ( + detail::tquat<T> const & q, + detail::tvec4<T> const & v + ) + { + return q * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER T extractRealComponent + ( + detail::tquat<T> const & q + ) + { + T w = T(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; + if(w < T(0)) + return T(0); + else + return -sqrt(w); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> shortMix + ( + detail::tquat<T> const & x, + detail::tquat<T> const & y, + T const & a + ) + { + if(a <= typename detail::tquat<T>::value_type(0)) return x; + if(a >= typename detail::tquat<T>::value_type(1)) return y; + + T fCos = dot(x, y); + detail::tquat<T> y2(y); //BUG!!! tquat<T> y2; + if(fCos < T(0)) + { + y2 = -y; + fCos = -fCos; + } + + //if(fCos > 1.0f) // problem + T k0, k1; + if(fCos > T(0.9999)) + { + k0 = T(1) - a; + k1 = T(0) + a; //BUG!!! 1.0f + a; + } + else + { + T fSin = sqrt(T(1) - fCos * fCos); + T fAngle = atan(fSin, fCos); + T fOneOverSin = T(1) / fSin; + k0 = sin((T(1) - a) * fAngle) * fOneOverSin; + k1 = sin((T(0) + a) * fAngle) * fOneOverSin; + } + + return detail::tquat<T>( + k0 * x.w + k1 * y2.w, + k0 * x.x + k1 * y2.x, + k0 * x.y + k1 * y2.y, + k0 * x.z + k1 * y2.z); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tquat<T> fastMix + ( + detail::tquat<T> const & x, + detail::tquat<T> const & y, + T const & a + ) + { + return glm::normalize(x * (T(1) - a) + (y * a)); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/random.hpp b/include/gal/opengl/glm/gtx/random.hpp new file mode 100644 index 0000000..a23d894 --- /dev/null +++ b/include/gal/opengl/glm/gtx/random.hpp @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_random extension is deprecated, include GLM_GTC_random instead") +#endif + +// Promoted: +#include "../gtc/random.hpp" diff --git a/include/gal/opengl/glm/gtx/raw_data.hpp b/include/gal/opengl/glm/gtx/raw_data.hpp new file mode 100644 index 0000000..4ec6cf0 --- /dev/null +++ b/include/gal/opengl/glm/gtx/raw_data.hpp @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_raw_data +/// @file glm/gtx/raw_data.hpp +/// @date 2008-11-19 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_raw_data GLM_GTX_raw_data +/// @ingroup gtx +/// +/// @brief Projection of a vector to other one +/// +/// <glm/gtx/raw_data.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_raw_data +#define GLM_GTX_raw_data GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/type_precision.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_raw_data extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_raw_data + /// @{ + + //! Type for byte numbers. + //! From GLM_GTX_raw_data extension. + typedef uint8 byte; + + //! Type for word numbers. + //! From GLM_GTX_raw_data extension. + typedef uint16 word; + + //! Type for dword numbers. + //! From GLM_GTX_raw_data extension. + typedef uint32 dword; + + //! Type for qword numbers. + //! From GLM_GTX_raw_data extension. + typedef uint64 qword; + + /// @} +}// namespace glm + +#include "raw_data.inl" + +#endif//GLM_GTX_raw_data diff --git a/include/gal/opengl/glm/gtx/raw_data.inl b/include/gal/opengl/glm/gtx/raw_data.inl new file mode 100644 index 0000000..526e3cd --- /dev/null +++ b/include/gal/opengl/glm/gtx/raw_data.inl @@ -0,0 +1,11 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-11-19 +// Updated : 2008-11-19 +// Licence : This source is under MIT License +// File : glm/gtx/raw_data.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/gal/opengl/glm/gtx/reciprocal.hpp b/include/gal/opengl/glm/gtx/reciprocal.hpp new file mode 100644 index 0000000..3519861 --- /dev/null +++ b/include/gal/opengl/glm/gtx/reciprocal.hpp @@ -0,0 +1,26 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_reciprocal extension is deprecated, include GLM_GTC_reciprocal instead") +#endif diff --git a/include/gal/opengl/glm/gtx/rotate_vector.hpp b/include/gal/opengl/glm/gtx/rotate_vector.hpp new file mode 100644 index 0000000..70c5e03 --- /dev/null +++ b/include/gal/opengl/glm/gtx/rotate_vector.hpp @@ -0,0 +1,132 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_rotate_vector +/// @file glm/gtx/rotate_vector.hpp +/// @date 2006-11-02 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_transform (dependence) +/// +/// @defgroup gtx_rotate_vector GLM_GTX_rotate_vector +/// @ingroup gtx +/// +/// @brief Function to directly rotate a vector +/// +/// <glm/gtx/rotate_vector.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_rotate_vector +#define GLM_GTX_rotate_vector GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/transform.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_rotate_vector extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_rotate_vector + /// @{ + + //! Rotate a two dimensional vector. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec2<T> rotate( + detail::tvec2<T> const & v, + T const & angle); + + //! Rotate a three dimensional vector around an axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec3<T> rotate( + detail::tvec3<T> const & v, + T const & angle, + detail::tvec3<T> const & normal); + + //! Rotate a four dimensional vector around an axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec4<T> rotate( + detail::tvec4<T> const & v, + T const & angle, + detail::tvec3<T> const & normal); + + //! Rotate a three dimensional vector around the X axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec3<T> rotateX( + detail::tvec3<T> const & v, + T const & angle); + + //! Rotate a three dimensional vector around the Y axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec3<T> rotateY( + detail::tvec3<T> const & v, + T const & angle); + + //! Rotate a three dimensional vector around the Z axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec3<T> rotateZ( + detail::tvec3<T> const & v, + T const & angle); + + //! Rotate a four dimentionnals vector around the X axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec4<T> rotateX( + detail::tvec4<T> const & v, + T const & angle); + + //! Rotate a four dimensional vector around the X axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec4<T> rotateY( + detail::tvec4<T> const & v, + T const & angle); + + //! Rotate a four dimensional vector around the X axis. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tvec4<T> rotateZ( + detail::tvec4<T> const & v, + T const & angle); + + //! Build a rotation matrix from a normal and a up vector. + //! From GLM_GTX_rotate_vector extension. + template <typename T> + detail::tmat4x4<T> orientation( + detail::tvec3<T> const & Normal, + detail::tvec3<T> const & Up); + + /// @} +}//namespace glm + +#include "rotate_vector.inl" + +#endif//GLM_GTX_rotate_vector diff --git a/include/gal/opengl/glm/gtx/rotate_vector.inl b/include/gal/opengl/glm/gtx/rotate_vector.inl new file mode 100644 index 0000000..1ec1717 --- /dev/null +++ b/include/gal/opengl/glm/gtx/rotate_vector.inl @@ -0,0 +1,215 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-11-02 +// Updated : 2009-02-19 +// Licence : This source is under MIT License +// File : glm/gtx/rotate_vector.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> rotate + ( + detail::tvec2<T> const & v, + T const & angle + ) + { + detail::tvec2<T> Result; +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos = cos(radians(angle)); + T const Sin = sin(radians(angle)); +#endif + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rotate + ( + detail::tvec3<T> const & v, + T const & angle, + detail::tvec3<T> const & normal + ) + { + return detail::tmat3x3<T>(glm::rotate(angle, normal)) * v; + } + /* + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rotateGTX( + const detail::tvec3<T>& x, + T angle, + const detail::tvec3<T>& normal) + { + const T Cos = cos(radians(angle)); + const T Sin = sin(radians(angle)); + return x * Cos + ((x * normal) * (T(1) - Cos)) * normal + cross(x, normal) * Sin; + } + */ + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> rotate + ( + detail::tvec4<T> const & v, + T const & angle, + detail::tvec3<T> const & normal + ) + { + return rotate(angle, normal) * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rotateX + ( + detail::tvec3<T> const & v, + T const & angle + ) + { + detail::tvec3<T> Result(v); + +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos = cos(radians(angle)); + T const Sin = sin(radians(angle)); +#endif + + Result.y = v.y * Cos - v.z * Sin; + Result.z = v.y * Sin + v.z * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rotateY + ( + detail::tvec3<T> const & v, + T const & angle + ) + { + detail::tvec3<T> Result = v; + +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos(cos(radians(angle))); + T const Sin(sin(radians(angle))); +#endif + + Result.x = v.x * Cos + v.z * Sin; + Result.z = -v.x * Sin + v.z * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> rotateZ + ( + detail::tvec3<T> const & v, + T const & angle + ) + { + detail::tvec3<T> Result = v; + +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos(cos(radians(angle))); + T const Sin(sin(radians(angle))); +#endif + + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> rotateX + ( + detail::tvec4<T> const & v, + T const & angle + ) + { + detail::tvec4<T> Result = v; + +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos(cos(radians(angle))); + T const Sin(sin(radians(angle))); +#endif + + Result.y = v.y * Cos - v.z * Sin; + Result.z = v.y * Sin + v.z * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> rotateY + ( + detail::tvec4<T> const & v, + T const & angle + ) + { + detail::tvec4<T> Result = v; + +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos(cos(radians(angle))); + T const Sin(sin(radians(angle))); +#endif + + Result.x = v.x * Cos + v.z * Sin; + Result.z = -v.x * Sin + v.z * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> rotateZ + ( + detail::tvec4<T> const & v, + T const & angle + ) + { + detail::tvec4<T> Result = v; + +#ifdef GLM_FORCE_RADIANS + T const Cos(cos(angle)); + T const Sin(sin(angle)); +#else + T const Cos(cos(radians(angle))); + T const Sin(sin(radians(angle))); +#endif + + Result.x = v.x * Cos - v.y * Sin; + Result.y = v.x * Sin + v.y * Cos; + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> orientation + ( + detail::tvec3<T> const & Normal, + detail::tvec3<T> const & Up + ) + { + if(all(equal(Normal, Up))) + return detail::tmat4x4<T>(T(1)); + + detail::tvec3<T> RotationAxis = cross(Up, Normal); +# ifdef GLM_FORCE_RADIANS + T Angle = acos(dot(Normal, Up)); +# else + T Angle = degrees(acos(dot(Normal, Up))); +# endif + return rotate(Angle, RotationAxis); + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/simd_mat4.hpp b/include/gal/opengl/glm/gtx/simd_mat4.hpp new file mode 100644 index 0000000..b435b11 --- /dev/null +++ b/include/gal/opengl/glm/gtx/simd_mat4.hpp @@ -0,0 +1,206 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_simd_vec4 +/// @file glm/gtx/simd_vec4.hpp +/// @date 2009-05-07 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_simd_mat4 GLM_GTX_simd_mat4 +/// @ingroup gtx +/// +/// @brief SIMD implementation of mat4 type. +/// +/// <glm/gtx/simd_mat4.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_simd_mat4 +#define GLM_GTX_simd_mat4 GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(GLM_ARCH != GLM_ARCH_PURE) + +#if(GLM_ARCH & GLM_ARCH_SSE2) +# include "../core/intrinsic_matrix.hpp" +# include "../gtx/simd_vec4.hpp" +#else +# error "GLM: GLM_GTX_simd_mat4 requires compiler support of SSE2 through intrinsics" +#endif + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_simd_mat4 extension included") +#endif + +namespace glm{ +namespace detail +{ + /// 4x4 Matrix implemented using SIMD SEE intrinsics. + /// \ingroup gtx_simd_mat4 + GLM_ALIGNED_STRUCT(16) fmat4x4SIMD + { + enum ctor{null}; + + typedef float value_type; + typedef fvec4SIMD col_type; + typedef fvec4SIMD row_type; + typedef std::size_t size_type; + static size_type value_size(); + static size_type col_size(); + static size_type row_size(); + static bool is_matrix(); + + fvec4SIMD Data[4]; + + ////////////////////////////////////// + // Constructors + + fmat4x4SIMD(); + explicit fmat4x4SIMD(float const & s); + explicit fmat4x4SIMD( + float const & x0, float const & y0, float const & z0, float const & w0, + float const & x1, float const & y1, float const & z1, float const & w1, + float const & x2, float const & y2, float const & z2, float const & w2, + float const & x3, float const & y3, float const & z3, float const & w3); + explicit fmat4x4SIMD( + fvec4SIMD const & v0, + fvec4SIMD const & v1, + fvec4SIMD const & v2, + fvec4SIMD const & v3); + explicit fmat4x4SIMD( + tmat4x4<float> const & m); + explicit fmat4x4SIMD( + __m128 const in[4]); + + // Conversions + //template <typename U> + //explicit tmat4x4(tmat4x4<U> const & m); + + //explicit tmat4x4(tmat2x2<T> const & x); + //explicit tmat4x4(tmat3x3<T> const & x); + //explicit tmat4x4(tmat2x3<T> const & x); + //explicit tmat4x4(tmat3x2<T> const & x); + //explicit tmat4x4(tmat2x4<T> const & x); + //explicit tmat4x4(tmat4x2<T> const & x); + //explicit tmat4x4(tmat3x4<T> const & x); + //explicit tmat4x4(tmat4x3<T> const & x); + + // Accesses + fvec4SIMD & operator[](size_type i); + fvec4SIMD const & operator[](size_type i) const; + + // Unary updatable operators + fmat4x4SIMD & operator= (fmat4x4SIMD const & m); + fmat4x4SIMD & operator+= (float const & s); + fmat4x4SIMD & operator+= (fmat4x4SIMD const & m); + fmat4x4SIMD & operator-= (float const & s); + fmat4x4SIMD & operator-= (fmat4x4SIMD const & m); + fmat4x4SIMD & operator*= (float const & s); + fmat4x4SIMD & operator*= (fmat4x4SIMD const & m); + fmat4x4SIMD & operator/= (float const & s); + fmat4x4SIMD & operator/= (fmat4x4SIMD const & m); + fmat4x4SIMD & operator++ (); + fmat4x4SIMD & operator-- (); + }; + + // Binary operators + fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s); + fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m); + fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2); + + fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s); + fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m); + fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2); + + fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s); + fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m); + + fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v); + fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m); + + fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2); + + fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s); + fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m); + + fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v); + fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m); + + fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2); + + // Unary constant operators + fmat4x4SIMD const operator- (fmat4x4SIMD const & m); + fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int); + fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int); +}//namespace detail + + typedef detail::fmat4x4SIMD simdMat4; + + /// @addtogroup gtx_simd_mat4 + /// @{ + + //! Convert a simdMat4 to a mat4. + //! (From GLM_GTX_simd_mat4 extension) + detail::tmat4x4<float> mat4_cast( + detail::fmat4x4SIMD const & x); + + //! Multiply matrix x by matrix y component-wise, i.e., + //! result[i][j] is the scalar product of x[i][j] and y[i][j]. + //! (From GLM_GTX_simd_mat4 extension). + detail::fmat4x4SIMD matrixCompMult( + detail::fmat4x4SIMD const & x, + detail::fmat4x4SIMD const & y); + + //! Treats the first parameter c as a column vector + //! and the second parameter r as a row vector + //! and does a linear algebraic matrix multiply c * r. + //! (From GLM_GTX_simd_mat4 extension). + detail::fmat4x4SIMD outerProduct( + detail::fvec4SIMD const & c, + detail::fvec4SIMD const & r); + + //! Returns the transposed matrix of x + //! (From GLM_GTX_simd_mat4 extension). + detail::fmat4x4SIMD transpose( + detail::fmat4x4SIMD const & x); + + //! Return the determinant of a mat4 matrix. + //! (From GLM_GTX_simd_mat4 extension). + float determinant( + detail::fmat4x4SIMD const & m); + + //! Return the inverse of a mat4 matrix. + //! (From GLM_GTX_simd_mat4 extension). + detail::fmat4x4SIMD inverse( + detail::fmat4x4SIMD const & m); + + /// @} +}// namespace glm + +#include "simd_mat4.inl" + +#endif//(GLM_ARCH != GLM_ARCH_PURE) + +#endif//GLM_GTX_simd_mat4 diff --git a/include/gal/opengl/glm/gtx/simd_mat4.inl b/include/gal/opengl/glm/gtx/simd_mat4.inl new file mode 100644 index 0000000..d6ec8ca --- /dev/null +++ b/include/gal/opengl/glm/gtx/simd_mat4.inl @@ -0,0 +1,590 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-05-19 +// Updated : 2009-05-19 +// Licence : This source is under MIT License +// File : glm/gtx/simd_mat4.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ +namespace detail{ + +GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::value_size() +{ + return sizeof(value_type); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::col_size() +{ + return 4; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::row_size() +{ + return 4; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD() +{ +#ifndef GLM_SIMD_ENABLE_DEFAULT_INIT + this->Data[0] = fvec4SIMD(1.0f, 0, 0, 0); + this->Data[1] = fvec4SIMD(0, 1.0f, 0, 0); + this->Data[2] = fvec4SIMD(0, 0, 1.0f, 0); + this->Data[3] = fvec4SIMD(0, 0, 0, 1.0f); +#endif +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD(float const & s) +{ + this->Data[0] = fvec4SIMD(s, 0, 0, 0); + this->Data[1] = fvec4SIMD(0, s, 0, 0); + this->Data[2] = fvec4SIMD(0, 0, s, 0); + this->Data[3] = fvec4SIMD(0, 0, 0, s); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + float const & x0, float const & y0, float const & z0, float const & w0, + float const & x1, float const & y1, float const & z1, float const & w1, + float const & x2, float const & y2, float const & z2, float const & w2, + float const & x3, float const & y3, float const & z3, float const & w3 +) +{ + this->Data[0] = fvec4SIMD(x0, y0, z0, w0); + this->Data[1] = fvec4SIMD(x1, y1, z1, w1); + this->Data[2] = fvec4SIMD(x2, y2, z2, w2); + this->Data[3] = fvec4SIMD(x3, y3, z3, w3); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + fvec4SIMD const & v0, + fvec4SIMD const & v1, + fvec4SIMD const & v2, + fvec4SIMD const & v3 +) +{ + this->Data[0] = v0; + this->Data[1] = v1; + this->Data[2] = v2; + this->Data[3] = v3; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + tmat4x4<float> const & m +) +{ + this->Data[0] = fvec4SIMD(m[0]); + this->Data[1] = fvec4SIMD(m[1]); + this->Data[2] = fvec4SIMD(m[2]); + this->Data[3] = fvec4SIMD(m[3]); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD +( + __m128 const in[4] +) +{ + this->Data[0] = in[0]; + this->Data[1] = in[1]; + this->Data[2] = in[2]; + this->Data[3] = in[3]; +} + +////////////////////////////////////// +// Accesses + +GLM_FUNC_QUALIFIER fvec4SIMD & fmat4x4SIMD::operator[] +( + fmat4x4SIMD::size_type i +) +{ + assert( + //i >= fmat4x4SIMD::size_type(0) && + i < fmat4x4SIMD::col_size()); + + return this->Data[i]; +} + +GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[] +( + fmat4x4SIMD::size_type i +) const +{ + assert( + //i >= fmat4x4SIMD::size_type(0) && + i < fmat4x4SIMD::col_size()); + + return this->Data[i]; +} + +////////////////////////////////////////////////////////////// +// mat4 operators + +GLM_FUNC_QUALIFIER fmat4x4SIMD& fmat4x4SIMD::operator= +( + fmat4x4SIMD const & m +) +{ + this->Data[0] = m[0]; + this->Data[1] = m[1]; + this->Data[2] = m[2]; + this->Data[3] = m[3]; + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+= +( + fmat4x4SIMD const & m +) +{ + this->Data[0].Data = _mm_add_ps(this->Data[0].Data, m[0].Data); + this->Data[1].Data = _mm_add_ps(this->Data[1].Data, m[1].Data); + this->Data[2].Data = _mm_add_ps(this->Data[2].Data, m[2].Data); + this->Data[3].Data = _mm_add_ps(this->Data[3].Data, m[3].Data); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-= +( + fmat4x4SIMD const & m +) +{ + this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, m[0].Data); + this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, m[1].Data); + this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, m[2].Data); + this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, m[3].Data); + + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator*= +( + fmat4x4SIMD const & m +) +{ + sse_mul_ps(&this->Data[0].Data, &m.Data[0].Data, &this->Data[0].Data); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator/= +( + fmat4x4SIMD const & m +) +{ + __m128 Inv[4]; + sse_inverse_ps(&m.Data[0].Data, Inv); + sse_mul_ps(&this->Data[0].Data, Inv, &this->Data[0].Data); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator+= +( + float const & s +) +{ + __m128 Operand = _mm_set_ps1(s); + this->Data[0].Data = _mm_add_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_add_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_add_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_add_ps(this->Data[3].Data, Operand); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-= +( + float const & s +) +{ + __m128 Operand = _mm_set_ps1(s); + this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, Operand); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator*= +( + float const & s +) +{ + __m128 Operand = _mm_set_ps1(s); + this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator/= +( + float const & s +) +{ + __m128 Operand = _mm_div_ps(one, _mm_set_ps1(s)); + this->Data[0].Data = _mm_mul_ps(this->Data[0].Data, Operand); + this->Data[1].Data = _mm_mul_ps(this->Data[1].Data, Operand); + this->Data[2].Data = _mm_mul_ps(this->Data[2].Data, Operand); + this->Data[3].Data = _mm_mul_ps(this->Data[3].Data, Operand); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator++ () +{ + this->Data[0].Data = _mm_add_ps(this->Data[0].Data, one); + this->Data[1].Data = _mm_add_ps(this->Data[1].Data, one); + this->Data[2].Data = _mm_add_ps(this->Data[2].Data, one); + this->Data[3].Data = _mm_add_ps(this->Data[3].Data, one); + return *this; +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-- () +{ + this->Data[0].Data = _mm_sub_ps(this->Data[0].Data, one); + this->Data[1].Data = _mm_sub_ps(this->Data[1].Data, one); + this->Data[2].Data = _mm_sub_ps(this->Data[2].Data, one); + this->Data[3].Data = _mm_sub_ps(this->Data[3].Data, one); + return *this; +} + + +////////////////////////////////////////////////////////////// +// Binary operators + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator+ +( + const fmat4x4SIMD &m, + float const & s +) +{ + return detail::fmat4x4SIMD + ( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator+ +( + float const & s, + const fmat4x4SIMD &m +) +{ + return detail::fmat4x4SIMD + ( + m[0] + s, + m[1] + s, + m[2] + s, + m[3] + s + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator+ +( + const fmat4x4SIMD &m1, + const fmat4x4SIMD &m2 +) +{ + return detail::fmat4x4SIMD + ( + m1[0] + m2[0], + m1[1] + m2[1], + m1[2] + m2[2], + m1[3] + m2[3] + ); +} + + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator- +( + const fmat4x4SIMD &m, + float const & s +) +{ + return detail::fmat4x4SIMD + ( + m[0] - s, + m[1] - s, + m[2] - s, + m[3] - s + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator- +( + float const & s, + const fmat4x4SIMD &m +) +{ + return detail::fmat4x4SIMD + ( + s - m[0], + s - m[1], + s - m[2], + s - m[3] + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator- +( + const fmat4x4SIMD &m1, + const fmat4x4SIMD &m2 +) +{ + return detail::fmat4x4SIMD + ( + m1[0] - m2[0], + m1[1] - m2[1], + m1[2] - m2[2], + m1[3] - m2[3] + ); +} + + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator* +( + const fmat4x4SIMD &m, + float const & s +) +{ + return detail::fmat4x4SIMD + ( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator* +( + float const & s, + const fmat4x4SIMD &m +) +{ + return detail::fmat4x4SIMD + ( + m[0] * s, + m[1] * s, + m[2] * s, + m[3] * s + ); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator* +( + const fmat4x4SIMD &m, + fvec4SIMD const & v +) +{ + return sse_mul_ps(&m.Data[0].Data, v.Data); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator* +( + fvec4SIMD const & v, + const fmat4x4SIMD &m +) +{ + return sse_mul_ps(v.Data, &m.Data[0].Data); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator* +( + const fmat4x4SIMD &m1, + const fmat4x4SIMD &m2 +) +{ + fmat4x4SIMD result; + sse_mul_ps(&m1.Data[0].Data, &m2.Data[0].Data, &result.Data[0].Data); + + return result; +} + + + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator/ +( + const fmat4x4SIMD &m, + float const & s +) +{ + return detail::fmat4x4SIMD + ( + m[0] / s, + m[1] / s, + m[2] / s, + m[3] / s + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator/ +( + float const & s, + const fmat4x4SIMD &m +) +{ + return detail::fmat4x4SIMD + ( + s / m[0], + s / m[1], + s / m[2], + s / m[3] + ); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator/ +( + const fmat4x4SIMD &m, + fvec4SIMD const & v +) +{ + return inverse(m) * v; +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator/ +( + fvec4SIMD const & v, + const fmat4x4SIMD &m +) +{ + return v * inverse(m); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD operator/ +( + const fmat4x4SIMD &m1, + const fmat4x4SIMD &m2 +) +{ + __m128 result[4]; + __m128 inv[4]; + + sse_inverse_ps(&m2.Data[0].Data, inv); + sse_mul_ps(&m1.Data[0].Data, inv, result); + + return fmat4x4SIMD(result); +} + + +////////////////////////////////////////////////////////////// +// Unary constant operators +GLM_FUNC_QUALIFIER fmat4x4SIMD const operator- +( + fmat4x4SIMD const & m +) +{ + return detail::fmat4x4SIMD + ( + -m[0], + -m[1], + -m[2], + -m[3] + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD const operator-- +( + fmat4x4SIMD const & m, + int +) +{ + return detail::fmat4x4SIMD + ( + m[0] - 1.0f, + m[1] - 1.0f, + m[2] - 1.0f, + m[3] - 1.0f + ); +} + +GLM_FUNC_QUALIFIER fmat4x4SIMD const operator++ +( + fmat4x4SIMD const & m, + int +) +{ + return detail::fmat4x4SIMD + ( + m[0] + 1.0f, + m[1] + 1.0f, + m[2] + 1.0f, + m[3] + 1.0f + ); +} + +}//namespace detail + +GLM_FUNC_QUALIFIER detail::tmat4x4<float> mat4_cast +( + detail::fmat4x4SIMD const & x +) +{ + GLM_ALIGN(16) detail::tmat4x4<float> Result; + _mm_store_ps(&Result[0][0], x.Data[0].Data); + _mm_store_ps(&Result[1][0], x.Data[1].Data); + _mm_store_ps(&Result[2][0], x.Data[2].Data); + _mm_store_ps(&Result[3][0], x.Data[3].Data); + return Result; +} + +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD matrixCompMult +( + detail::fmat4x4SIMD const & x, + detail::fmat4x4SIMD const & y +) +{ + detail::fmat4x4SIMD result; + result[0] = x[0] * y[0]; + result[1] = x[1] * y[1]; + result[2] = x[2] * y[2]; + result[3] = x[3] * y[3]; + return result; +} + +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD outerProduct +( + detail::fvec4SIMD const & c, + detail::fvec4SIMD const & r +) +{ + __m128 Shu0 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(0, 0, 0, 0)); + __m128 Shu1 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(1, 1, 1, 1)); + __m128 Shu2 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(2, 2, 2, 2)); + __m128 Shu3 = _mm_shuffle_ps(r.Data, r.Data, _MM_SHUFFLE(3, 3, 3, 3)); + + detail::fmat4x4SIMD result(detail::fmat4x4SIMD::null); + result[0].Data = _mm_mul_ps(c.Data, Shu0); + result[1].Data = _mm_mul_ps(c.Data, Shu1); + result[2].Data = _mm_mul_ps(c.Data, Shu2); + result[3].Data = _mm_mul_ps(c.Data, Shu3); + return result; +} + +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD transpose(detail::fmat4x4SIMD const & m) +{ + detail::fmat4x4SIMD result; + detail::sse_transpose_ps(&m[0].Data, &result[0].Data); + return result; +} + +GLM_FUNC_QUALIFIER float determinant(detail::fmat4x4SIMD const & m) +{ + float Result; + _mm_store_ss(&Result, detail::sse_det_ps(&m[0].Data)); + return Result; +} + +GLM_FUNC_QUALIFIER detail::fmat4x4SIMD inverse(detail::fmat4x4SIMD const & m) +{ + detail::fmat4x4SIMD result; + detail::sse_inverse_ps(&m[0].Data, &result[0].Data); + return result; +} + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/simd_vec4.hpp b/include/gal/opengl/glm/gtx/simd_vec4.hpp new file mode 100644 index 0000000..6f60060 --- /dev/null +++ b/include/gal/opengl/glm/gtx/simd_vec4.hpp @@ -0,0 +1,517 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_simd_vec4 +/// @file glm/gtx/simd_vec4.hpp +/// @date 2009-05-07 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_simd_vec4 GLM_GTX_simd_vec4 +/// @ingroup gtx +/// +/// @brief SIMD implementation of vec4 type. +/// +/// <glm/gtx/simd_vec4.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_simd_vec4 +#define GLM_GTX_simd_vec4 GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(GLM_ARCH != GLM_ARCH_PURE) + +#if(GLM_ARCH & GLM_ARCH_SSE2) +# include "../core/intrinsic_common.hpp" +# include "../core/intrinsic_geometric.hpp" +#else +# error "GLM: GLM_GTX_simd_vec4 requires compiler support of SSE2 through intrinsics" +#endif + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_simd_vec4 extension included") +#endif + + +// Warning silencer for nameless struct/union. +#if (GLM_COMPILER & GLM_COMPILER_VC) +# pragma warning(push) +# pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union +#endif + + +namespace glm{ +namespace detail +{ + /// 4-dimensional vector implemented using SIMD SEE intrinsics. + /// \ingroup gtx_simd_vec4 + GLM_ALIGNED_STRUCT(16) fvec4SIMD + { + enum ctor{null}; + typedef __m128 value_type; + typedef std::size_t size_type; + static size_type value_size(); + + typedef fvec4SIMD type; + typedef tvec4<bool> bool_type; + +#ifdef GLM_SIMD_ENABLE_XYZW_UNION + union + { + __m128 Data; + struct {float x, y, z, w;}; + }; +#else + __m128 Data; +#endif + + ////////////////////////////////////// + // Implicit basic constructors + + fvec4SIMD(); + fvec4SIMD(__m128 const & Data); + fvec4SIMD(fvec4SIMD const & v); + + ////////////////////////////////////// + // Explicit basic constructors + + explicit fvec4SIMD( + ctor); + explicit fvec4SIMD( + float const & s); + explicit fvec4SIMD( + float const & x, + float const & y, + float const & z, + float const & w); + explicit fvec4SIMD( + tvec4<float> const & v); + + //////////////////////////////////////// + //// Convertion vector constructors + + fvec4SIMD(vec2 const & v, float const & s1, float const & s2); + fvec4SIMD(float const & s1, vec2 const & v, float const & s2); + fvec4SIMD(float const & s1, float const & s2, vec2 const & v); + fvec4SIMD(vec3 const & v, float const & s); + fvec4SIMD(float const & s, vec3 const & v); + fvec4SIMD(vec2 const & v1, vec2 const & v2); + //fvec4SIMD(ivec4SIMD const & v); + + ////////////////////////////////////// + // Unary arithmetic operators + + fvec4SIMD& operator= (fvec4SIMD const & v); + fvec4SIMD& operator+=(fvec4SIMD const & v); + fvec4SIMD& operator-=(fvec4SIMD const & v); + fvec4SIMD& operator*=(fvec4SIMD const & v); + fvec4SIMD& operator/=(fvec4SIMD const & v); + + fvec4SIMD& operator+=(float const & s); + fvec4SIMD& operator-=(float const & s); + fvec4SIMD& operator*=(float const & s); + fvec4SIMD& operator/=(float const & s); + + fvec4SIMD& operator++(); + fvec4SIMD& operator--(); + + ////////////////////////////////////// + // Swizzle operators + + template <comp X, comp Y, comp Z, comp W> + fvec4SIMD& swizzle(); + template <comp X, comp Y, comp Z, comp W> + fvec4SIMD swizzle() const; + template <comp X, comp Y, comp Z> + fvec4SIMD swizzle() const; + template <comp X, comp Y> + fvec4SIMD swizzle() const; + template <comp X> + fvec4SIMD swizzle() const; + }; +}//namespace detail + + typedef glm::detail::fvec4SIMD simdVec4; + + /// @addtogroup gtx_simd_vec4 + /// @{ + + //! Convert a simdVec4 to a vec4. + //! (From GLM_GTX_simd_vec4 extension) + detail::tvec4<float> vec4_cast( + detail::fvec4SIMD const & x); + + //! Returns x if x >= 0; otherwise, it returns -x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD abs(detail::fvec4SIMD const & x); + + //! Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD sign(detail::fvec4SIMD const & x); + + //! Returns a value equal to the nearest integer that is less then or equal to x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD floor(detail::fvec4SIMD const & x); + + //! Returns a value equal to the nearest integer to x + //! whose absolute value is not larger than the absolute value of x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD trunc(detail::fvec4SIMD const & x); + + //! Returns a value equal to the nearest integer to x. + //! The fraction 0.5 will round in a direction chosen by the + //! implementation, presumably the direction that is fastest. + //! This includes the possibility that round(x) returns the + //! same value as roundEven(x) for all values of x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD round(detail::fvec4SIMD const & x); + + //! Returns a value equal to the nearest integer to x. + //! A fractional part of 0.5 will round toward the nearest even + //! integer. (Both 3.5 and 4.5 for x will return 4.0.) + //! (From GLM_GTX_simd_vec4 extension, common function) + //detail::fvec4SIMD roundEven(detail::fvec4SIMD const & x); + + //! Returns a value equal to the nearest integer + //! that is greater than or equal to x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD ceil(detail::fvec4SIMD const & x); + + //! Return x - floor(x). + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD fract(detail::fvec4SIMD const & x); + + //! Modulus. Returns x - y * floor(x / y) + //! for each component in x using the floating point value y. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD mod( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y); + + //! Modulus. Returns x - y * floor(x / y) + //! for each component in x using the floating point value y. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD mod( + detail::fvec4SIMD const & x, + float const & y); + + //! Returns the fractional part of x and sets i to the integer + //! part (as a whole number floating point value). Both the + //! return value and the output parameter will have the same + //! sign as x. + //! (From GLM_GTX_simd_vec4 extension, common function) + //detail::fvec4SIMD modf( + // detail::fvec4SIMD const & x, + // detail::fvec4SIMD & i); + + //! Returns y if y < x; otherwise, it returns x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD min( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y); + + detail::fvec4SIMD min( + detail::fvec4SIMD const & x, + float const & y); + + //! Returns y if x < y; otherwise, it returns x. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD max( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y); + + detail::fvec4SIMD max( + detail::fvec4SIMD const & x, + float const & y); + + //! Returns min(max(x, minVal), maxVal) for each component in x + //! using the floating-point values minVal and maxVal. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD clamp( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & minVal, + detail::fvec4SIMD const & maxVal); + + detail::fvec4SIMD clamp( + detail::fvec4SIMD const & x, + float const & minVal, + float const & maxVal); + + //! \return If genTypeU is a floating scalar or vector: + //! Returns x * (1.0 - a) + y * a, i.e., the linear blend of + //! x and y using the floating-point value a. + //! The value for a is not restricted to the range [0, 1]. + //! + //! \return If genTypeU is a boolean scalar or vector: + //! Selects which vector each returned component comes + //! from. For a component of a that is false, the + //! corresponding component of x is returned. For a + //! component of a that is true, the corresponding + //! component of y is returned. Components of x and y that + //! are not selected are allowed to be invalid floating point + //! values and will have no effect on the results. Thus, this + //! provides different functionality than + //! genType mix(genType x, genType y, genType(a)) + //! where a is a Boolean vector. + //! + //! From GLSL 1.30.08 specification, section 8.3 + //! + //! \param[in] x Floating point scalar or vector. + //! \param[in] y Floating point scalar or vector. + //! \param[in] a Floating point or boolean scalar or vector. + //! + // \todo Test when 'a' is a boolean. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD mix( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y, + detail::fvec4SIMD const & a); + + //! Returns 0.0 if x < edge, otherwise it returns 1.0. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD step( + detail::fvec4SIMD const & edge, + detail::fvec4SIMD const & x); + + detail::fvec4SIMD step( + float const & edge, + detail::fvec4SIMD const & x); + + //! Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and + //! performs smooth Hermite interpolation between 0 and 1 + //! when edge0 < x < edge1. This is useful in cases where + //! you would want a threshold function with a smooth + //! transition. This is equivalent to: + //! genType t; + //! t = clamp ((x - edge0) / (edge1 - edge0), 0, 1); + //! return t * t * (3 - 2 * t); + //! Results are undefined if edge0 >= edge1. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD smoothstep( + detail::fvec4SIMD const & edge0, + detail::fvec4SIMD const & edge1, + detail::fvec4SIMD const & x); + + detail::fvec4SIMD smoothstep( + float const & edge0, + float const & edge1, + detail::fvec4SIMD const & x); + + //! Returns true if x holds a NaN (not a number) + //! representation in the underlying implementation's set of + //! floating point representations. Returns false otherwise, + //! including for implementations with no NaN + //! representations. + //! (From GLM_GTX_simd_vec4 extension, common function) + //bvec4 isnan(detail::fvec4SIMD const & x); + + //! Returns true if x holds a positive infinity or negative + //! infinity representation in the underlying implementation's + //! set of floating point representations. Returns false + //! otherwise, including for implementations with no infinity + //! representations. + //! (From GLM_GTX_simd_vec4 extension, common function) + //bvec4 isinf(detail::fvec4SIMD const & x); + + //! Returns a signed or unsigned integer value representing + //! the encoding of a floating-point value. The floatingpoint + //! value's bit-level representation is preserved. + //! (From GLM_GTX_simd_vec4 extension, common function) + //detail::ivec4SIMD floatBitsToInt(detail::fvec4SIMD const & value); + + //! Returns a floating-point value corresponding to a signed + //! or unsigned integer encoding of a floating-point value. + //! If an inf or NaN is passed in, it will not signal, and the + //! resulting floating point value is unspecified. Otherwise, + //! the bit-level representation is preserved. + //! (From GLM_GTX_simd_vec4 extension, common function) + //detail::fvec4SIMD intBitsToFloat(detail::ivec4SIMD const & value); + + //! Computes and returns a * b + c. + //! (From GLM_GTX_simd_vec4 extension, common function) + detail::fvec4SIMD fma( + detail::fvec4SIMD const & a, + detail::fvec4SIMD const & b, + detail::fvec4SIMD const & c); + + //! Splits x into a floating-point significand in the range + //! [0.5, 1.0) and an integral exponent of two, such that: + //! x = significand * exp(2, exponent) + //! The significand is returned by the function and the + //! exponent is returned in the parameter exp. For a + //! floating-point value of zero, the significant and exponent + //! are both zero. For a floating-point value that is an + //! infinity or is not a number, the results are undefined. + //! (From GLM_GTX_simd_vec4 extension, common function) + //detail::fvec4SIMD frexp(detail::fvec4SIMD const & x, detail::ivec4SIMD & exp); + + //! Builds a floating-point number from x and the + //! corresponding integral exponent of two in exp, returning: + //! significand * exp(2, exponent) + //! If this product is too large to be represented in the + //! floating-point type, the result is undefined. + //! (From GLM_GTX_simd_vec4 extension, common function) + //detail::fvec4SIMD ldexp(detail::fvec4SIMD const & x, detail::ivec4SIMD const & exp); + + //! Returns the length of x, i.e., sqrt(x * x). + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + float length( + detail::fvec4SIMD const & x); + + //! Returns the length of x, i.e., sqrt(x * x). + //! Less accurate but much faster than simdLength. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + float fastLength( + detail::fvec4SIMD const & x); + + //! Returns the length of x, i.e., sqrt(x * x). + //! Slightly more accurate but much slower than simdLength. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + float niceLength( + detail::fvec4SIMD const & x); + + //! Returns the length of x, i.e., sqrt(x * x). + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD length4( + detail::fvec4SIMD const & x); + + //! Returns the length of x, i.e., sqrt(x * x). + //! Less accurate but much faster than simdLength4. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD fastLength4( + detail::fvec4SIMD const & x); + + //! Returns the length of x, i.e., sqrt(x * x). + //! Slightly more accurate but much slower than simdLength4. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD niceLength4( + detail::fvec4SIMD const & x); + + //! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + float distance( + detail::fvec4SIMD const & p0, + detail::fvec4SIMD const & p1); + + //! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD distance4( + detail::fvec4SIMD const & p0, + detail::fvec4SIMD const & p1); + + //! Returns the dot product of x and y, i.e., result = x * y. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + float simdDot( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y); + + //! Returns the dot product of x and y, i.e., result = x * y. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD dot4( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y); + + //! Returns the cross product of x and y. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD cross( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y); + + //! Returns a vector in the same direction as x but with length of 1. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD normalize( + detail::fvec4SIMD const & x); + + //! Returns a vector in the same direction as x but with length of 1. + //! Less accurate but much faster than simdNormalize. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD fastNormalize( + detail::fvec4SIMD const & x); + + //! If dot(Nref, I) < 0.0, return N, otherwise, return -N. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD simdFaceforward( + detail::fvec4SIMD const & N, + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & Nref); + + //! For the incident vector I and surface orientation N, + //! returns the reflection direction : result = I - 2.0 * dot(N, I) * N. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD reflect( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N); + + //! For the incident vector I and surface normal N, + //! and the ratio of indices of refraction eta, + //! return the refraction vector. + //! (From GLM_GTX_simd_vec4 extension, geometry functions) + detail::fvec4SIMD refract( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N, + float const & eta); + + //! Returns the positive square root of x. + //! (From GLM_GTX_simd_vec4 extension, exponential function) + detail::fvec4SIMD sqrt( + detail::fvec4SIMD const & x); + + //! Returns the positive square root of x with the nicest quality but very slow. + //! Slightly more accurate but much slower than simdSqrt. + //! (From GLM_GTX_simd_vec4 extension, exponential function) + detail::fvec4SIMD niceSqrt( + detail::fvec4SIMD const & x); + + //! Returns the positive square root of x + //! Less accurate but much faster than sqrt. + //! (From GLM_GTX_simd_vec4 extension, exponential function) + detail::fvec4SIMD fastSqrt( + detail::fvec4SIMD const & x); + + //! Returns the reciprocal of the positive square root of x. + //! (From GLM_GTX_simd_vec4 extension, exponential function) + detail::fvec4SIMD inversesqrt( + detail::fvec4SIMD const & x); + + //! Returns the reciprocal of the positive square root of x. + //! Faster than inversesqrt but less accurate. + //! (From GLM_GTX_simd_vec4 extension, exponential function) + detail::fvec4SIMD fastInversesqrt( + detail::fvec4SIMD const & x); + + /// @} +}//namespace glm + +#include "simd_vec4.inl" + + +#if (GLM_COMPILER & GLM_COMPILER_VC) +# pragma warning(pop) +#endif + + +#endif//(GLM_ARCH != GLM_ARCH_PURE) + +#endif//GLM_GTX_simd_vec4 diff --git a/include/gal/opengl/glm/gtx/simd_vec4.inl b/include/gal/opengl/glm/gtx/simd_vec4.inl new file mode 100644 index 0000000..0b22115 --- /dev/null +++ b/include/gal/opengl/glm/gtx/simd_vec4.inl @@ -0,0 +1,727 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-05-07 +// Updated : 2009-05-07 +// Licence : This source is under MIT License +// File : glm/gtx/simd_vec4.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ +namespace detail{ + +template <int Value> +struct mask +{ + enum{value = Value}; +}; + +////////////////////////////////////// +// Implicit basic constructors + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD() +#ifdef GLM_SIMD_ENABLE_DEFAULT_INIT + : Data(_mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f)) +#endif +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(__m128 const & Data) : + Data(Data) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(fvec4SIMD const & v) : + Data(v.Data) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(tvec4<float> const & v) : + Data(_mm_set_ps(v.w, v.z, v.y, v.x)) +{} + +////////////////////////////////////// +// Explicit basic constructors + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s) : + Data(_mm_set1_ps(s)) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & x, float const & y, float const & z, float const & w) : +// Data(_mm_setr_ps(x, y, z, w)) + Data(_mm_set_ps(w, z, y, x)) +{} +/* +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const v[4]) : + Data(_mm_load_ps(v)) +{} +*/ +////////////////////////////////////// +// Swizzle constructors + +//fvec4SIMD(ref4<float> const & r); + +////////////////////////////////////// +// Convertion vector constructors + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v, float const & s1, float const & s2) : + Data(_mm_set_ps(s2, s1, v.y, v.x)) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s1, vec2 const & v, float const & s2) : + Data(_mm_set_ps(s2, v.y, v.x, s1)) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s1, float const & s2, vec2 const & v) : + Data(_mm_set_ps(v.y, v.x, s2, s1)) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec3 const & v, float const & s) : + Data(_mm_set_ps(s, v.z, v.y, v.x)) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(float const & s, vec3 const & v) : + Data(_mm_set_ps(v.z, v.y, v.x, s)) +{} + +GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) : + Data(_mm_set_ps(v2.y, v2.x, v1.y, v1.x)) +{} + +//GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(ivec4SIMD const & v) : +// Data(_mm_cvtepi32_ps(v.Data)) +//{} + +////////////////////////////////////// +// Unary arithmetic operators + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator=(fvec4SIMD const & v) +{ + this->Data = v.Data; + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(float const & s) +{ + this->Data = _mm_add_ps(Data, _mm_set_ps1(s)); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator+=(fvec4SIMD const & v) +{ + this->Data = _mm_add_ps(this->Data , v.Data); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator-=(float const & s) +{ + this->Data = _mm_sub_ps(Data, _mm_set_ps1(s)); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator-=(fvec4SIMD const & v) +{ + this->Data = _mm_sub_ps(this->Data , v.Data); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator*=(float const & s) +{ + this->Data = _mm_mul_ps(this->Data, _mm_set_ps1(s)); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator*=(fvec4SIMD const & v) +{ + this->Data = _mm_mul_ps(this->Data , v.Data); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator/=(float const & s) +{ + this->Data = _mm_div_ps(Data, _mm_set1_ps(s)); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator/=(fvec4SIMD const & v) +{ + this->Data = _mm_div_ps(this->Data , v.Data); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator++() +{ + this->Data = _mm_add_ps(this->Data , glm::detail::one); + return *this; +} + +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::operator--() +{ + this->Data = _mm_sub_ps(this->Data, glm::detail::one); + return *this; +} + +////////////////////////////////////// +// Swizzle operators + +template <comp X, comp Y, comp Z, comp W> +GLM_FUNC_QUALIFIER fvec4SIMD fvec4SIMD::swizzle() const +{ + __m128 Data = _mm_shuffle_ps( + this->Data, this->Data, + mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + return fvec4SIMD(Data); +} + +template <comp X, comp Y, comp Z, comp W> +GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::swizzle() +{ + this->Data = _mm_shuffle_ps( + this->Data, this->Data, + mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value); + return *this; +} + +// operator+ +GLM_FUNC_QUALIFIER fvec4SIMD operator+ (fvec4SIMD const & v, float s) +{ + return fvec4SIMD(_mm_add_ps(v.Data, _mm_set1_ps(s))); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator+ (float s, fvec4SIMD const & v) +{ + return fvec4SIMD(_mm_add_ps(_mm_set1_ps(s), v.Data)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator+ (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_add_ps(v1.Data, v2.Data)); +} + +//operator- +GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v, float s) +{ + return fvec4SIMD(_mm_sub_ps(v.Data, _mm_set1_ps(s))); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator- (float s, fvec4SIMD const & v) +{ + return fvec4SIMD(_mm_sub_ps(_mm_set1_ps(s), v.Data)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_sub_ps(v1.Data, v2.Data)); +} + +//operator* +GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v, float s) +{ + __m128 par0 = v.Data; + __m128 par1 = _mm_set1_ps(s); + return fvec4SIMD(_mm_mul_ps(par0, par1)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator* (float s, fvec4SIMD const & v) +{ + __m128 par0 = _mm_set1_ps(s); + __m128 par1 = v.Data; + return fvec4SIMD(_mm_mul_ps(par0, par1)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator* (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_mul_ps(v1.Data, v2.Data)); +} + +//operator/ +GLM_FUNC_QUALIFIER fvec4SIMD operator/ (fvec4SIMD const & v, float s) +{ + __m128 par0 = v.Data; + __m128 par1 = _mm_set1_ps(s); + return fvec4SIMD(_mm_div_ps(par0, par1)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator/ (float s, fvec4SIMD const & v) +{ + __m128 par0 = _mm_set1_ps(s); + __m128 par1 = v.Data; + return fvec4SIMD(_mm_div_ps(par0, par1)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator/ (fvec4SIMD const & v1, fvec4SIMD const & v2) +{ + return fvec4SIMD(_mm_div_ps(v1.Data, v2.Data)); +} + +// Unary constant operators +GLM_FUNC_QUALIFIER fvec4SIMD operator- (fvec4SIMD const & v) +{ + return fvec4SIMD(_mm_sub_ps(_mm_setzero_ps(), v.Data)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator++ (fvec4SIMD const & v, int) +{ + return fvec4SIMD(_mm_add_ps(v.Data, glm::detail::one)); +} + +GLM_FUNC_QUALIFIER fvec4SIMD operator-- (fvec4SIMD const & v, int) +{ + return fvec4SIMD(_mm_sub_ps(v.Data, glm::detail::one)); +} + +}//namespace detail + +GLM_FUNC_QUALIFIER detail::tvec4<float> vec4_cast +( + detail::fvec4SIMD const & x +) +{ + GLM_ALIGN(16) detail::tvec4<float> Result; + _mm_store_ps(&Result[0], x.Data); + return Result; +} + +// Other possible implementation +//float abs(float a) +//{ +// return max(-a, a); +//} +GLM_FUNC_QUALIFIER detail::fvec4SIMD abs +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_abs_ps(x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD sign +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_sgn_ps(x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD floor +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_flr_ps(x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD trunc +( + detail::fvec4SIMD const & x +) +{ + //return x < 0 ? -floor(-x) : floor(x); + + __m128 Flr0 = detail::sse_flr_ps(_mm_sub_ps(_mm_setzero_ps(), x.Data)); + __m128 Sub0 = _mm_sub_ps(Flr0, x.Data); + __m128 Flr1 = detail::sse_flr_ps(x.Data); + + __m128 Cmp0 = _mm_cmplt_ps(x.Data, glm::detail::zero); + __m128 Cmp1 = _mm_cmpnlt_ps(x.Data, glm::detail::zero); + + __m128 And0 = _mm_and_ps(Sub0, Cmp0); + __m128 And1 = _mm_and_ps(Flr1, Cmp1); + + return _mm_or_ps(And0, And1); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD round +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_rnd_ps(x.Data); +} + +//GLM_FUNC_QUALIFIER detail::fvec4SIMD roundEven +//( +// detail::fvec4SIMD const & x +//) +//{ + +//} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD ceil +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_ceil_ps(x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD fract +( + detail::fvec4SIMD const & x +) +{ + return detail::sse_frc_ps(x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD mod +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return detail::sse_mod_ps(x.Data, y.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD mod +( + detail::fvec4SIMD const & x, + float const & y +) +{ + return detail::sse_mod_ps(x.Data, _mm_set1_ps(y)); +} + +//GLM_FUNC_QUALIFIER detail::fvec4SIMD modf +//( +// detail::fvec4SIMD const & x, +// detail::fvec4SIMD & i +//) +//{ + +//} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD min +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return _mm_min_ps(x.Data, y.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD min +( + detail::fvec4SIMD const & x, + float const & y +) +{ + return _mm_min_ps(x.Data, _mm_set1_ps(y)); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD max +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return _mm_max_ps(x.Data, y.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD max +( + detail::fvec4SIMD const & x, + float const & y +) +{ + return _mm_max_ps(x.Data, _mm_set1_ps(y)); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD clamp +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & minVal, + detail::fvec4SIMD const & maxVal +) +{ + return detail::sse_clp_ps(x.Data, minVal.Data, maxVal.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD clamp +( + detail::fvec4SIMD const & x, + float const & minVal, + float const & maxVal +) +{ + return detail::sse_clp_ps(x.Data, _mm_set1_ps(minVal), _mm_set1_ps(maxVal)); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD mix +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y, + detail::fvec4SIMD const & a +) +{ + __m128 Sub0 = _mm_sub_ps(y.Data, x.Data); + __m128 Mul0 = _mm_mul_ps(a.Data, Sub0); + return _mm_add_ps(x.Data, Mul0); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD step +( + detail::fvec4SIMD const & edge, + detail::fvec4SIMD const & x +) +{ + __m128 cmp0 = _mm_cmpngt_ps(x.Data, edge.Data); + return _mm_max_ps(_mm_min_ps(cmp0, _mm_setzero_ps()), detail::one); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD step +( + float const & edge, + detail::fvec4SIMD const & x +) +{ + __m128 cmp0 = _mm_cmpngt_ps(x.Data, _mm_set1_ps(edge)); + return _mm_max_ps(_mm_min_ps(cmp0, _mm_setzero_ps()), detail::one); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD smoothstep +( + detail::fvec4SIMD const & edge0, + detail::fvec4SIMD const & edge1, + detail::fvec4SIMD const & x +) +{ + return detail::sse_ssp_ps(edge0.Data, edge1.Data, x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD smoothstep +( + float const & edge0, + float const & edge1, + detail::fvec4SIMD const & x +) +{ + return detail::sse_ssp_ps(_mm_set1_ps(edge0), _mm_set1_ps(edge1), x.Data); +} + +//GLM_FUNC_QUALIFIER bvec4 isnan(detail::fvec4SIMD const & x) +//{ + +//} + +//GLM_FUNC_QUALIFIER bvec4 isinf(detail::fvec4SIMD const & x) +//{ + +//} + +//GLM_FUNC_QUALIFIER detail::ivec4SIMD floatBitsToInt +//( +// detail::fvec4SIMD const & value +//) +//{ + +//} + +//GLM_FUNC_QUALIFIER detail::fvec4SIMD intBitsToFloat +//( +// detail::ivec4SIMD const & value +//) +//{ + +//} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD fma +( + detail::fvec4SIMD const & a, + detail::fvec4SIMD const & b, + detail::fvec4SIMD const & c +) +{ + return _mm_add_ps(_mm_mul_ps(a.Data, b.Data), c.Data); +} + +GLM_FUNC_QUALIFIER float length +( + detail::fvec4SIMD const & x +) +{ + detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); + detail::fvec4SIMD sqt0 = sqrt(dot0); + float Result = 0; + _mm_store_ss(&Result, sqt0.Data); + return Result; +} + +GLM_FUNC_QUALIFIER float fastLength +( + detail::fvec4SIMD const & x +) +{ + detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); + detail::fvec4SIMD sqt0 = fastSqrt(dot0); + float Result = 0; + _mm_store_ss(&Result, sqt0.Data); + return Result; +} + +GLM_FUNC_QUALIFIER float niceLength +( + detail::fvec4SIMD const & x +) +{ + detail::fvec4SIMD dot0 = detail::sse_dot_ss(x.Data, x.Data); + detail::fvec4SIMD sqt0 = niceSqrt(dot0); + float Result = 0; + _mm_store_ss(&Result, sqt0.Data); + return Result; +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD length4 +( + detail::fvec4SIMD const & x +) +{ + return sqrt(dot4(x, x)); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastLength4 +( + detail::fvec4SIMD const & x +) +{ + return fastSqrt(dot4(x, x)); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD niceLength4 +( + detail::fvec4SIMD const & x +) +{ + return niceSqrt(dot4(x, x)); +} + +GLM_FUNC_QUALIFIER float distance +( + detail::fvec4SIMD const & p0, + detail::fvec4SIMD const & p1 +) +{ + float Result = 0; + _mm_store_ss(&Result, detail::sse_dst_ps(p0.Data, p1.Data)); + return Result; +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD distance4 +( + detail::fvec4SIMD const & p0, + detail::fvec4SIMD const & p1 +) +{ + return detail::sse_dst_ps(p0.Data, p1.Data); +} + +GLM_FUNC_QUALIFIER float dot +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + float Result = 0; + _mm_store_ss(&Result, detail::sse_dot_ss(x.Data, y.Data)); + return Result; +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD dot4 +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return detail::sse_dot_ps(x.Data, y.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD cross +( + detail::fvec4SIMD const & x, + detail::fvec4SIMD const & y +) +{ + return detail::sse_xpd_ps(x.Data, y.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD normalize +( + detail::fvec4SIMD const & x +) +{ + __m128 dot0 = detail::sse_dot_ps(x.Data, x.Data); + __m128 isr0 = inversesqrt(detail::fvec4SIMD(dot0)).Data; + __m128 mul0 = _mm_mul_ps(x.Data, isr0); + return mul0; +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastNormalize +( + detail::fvec4SIMD const & x +) +{ + __m128 dot0 = detail::sse_dot_ps(x.Data, x.Data); + __m128 isr0 = fastInversesqrt(dot0).Data; + __m128 mul0 = _mm_mul_ps(x.Data, isr0); + return mul0; +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD faceforward +( + detail::fvec4SIMD const & N, + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & Nref +) +{ + return detail::sse_ffd_ps(N.Data, I.Data, Nref.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD reflect +( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N +) +{ + return detail::sse_rfe_ps(I.Data, N.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD refract +( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N, + float const & eta +) +{ + return detail::sse_rfa_ps(I.Data, N.Data, _mm_set1_ps(eta)); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD sqrt(detail::fvec4SIMD const & x) +{ + return _mm_mul_ps(inversesqrt(x).Data, x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD niceSqrt(detail::fvec4SIMD const & x) +{ + return _mm_sqrt_ps(x.Data); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastSqrt(detail::fvec4SIMD const & x) +{ + return _mm_mul_ps(fastInversesqrt(x.Data).Data, x.Data); +} + +// SSE scalar reciprocal sqrt using rsqrt op, plus one Newton-Rhaphson iteration +// By Elan Ruskin, http://assemblyrequired.crashworks.org/ +GLM_FUNC_QUALIFIER detail::fvec4SIMD inversesqrt(detail::fvec4SIMD const & x) +{ + GLM_ALIGN(4) static const __m128 three = {3, 3, 3, 3}; // aligned consts for fast load + GLM_ALIGN(4) static const __m128 half = {0.5,0.5,0.5,0.5}; + + __m128 recip = _mm_rsqrt_ps(x.Data); // "estimate" opcode + __m128 halfrecip = _mm_mul_ps(half, recip); + __m128 threeminus_xrr = _mm_sub_ps(three, _mm_mul_ps(x.Data, _mm_mul_ps(recip, recip))); + return _mm_mul_ps(halfrecip, threeminus_xrr); +} + +GLM_FUNC_QUALIFIER detail::fvec4SIMD fastInversesqrt(detail::fvec4SIMD const & x) +{ + return _mm_rsqrt_ps(x.Data); +} + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/spline.hpp b/include/gal/opengl/glm/gtx/spline.hpp new file mode 100644 index 0000000..e9035ce --- /dev/null +++ b/include/gal/opengl/glm/gtx/spline.hpp @@ -0,0 +1,90 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_spline +/// @file glm/gtx/spline.hpp +/// @date 2007-01-25 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_spline GLM_GTX_spline +/// @ingroup gtx +/// +/// @brief Spline functions +/// +/// <glm/gtx/spline.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_spline +#define GLM_GTX_spline GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/optimum_pow.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_spline extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_spline + /// @{ + + //! Return a point from a catmull rom curve. + //! From GLM_GTX_spline extension. + template <typename genType> + genType catmullRom( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s); + + //! Return a point from a hermite curve. + //! From GLM_GTX_spline extension. + template <typename genType> + genType hermite( + genType const & v1, + genType const & t1, + genType const & v2, + genType const & t2, + typename genType::value_type const & s); + + //! Return a point from a cubic curve. + //! From GLM_GTX_spline extension. + template <typename genType> + genType cubic( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s); + + /// @} +}//namespace glm + +#include "spline.inl" + +#endif//GLM_GTX_spline + diff --git a/include/gal/opengl/glm/gtx/spline.inl b/include/gal/opengl/glm/gtx/spline.inl new file mode 100644 index 0000000..6a6509e --- /dev/null +++ b/include/gal/opengl/glm/gtx/spline.inl @@ -0,0 +1,70 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-01-25 +// Updated : 2009-02-19 +// Licence : This source is under MIT License +// File : glm/gtx/spline.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm{ + +template <typename genType> +GLM_FUNC_QUALIFIER genType catmullRom +( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s +) +{ + typename genType::value_type s1 = s; + typename genType::value_type s2 = pow2(s); + typename genType::value_type s3 = pow3(s); + + typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; + typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); + typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; + typename genType::value_type f4 = s3 - s2; + + return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); + +} + +template <typename genType> +GLM_FUNC_QUALIFIER genType hermite +( + genType const & v1, + genType const & t1, + genType const & v2, + genType const & t2, + typename genType::value_type const & s +) +{ + typename genType::value_type s1 = s; + typename genType::value_type s2 = pow2(s); + typename genType::value_type s3 = pow3(s); + + typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); + typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; + typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; + typename genType::value_type f4 = s3 - s2; + + return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; +} + +template <typename genType> +GLM_FUNC_QUALIFIER genType cubic +( + genType const & v1, + genType const & v2, + genType const & v3, + genType const & v4, + typename genType::value_type const & s +) +{ + return ((v1 * s + v2) * s + v3) * s + v4; +} + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/std_based_type.hpp b/include/gal/opengl/glm/gtx/std_based_type.hpp new file mode 100644 index 0000000..c5c04dc --- /dev/null +++ b/include/gal/opengl/glm/gtx/std_based_type.hpp @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_std_based_type +/// @file glm/gtx/std_based_type.hpp +/// @date 2008-06-08 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_extented_min_max (dependence) +/// +/// @defgroup gtx_std_based_type GLM_GTX_std_based_type +/// @ingroup gtx +/// +/// @brief Adds vector types based on STL value types. +/// <glm/gtx/std_based_type.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_std_based_type +#define GLM_GTX_std_based_type GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include <cstdlib> + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_std_based_type extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_std_based_type + /// @{ + + /// Vector type based of two std::size_t components. + /// @see GLM_GTX_std_based_type + typedef detail::tvec2<std::size_t> size2; + + /// Vector type based of three std::size_t components. + /// @see GLM_GTX_std_based_type + typedef detail::tvec3<std::size_t> size3; + + /// Vector type based of four std::size_t components. + /// @see GLM_GTX_std_based_type + typedef detail::tvec4<std::size_t> size4; + + /// Vector type based of two std::size_t components. + /// @see GLM_GTX_std_based_type + typedef detail::tvec2<std::size_t> size2_t; + + /// Vector type based of three std::size_t components. + /// @see GLM_GTX_std_based_type + typedef detail::tvec3<std::size_t> size3_t; + + /// Vector type based of four std::size_t components. + /// @see GLM_GTX_std_based_type + typedef detail::tvec4<std::size_t> size4_t; + + /// @} +}//namespace glm + +#include "std_based_type.inl" + +#endif//GLM_GTX_std_based_type diff --git a/include/gal/opengl/glm/gtx/std_based_type.inl b/include/gal/opengl/glm/gtx/std_based_type.inl new file mode 100644 index 0000000..e349c4a --- /dev/null +++ b/include/gal/opengl/glm/gtx/std_based_type.inl @@ -0,0 +1,13 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-06-08 +// Updated : 2008-06-08 +// Licence : This source is under MIT License +// File : glm/gtx/std_based_type.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + +} diff --git a/include/gal/opengl/glm/gtx/string_cast.hpp b/include/gal/opengl/glm/gtx/string_cast.hpp new file mode 100644 index 0000000..b306093 --- /dev/null +++ b/include/gal/opengl/glm/gtx/string_cast.hpp @@ -0,0 +1,70 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_string_cast +/// @file glm/gtx/string_cast.hpp +/// @date 2008-04-26 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtx_integer (dependence) +/// @see gtx_quaternion (dependence) +/// +/// @defgroup gtx_string_cast GLM_GTX_string_cast +/// @ingroup gtx +/// +/// @brief Setup strings for GLM type values +/// +/// <glm/gtx/string_cast.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_string_cast +#define GLM_GTX_string_cast GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/half_float.hpp" +#include "../gtx/integer.hpp" +#include "../gtx/quaternion.hpp" +#include <string> + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_string_cast extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_string_cast + /// @{ + + /// Create a string from a GLM type value. + /// From GLM_GTX_string_cast extension. + template <typename genType> + std::string to_string(genType const & x); + + /// @} +}//namespace glm + +#include "string_cast.inl" + +#endif//GLM_GTX_string_cast diff --git a/include/gal/opengl/glm/gtx/string_cast.inl b/include/gal/opengl/glm/gtx/string_cast.inl new file mode 100644 index 0000000..d0e8f43 --- /dev/null +++ b/include/gal/opengl/glm/gtx/string_cast.inl @@ -0,0 +1,588 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2006 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-04-27 +// Updated : 2008-05-24 +// Licence : This source is under MIT License +// File : glm/gtx/string_cast.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include <cstdarg> +#include <cstdio> + +namespace glm{ +namespace detail +{ + GLM_FUNC_QUALIFIER std::string format(const char* msg, ...) + { + std::size_t const STRING_BUFFER(4096); + char text[STRING_BUFFER]; + va_list list; + + if(msg == 0) + return std::string(); + + va_start(list, msg); + +#if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) + vsprintf_s(text, STRING_BUFFER, msg, list); +#else// + vsprintf(text, msg, list); +#endif// + va_end(list); + + return std::string(text); + } + + static const char* True = "true"; + static const char* False = "false"; +}//namespace detail + + //////////////////////////////// + // Scalars + + GLM_FUNC_QUALIFIER std::string to_string(detail::half const & x) + { + return detail::format("half(%2.4f)", float(x)); + } + + GLM_FUNC_QUALIFIER std::string to_string(float x) + { + return detail::format("float(%f)", x); + } + + GLM_FUNC_QUALIFIER std::string to_string(double x) + { + return detail::format("double(%f)", x); + } + + GLM_FUNC_QUALIFIER std::string to_string(int x) + { + return detail::format("int(%d)", x); + } + + GLM_FUNC_QUALIFIER std::string to_string(unsigned int x) + { + return detail::format("uint(%d)", x); + } + + //////////////////////////////// + // Bool vectors + + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec2<bool> const & v + ) + { + return detail::format("bvec2(%s, %s)", + v.x ? detail::True : detail::False, + v.y ? detail::True : detail::False); + } + + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec3<bool> const & v + ) + { + return detail::format("bvec3(%s, %s, %s)", + v.x ? detail::True : detail::False, + v.y ? detail::True : detail::False, + v.z ? detail::True : detail::False); + } + + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec4<bool> const & v + ) + { + return detail::format("bvec4(%s, %s, %s, %s)", + v.x ? detail::True : detail::False, + v.y ? detail::True : detail::False, + v.z ? detail::True : detail::False, + v.w ? detail::True : detail::False); + } + + //////////////////////////////// + // Half vectors + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec2<detail::half> const & v + ) + { + return detail::format("hvec2(%2.4f, %2.4f)", v.x.toFloat(), v.y.toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec3<detail::half> const & v + ) + { + return detail::format("hvec3(%2.4f, %2.4f, %2.4f)", v.x.toFloat(), v.y.toFloat(), v.z.toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec4<detail::half> const & v + ) + { + return detail::format("hvec4(%2.4f, %2.4f, %2.4f, %2.4f)", v.x.toFloat(), v.y.toFloat(), v.z.toFloat(), v.w.toFloat()); + } + + //////////////////////////////// + // Float vectors + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec2<float> const & v + ) + { + return detail::format("fvec2(%f, %f)", v.x, v.y); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec3<float> const & v + ) + { + return detail::format("fvec3(%f, %f, %f)", v.x, v.y, v.z); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec4<float> const & v + ) + { + return detail::format("fvec4(%f, %f, %f, %f)", v.x, v.y, v.z, v.w); + } + + //////////////////////////////// + // Double vectors + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec2<double> const & v + ) + { + return detail::format("dvec2(%f, %f)", v.x, v.y); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec3<double> const & v + ) + { + return detail::format("dvec3(%f, %f, %f)", v.x, v.y, v.z); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec4<double> const & v + ) + { + return detail::format("dvec4(%f, %f, %f, %f)", v.x, v.y, v.z, v.w); + } + + //////////////////////////////// + // Int vectors + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec2<int> const & v + ) + { + return detail::format("ivec2(%d, %d)", v.x, v.y); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec3<int> const & v + ) + { + return detail::format("ivec3(%d, %d, %d)", v.x, v.y, v.z); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec4<int> const & v + ) + { + return detail::format("ivec4(%d, %d, %d, %d)", v.x, v.y, v.z, v.w); + } + + //////////////////////////////// + // Unsigned int vectors + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec2<unsigned int> const & v + ) + { + return detail::format("uvec2(%d, %d)", v.x, v.y); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec3<unsigned int> const & v + ) + { + return detail::format("uvec3(%d, %d, %d)", v.x, v.y, v.z); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tvec4<unsigned int> const & v + ) + { + return detail::format("uvec4(%d, %d, %d, %d)", v.x, v.y, v.z, v.w); + } + + //////////////////////////////// + // Half matrices + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x2<detail::half> const & m + ) + { + return detail::format("hmat2x2((%f, %f), (%f, %f))", + m[0][0].toFloat(), m[0][1].toFloat(), + m[1][0].toFloat(), m[1][1].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x3<detail::half> const & x + ) + { + return detail::format("hmat2x3((%f, %f, %f), (%f, %f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), x[0][2].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), x[1][2].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x4<detail::half> const & x + ) + { + return detail::format("hmat2x4((%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), x[0][2].toFloat(), x[0][3].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), x[1][2].toFloat(), x[1][3].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x2<detail::half> const & x + ) + { + return detail::format("hmat3x2((%f, %f), (%f, %f), (%f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), + x[2][0].toFloat(), x[2][1].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x3<detail::half> const & x + ) + { + return detail::format("hmat3x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), x[0][2].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), x[1][2].toFloat(), + x[2][0].toFloat(), x[2][1].toFloat(), x[2][2].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x4<detail::half> const & x + ) + { + return detail::format("hmat3x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), x[0][2].toFloat(), x[0][3].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), x[1][2].toFloat(), x[1][3].toFloat(), + x[2][0].toFloat(), x[2][1].toFloat(), x[2][2].toFloat(), x[2][3].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x2<detail::half> const & x + ) + { + return detail::format("hmat4x2((%f, %f), (%f, %f), (%f, %f), (%f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), + x[2][0].toFloat(), x[2][1].toFloat(), + x[3][0].toFloat(), x[3][1].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x3<detail::half> const & x + ) + { + return detail::format("hmat4x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), x[0][2].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), x[1][2].toFloat(), + x[2][0].toFloat(), x[2][1].toFloat(), x[2][2].toFloat(), + x[3][0].toFloat(), x[3][1].toFloat(), x[3][2].toFloat()); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x4<detail::half> const & x + ) + { + return detail::format("hmat4x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0].toFloat(), x[0][1].toFloat(), x[0][2].toFloat(), x[0][3].toFloat(), + x[1][0].toFloat(), x[1][1].toFloat(), x[1][2].toFloat(), x[1][3].toFloat(), + x[2][0].toFloat(), x[2][1].toFloat(), x[2][2].toFloat(), x[2][3].toFloat(), + x[3][0].toFloat(), x[3][1].toFloat(), x[3][2].toFloat(), x[3][3].toFloat()); + } + + //////////////////////////////// + // Float matrices + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x2<float> const & x + ) + { + return detail::format("mat2x2((%f, %f), (%f, %f))", + x[0][0], x[0][1], + x[1][0], x[1][1]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x3<float> const & x + ) + { + return detail::format("mat2x3((%f, %f, %f), (%f, %f, %f))", + x[0][0], x[0][1], x[0][2], + x[1][0], x[1][1], x[1][2]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x4<float> const & x + ) + { + return detail::format("mat2x4((%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0], x[0][1], x[0][2], x[0][3], + x[1][0], x[1][1], x[1][2], x[1][3]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x2<float> const & x + ) + { + return detail::format("mat3x2((%f, %f), (%f, %f), (%f, %f))", + x[0][0], x[0][1], + x[1][0], x[1][1], + x[2][0], x[2][1]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x3<float> const & x + ) + { + return detail::format("mat3x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", + x[0][0], x[0][1], x[0][2], + x[1][0], x[1][1], x[1][2], + x[2][0], x[2][1], x[2][2]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x4<float> const & x + ) + { + return detail::format("mat3x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0], x[0][1], x[0][2], x[0][3], + x[1][0], x[1][1], x[1][2], x[1][3], + x[2][0], x[2][1], x[2][2], x[2][3]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x2<float> const & x + ) + { + return detail::format("mat4x2((%f, %f), (%f, %f), (%f, %f), (%f, %f))", + x[0][0], x[0][1], + x[1][0], x[1][1], + x[2][0], x[2][1], + x[3][0], x[3][1]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x3<float> const & x + ) + { + return detail::format("mat4x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", + x[0][0], x[0][1], x[0][2], + x[1][0], x[1][1], x[1][2], + x[2][0], x[2][1], x[2][2], + x[3][0], x[3][1], x[3][2]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x4<float> const & x + ) + { + return detail::format("mat4x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0], x[0][1], x[0][2], x[0][3], + x[1][0], x[1][1], x[1][2], x[1][3], + x[2][0], x[2][1], x[2][2], x[2][3], + x[3][0], x[3][1], x[3][2], x[3][3]); + } + + //////////////////////////////// + // Double matrices + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x2<double> const & x + ) + { + return detail::format("dmat2x2((%f, %f), (%f, %f))", + x[0][0], x[0][1], + x[1][0], x[1][1]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x3<double> const & x + ) + { + return detail::format("dmat2x3((%f, %f, %f), (%f, %f, %f))", + x[0][0], x[0][1], x[0][2], + x[1][0], x[1][1], x[1][2]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat2x4<double> const & x + ) + { + return detail::format("dmat2x4((%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0], x[0][1], x[0][2], x[0][3], + x[1][0], x[1][1], x[1][2], x[1][3]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x2<double> const & x + ) + { + return detail::format("dmat3x2((%f, %f), (%f, %f), (%f, %f))", + x[0][0], x[0][1], + x[1][0], x[1][1], + x[2][0], x[2][1]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x3<double> const & x + ) + { + return detail::format("dmat3x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", + x[0][0], x[0][1], x[0][2], + x[1][0], x[1][1], x[1][2], + x[2][0], x[2][1], x[2][2]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat3x4<double> const & x + ) + { + return detail::format("dmat3x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0], x[0][1], x[0][2], x[0][3], + x[1][0], x[1][1], x[1][2], x[1][3], + x[2][0], x[2][1], x[2][2], x[2][3]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x2<double> const & x + ) + { + return detail::format("dmat4x2((%f, %f), (%f, %f), (%f, %f), (%f, %f))", + x[0][0], x[0][1], + x[1][0], x[1][1], + x[2][0], x[2][1], + x[3][0], x[3][1]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x3<double> const & x + ) + { + return detail::format("dmat4x3((%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f))", + x[0][0], x[0][1], x[0][2], + x[1][0], x[1][1], x[1][2], + x[2][0], x[2][1], x[2][2], + x[3][0], x[3][1], x[3][2]); + } + + template <> + GLM_FUNC_QUALIFIER std::string to_string + ( + detail::tmat4x4<double> const & x + ) + { + return detail::format("dmat4x4((%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f), (%f, %f, %f, %f))", + x[0][0], x[0][1], x[0][2], x[0][3], + x[1][0], x[1][1], x[1][2], x[1][3], + x[2][0], x[2][1], x[2][2], x[2][3], + x[3][0], x[3][1], x[3][2], x[3][3]); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/transform.hpp b/include/gal/opengl/glm/gtx/transform.hpp new file mode 100644 index 0000000..8929e46 --- /dev/null +++ b/include/gal/opengl/glm/gtx/transform.hpp @@ -0,0 +1,131 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_transform +/// @file glm/gtx/transform.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtc_matrix_transform (dependence) +/// @see gtx_transform +/// @see gtx_transform2 +/// +/// @defgroup gtx_transform GLM_GTX_transform +/// @ingroup gtx +/// +/// @brief Add transformation matrices +/// +/// <glm/gtx/transform.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_transform +#define GLM_GTX_transform GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/matrix_transform.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_transform extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_transform + /// @{ + + //! Builds a translation 4 * 4 matrix created from 3 scalars. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::translate GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> translate( + T x, T y, T z); + + //! Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::translate GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> translate( + detail::tmat4x4<T> const & m, + T x, T y, T z); + + //! Transforms a matrix with a translation 4 * 4 matrix created from 3 scalars. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::translate GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> translate( + detail::tvec3<T> const & v); + + //! Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::rotate GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> rotate( + T angle, + T x, T y, T z); + + //! Builds a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::rotate GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> rotate( + T angle, + detail::tvec3<T> const & v); + + //! Transforms a matrix with a rotation 4 * 4 matrix created from an axis of 3 scalars and an angle expressed in degrees. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::rotate GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> rotate( + detail::tmat4x4<T> const & m, + T angle, + T x, T y, T z); + + //! Builds a scale 4 * 4 matrix created from 3 scalars. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::scale GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> scale( + T x, T y, T z); + + //! Transforms a matrix with a scale 4 * 4 matrix created from 3 scalars. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::scale GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> scale( + detail::tmat4x4<T> const & m, + T x, T y, T z); + + //! Transforms a matrix with a scale 4 * 4 matrix created from a vector of 3 components. + //! - From \link gtx_transform GLM_GTX_transform \endlink extension + // - See also: \link glm::scale GLM_GTC_matrix_transform \endlink + template <typename T> + detail::tmat4x4<T> scale( + detail::tvec3<T> const & v); + + /// @} +}// namespace glm + +#include "transform.inl" + +#endif//GLM_GTX_transform diff --git a/include/gal/opengl/glm/gtx/transform.inl b/include/gal/opengl/glm/gtx/transform.inl new file mode 100644 index 0000000..8f8c921 --- /dev/null +++ b/include/gal/opengl/glm/gtx/transform.inl @@ -0,0 +1,90 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-21 +// Updated : 2009-04-29 +// Licence : This source is under MIT License +// File : glm/gtx/transform.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate( + T x, T y, T z) + { + return translate( + detail::tmat4x4<T>(1.0f), + detail::tvec3<T>(x, y , z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate( + detail::tmat4x4<T> const & m, + T x, T y, T z) + { + return translate( + m, detail::tvec3<T>(x, y , z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> translate( + detail::tvec3<T> const & v) + { + return translate( + detail::tmat4x4<T>(1.0f), v); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate( + T angle, + T x, T y, T z) + { + return rotate( + detail::tmat4x4<T>(1), angle, detail::tvec3<T>(x, y, z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate( + T angle, + detail::tvec3<T> const & v) + { + return rotate( + detail::tmat4x4<T>(1), angle, v); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> rotate( + detail::tmat4x4<T> const & m, + T angle, + T x, T y, T z) + { + return rotate( + m, angle, detail::tvec3<T>(x, y, z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale(T x, T y, T z) + { + return scale( + detail::tmat4x4<T>(1), detail::tvec3<T>(x, y, z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale( + detail::tmat4x4<T> const & m, + T x, T y, T z) + { + return scale( + m, detail::tvec3<T>(x, y, z)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> scale( + detail::tvec3<T> const & v) + { + return scale( + detail::tmat4x4<T>(1.0f), v); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/transform2.hpp b/include/gal/opengl/glm/gtx/transform2.hpp new file mode 100644 index 0000000..4c6bd15 --- /dev/null +++ b/include/gal/opengl/glm/gtx/transform2.hpp @@ -0,0 +1,135 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_transform2 +/// @file glm/gtx/transform2.hpp +/// @date 2005-12-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_transform (dependence) +/// +/// @defgroup gtx_transform2 GLM_GTX_transform2 +/// @ingroup gtx +/// +/// @brief Add extra transformation matrices +/// +/// <glm/gtx/transform2.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_transform2 +#define GLM_GTX_transform2 GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtx/transform.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_transform2 extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_transform2 + /// @{ + + //! Transforms a matrix with a shearing on X axis. + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat3x3<T> shearX2D( + detail::tmat3x3<T> const & m, + T y); + + //! Transforms a matrix with a shearing on Y axis. + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat3x3<T> shearY2D( + detail::tmat3x3<T> const & m, + T x); + + //! Transforms a matrix with a shearing on X axis + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat4x4<T> shearX3D( + const detail::tmat4x4<T> & m, + T y, + T z); + + //! Transforms a matrix with a shearing on Y axis. + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat4x4<T> shearY3D( + const detail::tmat4x4<T> & m, + T x, + T z); + + //! Transforms a matrix with a shearing on Z axis. + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat4x4<T> shearZ3D( + const detail::tmat4x4<T> & m, + T x, + T y); + + //template <typename T> GLM_FUNC_QUALIFIER detail::tmat4x4<T> shear(const detail::tmat4x4<T> & m, shearPlane, planePoint, angle) + // Identity + tan(angle) * cross(Normal, OnPlaneVector) 0 + // - dot(PointOnPlane, normal) * OnPlaneVector 1 + + // Reflect functions seem to don't work + //template <typename T> detail::tmat3x3<T> reflect2D(const detail::tmat3x3<T> & m, const detail::tvec3<T>& normal){return reflect2DGTX(m, normal);} //!< \brief Build a reflection matrix (from GLM_GTX_transform2 extension) + //template <typename T> detail::tmat4x4<T> reflect3D(const detail::tmat4x4<T> & m, const detail::tvec3<T>& normal){return reflect3DGTX(m, normal);} //!< \brief Build a reflection matrix (from GLM_GTX_transform2 extension) + + //! Build planar projection matrix along normal axis. + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat3x3<T> proj2D( + const detail::tmat3x3<T> & m, + const detail::tvec3<T>& normal); + + //! Build planar projection matrix along normal axis. + //! From GLM_GTX_transform2 extension. + template <typename T> + detail::tmat4x4<T> proj3D( + const detail::tmat4x4<T> & m, + const detail::tvec3<T>& normal); + + //! Build a scale bias matrix. + //! From GLM_GTX_transform2 extension. + template <typename valType> + detail::tmat4x4<valType> scaleBias( + valType scale, + valType bias); + + //! Build a scale bias matrix. + //! From GLM_GTX_transform2 extension. + template <typename valType> + detail::tmat4x4<valType> scaleBias( + detail::tmat4x4<valType> const & m, + valType scale, + valType bias); + + /// @} +}// namespace glm + +#include "transform2.inl" + +#endif//GLM_GTX_transform2 diff --git a/include/gal/opengl/glm/gtx/transform2.inl b/include/gal/opengl/glm/gtx/transform2.inl new file mode 100644 index 0000000..06b65f5 --- /dev/null +++ b/include/gal/opengl/glm/gtx/transform2.inl @@ -0,0 +1,154 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-02-28 +// Updated : 2005-04-23 +// Licence : This source is under MIT License +// File : glm/gtx/transform2.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearX2D( + const detail::tmat3x3<T>& m, + T s) + { + detail::tmat3x3<T> r(1); + r[0][1] = s; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> shearY2D( + const detail::tmat3x3<T>& m, + T s) + { + detail::tmat3x3<T> r(1); + r[1][0] = s; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearX3D( + const detail::tmat4x4<T>& m, + T s, + T t) + { + detail::tmat4x4<T> r(1); + r[1][0] = s; + r[2][0] = t; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearY3D( + const detail::tmat4x4<T>& m, + T s, + T t) + { + detail::tmat4x4<T> r(1); + r[0][1] = s; + r[2][1] = t; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> shearZ3D( + const detail::tmat4x4<T>& m, + T s, + T t) + { + detail::tmat4x4<T> r(1); + r[0][2] = s; + r[1][2] = t; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> reflect2D( + const detail::tmat3x3<T>& m, + const detail::tvec3<T>& normal) + { + detail::tmat3x3<T> r(1); + r[0][0] = 1 - 2 * normal.x * normal.x; + r[0][1] = -2 * normal.x * normal.y; + r[1][0] = -2 * normal.x * normal.y; + r[1][1] = 1 - 2 * normal.y * normal.y; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> reflect3D( + const detail::tmat4x4<T>& m, + const detail::tvec3<T>& normal) + { + detail::tmat4x4<T> r(1); + r[0][0] = 1 - 2 * normal.x * normal.x; + r[0][1] = -2 * normal.x * normal.y; + r[0][2] = -2 * normal.x * normal.z; + + r[1][0] = -2 * normal.x * normal.y; + r[1][1] = 1 - 2 * normal.y * normal.y; + r[1][2] = -2 * normal.y * normal.z; + + r[2][0] = -2 * normal.x * normal.z; + r[2][1] = -2 * normal.y * normal.z; + r[2][2] = 1 - 2 * normal.z * normal.z; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> proj2D( + const detail::tmat3x3<T>& m, + const detail::tvec3<T>& normal) + { + detail::tmat3x3<T> r(1); + r[0][0] = 1 - normal.x * normal.x; + r[0][1] = - normal.x * normal.y; + r[1][0] = - normal.x * normal.y; + r[1][1] = 1 - normal.y * normal.y; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> proj3D( + const detail::tmat4x4<T>& m, + const detail::tvec3<T>& normal) + { + detail::tmat4x4<T> r(1); + r[0][0] = 1 - normal.x * normal.x; + r[0][1] = - normal.x * normal.y; + r[0][2] = - normal.x * normal.z; + r[1][0] = - normal.x * normal.y; + r[1][1] = 1 - normal.y * normal.y; + r[1][2] = - normal.y * normal.z; + r[2][0] = - normal.x * normal.z; + r[2][1] = - normal.y * normal.z; + r[2][2] = 1 - normal.z * normal.z; + return m * r; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias( + T scale, + T bias) + { + detail::tmat4x4<T> result; + result[3] = detail::tvec4<T>(detail::tvec3<T>(bias), T(1)); + result[0][0] = scale; + result[1][1] = scale; + result[2][2] = scale; + return result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> scaleBias( + const detail::tmat4x4<T>& m, + T scale, + T bias) + { + return m * scaleBias(scale, bias); + } +}//namespace glm + diff --git a/include/gal/opengl/glm/gtx/ulp.hpp b/include/gal/opengl/glm/gtx/ulp.hpp new file mode 100644 index 0000000..b74f480 --- /dev/null +++ b/include/gal/opengl/glm/gtx/ulp.hpp @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_ulp extension is deprecated, include GLM_GTC_ulp (glm/gtc/ulp.hpp) instead") +#endif + +// Promoted: +#include "../gtc/ulp.hpp" diff --git a/include/gal/opengl/glm/gtx/unsigned_int.hpp b/include/gal/opengl/glm/gtx/unsigned_int.hpp new file mode 100644 index 0000000..340cfd4 --- /dev/null +++ b/include/gal/opengl/glm/gtx/unsigned_int.hpp @@ -0,0 +1,26 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////// + +#if(defined(GLM_MESSAGES)) +# pragma message("GLM: GLM_GTX_unsigned_int extension is deprecated, include GLM_GTX_integer instead") +#endif diff --git a/include/gal/opengl/glm/gtx/unsigned_int.inl b/include/gal/opengl/glm/gtx/unsigned_int.inl new file mode 100644 index 0000000..b08a387 --- /dev/null +++ b/include/gal/opengl/glm/gtx/unsigned_int.inl @@ -0,0 +1,13 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-24 +// Updated : 2008-10-07 +// Licence : This source is under MIT License +// File : glm/gtx/unsigned_int.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/vec1.hpp b/include/gal/opengl/glm/gtx/vec1.hpp new file mode 100644 index 0000000..7d37e6d --- /dev/null +++ b/include/gal/opengl/glm/gtx/vec1.hpp @@ -0,0 +1,137 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_vec1 +/// @file glm/gtx/vec1.hpp +/// @date 2010-02-08 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_vec1 GLM_GTX_vec1 +/// @ingroup gtx +/// +/// @brief Add vec1, ivec1, uvec1 and bvec1 types. +/// <glm/gtx/vec1.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_vec1 +#define GLM_GTX_vec1 GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../core/type_vec1.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_vec1 extension included") +#endif + +namespace glm +{ + //! 1 component vector of high precision floating-point numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::highp_vec1_t highp_vec1; + //! 1 component vector of medium precision floating-point numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::mediump_vec1_t mediump_vec1; + //! 1 component vector of low precision floating-point numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::lowp_vec1_t lowp_vec1; + + //! 1 component vector of high precision signed integer numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::highp_ivec1_t highp_ivec1; + //! 1 component vector of medium precision signed integer numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::mediump_ivec1_t mediump_ivec1; + //! 1 component vector of low precision signed integer numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::lowp_ivec1_t lowp_ivec1; + + //! 1 component vector of high precision unsigned integer numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::highp_uvec1_t highp_uvec1; + //! 1 component vector of medium precision unsigned integer numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::mediump_uvec1_t mediump_uvec1; + //! 1 component vector of low precision unsigned integer numbers. + //! There is no guarantee on the actual precision. + //! From GLM_GTX_vec1 extension. + typedef detail::lowp_uvec1_t lowp_uvec1; + + ////////////////////////// + // vec1 definition + + //! 1 component vector of boolean. + //! From GLM_GTX_vec1 extension. + typedef detail::tvec1<bool> bvec1; + +#if(defined(GLM_PRECISION_HIGHP_FLOAT)) + typedef highp_vec1 vec1; +#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) + typedef mediump_vec1 vec1; +#elif(defined(GLM_PRECISION_LOWP_FLOAT)) + typedef lowp_vec1 vec1; +#else + //! 1 component vector of floating-point numbers. + //! From GLM_GTX_vec1 extension. + typedef mediump_vec1 vec1; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_INT)) + typedef highp_ivec1 ivec1; +#elif(defined(GLM_PRECISION_MEDIUMP_INT)) + typedef mediump_ivec1 ivec1; +#elif(defined(GLM_PRECISION_LOWP_INT)) + typedef lowp_ivec1 ivec1; +#else + //! 1 component vector of signed integer numbers. + //! From GLM_GTX_vec1 extension. + typedef mediump_ivec1 ivec1; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_HIGHP_UINT)) + typedef highp_uvec1 uvec1; +#elif(defined(GLM_PRECISION_MEDIUMP_UINT)) + typedef mediump_uvec1 uvec1; +#elif(defined(GLM_PRECISION_LOWP_UINT)) + typedef lowp_uvec1 uvec1; +#else + //! 1 component vector of unsigned integer numbers. + //! From GLM_GTX_vec1 extension. + typedef mediump_uvec1 uvec1; +#endif//GLM_PRECISION + +}// namespace glm + +#include "vec1.inl" + +#endif//GLM_GTX_vec1 + diff --git a/include/gal/opengl/glm/gtx/vec1.inl b/include/gal/opengl/glm/gtx/vec1.inl new file mode 100644 index 0000000..782a8ec --- /dev/null +++ b/include/gal/opengl/glm/gtx/vec1.inl @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_vec1 +/// @file glm/gtx/vec1.inl +/// @date 2013-03-16 / 2013-03-16 +/// @author Christophe Riccio +/////////////////////////////////////////////////////////////////////////////////// diff --git a/include/gal/opengl/glm/gtx/vector_access.hpp b/include/gal/opengl/glm/gtx/vector_access.hpp new file mode 100644 index 0000000..8942661 --- /dev/null +++ b/include/gal/opengl/glm/gtx/vector_access.hpp @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_vector_access +/// @file glm/gtx/vector_access.hpp +/// @date 2006-01-16 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_vector_access GLM_GTX_vector_access +/// @ingroup gtx +/// +/// @brief Function to set values to vectors +/// +/// <glm/gtx/vector_access.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_vector_access +#define GLM_GTX_vector_access GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_vector_access extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_vector_access + /// @{ + + //! Set values to a 2 components vector. + //! From GLM_GTX_vector_access extension. + template <typename valType> + void set( + detail::tvec2<valType> & v, + valType const & x, + valType const & y); + + //! Set values to a 3 components vector. + //! From GLM_GTX_vector_access extension. + template <typename valType> + void set( + detail::tvec3<valType> & v, + valType const & x, + valType const & y, + valType const & z); + + //! Set values to a 4 components vector. + //! From GLM_GTX_vector_access extension. + template <typename valType> + void set( + detail::tvec4<valType> & v, + valType const & x, + valType const & y, + valType const & z, + valType const & w); + + /// @} +}//namespace glm + +#include "vector_access.inl" + +#endif//GLM_GTX_vector_access diff --git a/include/gal/opengl/glm/gtx/vector_access.inl b/include/gal/opengl/glm/gtx/vector_access.inl new file mode 100644 index 0000000..b5a5603 --- /dev/null +++ b/include/gal/opengl/glm/gtx/vector_access.inl @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-01-16 +// Updated : 2008-10-07 +// Licence : This source is under MIT License +// File : glm/gtx/vector_access.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename valType> + GLM_FUNC_QUALIFIER void set + ( + detail::tvec2<valType>& v, + valType const & x, + valType const & y + ) + { + v.x = x; + v.y = y; + } + + template <typename valType> + GLM_FUNC_QUALIFIER void set + ( + detail::tvec3<valType>& v, + valType const & x, + valType const & y, + valType const & z + ) + { + v.x = x; + v.y = y; + v.z = z; + } + + template <typename valType> + GLM_FUNC_QUALIFIER void set + ( + detail::tvec4<valType>& v, + valType const & x, + valType const & y, + valType const & z, + valType const & w + ) + { + v.x = x; + v.y = y; + v.z = z; + v.w = w; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/vector_angle.hpp b/include/gal/opengl/glm/gtx/vector_angle.hpp new file mode 100644 index 0000000..fea8f65 --- /dev/null +++ b/include/gal/opengl/glm/gtx/vector_angle.hpp @@ -0,0 +1,88 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_vector_angle +/// @file glm/gtx/vector_angle.hpp +/// @date 2005-12-30 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// @see gtx_quaternion (dependence) +/// @see gtx_epsilon (dependence) +/// +/// @defgroup gtx_vector_angle GLM_GTX_vector_angle +/// @ingroup gtx +/// +/// @brief Compute angle between vectors +/// +/// <glm/gtx/vector_angle.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_vector_angle +#define GLM_GTX_vector_angle GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include "../gtc/epsilon.hpp" +#include "../gtx/quaternion.hpp" +#include "../gtx/rotate_vector.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_vector_angle extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_vector_angle + /// @{ + + //! Returns the absolute angle between two vectors + //! Parameters need to be normalized. + //! From GLM_GTX_vector_angle extension + template <typename vecType> + GLM_FUNC_QUALIFIER typename vecType::value_type angle( + vecType const & x, + vecType const & y); + + //! Returns the oriented angle between two 2d vectors + //! Parameters need to be normalized. + //! From GLM_GTX_vector_angle extension. + template <typename T> + GLM_FUNC_QUALIFIER T orientedAngle( + detail::tvec2<T> const & x, + detail::tvec2<T> const & y); + + //! Returns the oriented angle between two 3d vectors based from a reference axis. + //! Parameters need to be normalized. + //! From GLM_GTX_vector_angle extension. + template <typename T> + GLM_FUNC_QUALIFIER T orientedAngle( + detail::tvec3<T> const & x, + detail::tvec3<T> const & y, + detail::tvec3<T> const & ref); + + /// @} +}// namespace glm + +#include "vector_angle.inl" + +#endif//GLM_GTX_vector_angle diff --git a/include/gal/opengl/glm/gtx/vector_angle.inl b/include/gal/opengl/glm/gtx/vector_angle.inl new file mode 100644 index 0000000..ad221b1 --- /dev/null +++ b/include/gal/opengl/glm/gtx/vector_angle.inl @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2005-12-30 +// Updated : 2008-09-29 +// Licence : This source is under MIT License +// File : glm/gtx/vector_angle.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER typename genType::value_type angle + ( + genType const & x, + genType const & y + ) + { + return degrees(acos(dot(x, y))); + } + + //! \todo epsilon is hard coded to 0.01 + template <typename valType> + GLM_FUNC_QUALIFIER valType orientedAngle + ( + detail::tvec2<valType> const & x, + detail::tvec2<valType> const & y + ) + { +#ifdef GLM_FORCE_RADIANS + valType const Angle(acos(dot(x, y))); +#else + valType const Angle(glm::degrees(acos(dot(x, y)))); +#endif + detail::tvec2<valType> const TransformedVector(glm::rotate(x, Angle)); + if(all(epsilonEqual(y, TransformedVector, valType(0.01)))) + return Angle; + else + return -Angle; + } + + template <typename valType> + GLM_FUNC_QUALIFIER valType orientedAngle + ( + detail::tvec3<valType> const & x, + detail::tvec3<valType> const & y, + detail::tvec3<valType> const & ref + ) + { + valType const Angle(glm::degrees(glm::acos(glm::dot(x, y)))); + + if(glm::dot(ref, glm::cross(x, y)) < valType(0)) + return -Angle; + else + return Angle; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/vector_query.hpp b/include/gal/opengl/glm/gtx/vector_query.hpp new file mode 100644 index 0000000..f49f9e9 --- /dev/null +++ b/include/gal/opengl/glm/gtx/vector_query.hpp @@ -0,0 +1,112 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_vector_query +/// @file glm/gtx/vector_query.hpp +/// @date 2008-03-10 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_vector_query GLM_GTX_vector_query +/// @ingroup gtx +/// +/// @brief Query informations of vector types +/// +/// <glm/gtx/vector_query.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_vector_query +#define GLM_GTX_vector_query GLM_VERSION + +// Dependency: +#include "../glm.hpp" +#include <cfloat> +#include <limits> + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_vector_query extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_vector_query + /// @{ + + //! Check whether two vectors are collinears. + //! From GLM_GTX_vector_query extensions. + template <typename genType> + bool areCollinear( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + //! Check whether two vectors are orthogonals. + //! From GLM_GTX_vector_query extensions. + template <typename genType> + bool areOrthogonal( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + //! Check whether a vector is normalized. + //! From GLM_GTX_vector_query extensions. + template <typename genType, template <typename> class vecType> + bool isNormalized( + vecType<genType> const & v, + genType const & epsilon/* = std::numeric_limits<genType>::epsilon()*/); + + //! Check whether a vector is null. + //! From GLM_GTX_vector_query extensions. + template <typename valType> + bool isNull( + detail::tvec2<valType> const & v, + valType const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + //! Check whether a vector is null. + //! From GLM_GTX_vector_query extensions. + template <typename valType> + bool isNull( + detail::tvec3<valType> const & v, + valType const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + //! Check whether a vector is null. + //! From GLM_GTX_vector_query extensions. + template <typename valType> + bool isNull( + detail::tvec4<valType> const & v, + valType const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + //! Check whether two vectors are orthonormal. + //! From GLM_GTX_vector_query extensions. + template <typename genType> + bool areOrthonormal( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/); + + /// @} +}// namespace glm + +#include "vector_query.inl" + +#endif//GLM_GTX_vector_query diff --git a/include/gal/opengl/glm/gtx/vector_query.inl b/include/gal/opengl/glm/gtx/vector_query.inl new file mode 100644 index 0000000..c955315 --- /dev/null +++ b/include/gal/opengl/glm/gtx/vector_query.inl @@ -0,0 +1,164 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2007-03-05 +// Updated : 2010-02-16 +// Licence : This source is under MIT License +// File : glm/gtx/vector_query.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include <cassert> + +namespace glm +{ + template <typename T> + GLM_FUNC_QUALIFIER bool areCollinear + ( + detail::tvec2<T> const & v0, + detail::tvec2<T> const & v1, + typename detail::tvec2<T>::value_type const & epsilon + ) + { + return length(cross(detail::tvec3<T>(v0, T(0)), detail::tvec3<T>(v1, T(0)))) < epsilon; + } + + template <typename T> + GLM_FUNC_QUALIFIER bool areCollinear + ( + detail::tvec3<T> const & v0, + detail::tvec3<T> const & v1, + typename detail::tvec3<T>::value_type const & epsilon + ) + { + return length(cross(v0, v1)) < epsilon; + } + + template <typename T> + GLM_FUNC_QUALIFIER bool areCollinear + ( + detail::tvec4<T> const & v0, + detail::tvec4<T> const & v1, + typename detail::tvec4<T>::value_type const & epsilon + ) + { + return length(cross(detail::tvec3<T>(v0), detail::tvec3<T>(v1))) < epsilon; + } + + template <typename genType> + GLM_FUNC_QUALIFIER bool areOrthogonal + ( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon + ) + { + return abs(dot(v0, v1)) <= max( + typename genType::value_type(1), + length(v0)) * max( + typename genType::value_type(1), + length(v1)) * epsilon; + } + + template <typename genType, template <typename> class vecType> + GLM_FUNC_QUALIFIER bool isNormalized + ( + vecType<genType> const & v, + genType const & epsilon + ) + { + return abs(length(v) - genType(1)) <= genType(2) * epsilon; + } + + template <typename valType> + GLM_FUNC_QUALIFIER bool isNull + ( + detail::tvec2<valType> const & v, + valType const & epsilon + ) + { + return length(v) <= epsilon; + } + + template <typename valType> + GLM_FUNC_QUALIFIER bool isNull + ( + detail::tvec3<valType> const & v, + valType const & epsilon + ) + { + return length(v) <= epsilon; + } + + template <typename valType> + GLM_FUNC_QUALIFIER bool isNull + ( + detail::tvec4<valType> const & v, + valType const & epsilon + ) + { + return length(v) <= epsilon; + } + + template <typename T> + GLM_FUNC_QUALIFIER bool isCompNull + ( + T const & s, + T const & epsilon + ) + { + return abs(s) < epsilon; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<bool> isCompNull + ( + detail::tvec2<T> const & v, + T const & epsilon) + { + return detail::tvec2<bool>( + (abs(v.x) < epsilon), + (abs(v.y) < epsilon)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<bool> isCompNull + ( + detail::tvec3<T> const & v, + T const & epsilon + ) + { + return detail::tvec3<bool>( + abs(v.x) < epsilon, + abs(v.y) < epsilon, + abs(v.z) < epsilon); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<bool> isCompNull + ( + detail::tvec4<T> const & v, + T const & epsilon + ) + { + return detail::tvec4<bool>( + abs(v.x) < epsilon, + abs(v.y) < epsilon, + abs(v.z) < epsilon, + abs(v.w) < epsilon); + } + + template <typename genType> + GLM_FUNC_QUALIFIER bool areOrthonormal + ( + genType const & v0, + genType const & v1, + typename genType::value_type const & epsilon + ) + { + return isNormalized(v0, epsilon) && isNormalized(v1, epsilon) && (abs(dot(v0, v1)) <= epsilon); + } + +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/verbose_operator.hpp b/include/gal/opengl/glm/gtx/verbose_operator.hpp new file mode 100644 index 0000000..0a2f0e3 --- /dev/null +++ b/include/gal/opengl/glm/gtx/verbose_operator.hpp @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_verbose_operator +/// @file glm/gtx/verbose_operator.hpp +/// @date 2007-05-21 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_verbose_operator GLM_GTX_verbose_operator +/// @ingroup gtx +/// +/// @brief Use words to replace operators +/// +/// <glm/gtx/verbose_operator.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_verbose_operator +#define GLM_GTX_verbose_operator GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_verbose_operator extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_verbose_operator + /// @{ + + //! Addition of two values + //! From GLM_GTX_verbose_operator extension. + template <typename genTypeT, typename genTypeU> + genTypeT add(genTypeT const & a, genTypeU const & b); + + //! Substration of two values + //! From GLM_GTX_verbose_operator extension. + template <typename genTypeT, typename genTypeU> + genTypeT sub(genTypeT const & a, genTypeU const & b); + + //! Multiplication of two values + //! From GLM_GTX_verbose_operator extension. + template <typename genTypeT, typename genTypeU> + genTypeT mul(genTypeT const & a, genTypeU const & b); + + //! Division of two values + //! From GLM_GTX_verbose_operator extension. + template <typename genTypeT, typename genTypeU> + genTypeT div(genTypeT const & a, genTypeU const & b); + + //! Multiplication and addition of three values + //! From GLM_GTX_verbose_operator extension. + template <typename genTypeT, typename genTypeU, typename genTypeV> + genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c); + + /// @} +}// namespace glm + +#include "verbose_operator.inl" + +#endif//GLM_GTX_verbose_operator diff --git a/include/gal/opengl/glm/gtx/verbose_operator.inl b/include/gal/opengl/glm/gtx/verbose_operator.inl new file mode 100644 index 0000000..468bdd4 --- /dev/null +++ b/include/gal/opengl/glm/gtx/verbose_operator.inl @@ -0,0 +1,124 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2006-04-20 +// Updated : 2008-09-29 +// Licence : This source is under MIT License +// File : glm/gtx/verbose_operator.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER genType add(genType const & a, genType const & b) + { + return a + b; + } + + template <typename genType> + GLM_FUNC_QUALIFIER genType sub(genType const & a, genType const & b) + { + return a - b; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat2x2<T> mul + ( + detail::tmat2x2<T> const & a, + detail::tmat2x2<T> const & b + ) + { + return a * b; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat3x3<T> mul + ( + detail::tmat3x3<T> const & a, + detail::tmat3x3<T> const & b + ) + { + return a * b; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tmat4x4<T> mul + ( + detail::tmat4x4<T> const & a, + detail::tmat4x4<T> const & b + ) + { + return a * b; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> mul + ( + detail::tmat2x2<T> const & m, + detail::tvec2<T> const & v + ) + { + return m * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> mul + ( + detail::tmat3x3<T> const & m, + detail::tvec3<T> const & v) + { + return m * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> mul + ( + detail::tmat4x4<T> const & m, + detail::tvec4<T> const & v + ) + { + return m * v; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> mul + ( + detail::tvec2<T> const & v, + detail::tmat2x2<T> const & m + ) + { + return v * m; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> mul + ( + detail::tvec3<T> const & v, + detail::tmat3x3<T> const & m + ) + { + return v * m; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> mul + ( + detail::tvec4<T> const & v, + detail::tmat4x4<T> const & m + ) + { + return v * m; + } + + template <typename genType> + GLM_FUNC_QUALIFIER genType div(genType const & a, genType const & b) + { + return a / b; + } + + template <typename genTypeT, typename genTypeU, typename genTypeV> + GLM_FUNC_QUALIFIER genTypeT mad(genTypeT const & a, genTypeU const & b, genTypeV const & c) + { + return a * b + c; + } +}//namespace glm diff --git a/include/gal/opengl/glm/gtx/wrap.hpp b/include/gal/opengl/glm/gtx/wrap.hpp new file mode 100644 index 0000000..a671327 --- /dev/null +++ b/include/gal/opengl/glm/gtx/wrap.hpp @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////////////// +/// OpenGL Mathematics (glm.g-truc.net) +/// +/// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/// Permission is hereby granted, free of charge, to any person obtaining a copy +/// of this software and associated documentation files (the "Software"), to deal +/// in the Software without restriction, including without limitation the rights +/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/// copies of the Software, and to permit persons to whom the Software is +/// furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +/// THE SOFTWARE. +/// +/// @ref gtx_wrap +/// @file glm/gtx/wrap.hpp +/// @date 2009-11-25 / 2011-06-07 +/// @author Christophe Riccio +/// +/// @see core (dependence) +/// +/// @defgroup gtx_wrap GLM_GTX_wrap +/// @ingroup gtx +/// +/// @brief Wrapping mode of texture coordinates. +/// +/// <glm/gtx/wrap.hpp> need to be included to use these functionalities. +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLM_GTX_wrap +#define GLM_GTX_wrap GLM_VERSION + +// Dependency: +#include "../glm.hpp" + +#if(defined(GLM_MESSAGES) && !defined(glm_ext)) +# pragma message("GLM: GLM_GTX_wrap extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_wrap + /// @{ + + //! Simulate GL_CLAMP OpenGL wrap mode + //! From GLM_GTX_wrap extension. + template <typename genType> + genType clamp(genType const & Texcoord); + + //! Simulate GL_REPEAT OpenGL wrap mode + //! From GLM_GTX_wrap extension. + template <typename genType> + genType repeat(genType const & Texcoord); + + //! Simulate GL_MIRROR_REPEAT OpenGL wrap mode + //! From GLM_GTX_wrap extension. + template <typename genType> + genType mirrorRepeat(genType const & Texcoord); + + /// @} +}// namespace glm + +#include "wrap.inl" + +#endif//GLM_GTX_wrap diff --git a/include/gal/opengl/glm/gtx/wrap.inl b/include/gal/opengl/glm/gtx/wrap.inl new file mode 100644 index 0000000..41c7d47 --- /dev/null +++ b/include/gal/opengl/glm/gtx/wrap.inl @@ -0,0 +1,165 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2009-11-25 +// Updated : 2010-02-13 +// Licence : This source is under MIT License +// File : glm/gtx/wrap.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Dependency: +// - GLM core +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace glm +{ + template <typename genType> + GLM_FUNC_QUALIFIER genType clamp + ( + genType const & Texcoord + ) + { + return glm::clamp(Texcoord, genType(0), genType(1)); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> clamp + ( + detail::tvec2<T> const & Texcoord + ) + { + detail::tvec2<T> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + Result[i] = clamp(Texcoord[i]); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> clamp + ( + detail::tvec3<T> const & Texcoord + ) + { + detail::tvec3<T> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + Result[i] = clamp(Texcoord[i]); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> clamp + ( + detail::tvec4<T> const & Texcoord + ) + { + detail::tvec4<T> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + Result[i] = clamp(Texcoord[i]); + return Result; + } + + //////////////////////// + // repeat + + template <typename genType> + GLM_FUNC_QUALIFIER genType repeat + ( + genType const & Texcoord + ) + { + return glm::fract(Texcoord); + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> repeat + ( + detail::tvec2<T> const & Texcoord + ) + { + detail::tvec2<T> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + Result[i] = repeat(Texcoord[i]); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> repeat + ( + detail::tvec3<T> const & Texcoord + ) + { + detail::tvec3<T> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + Result[i] = repeat(Texcoord[i]); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> repeat + ( + detail::tvec4<T> const & Texcoord + ) + { + detail::tvec4<T> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + Result[i] = repeat(Texcoord[i]); + return Result; + } + + //////////////////////// + // mirrorRepeat + + template <typename genType> + GLM_FUNC_QUALIFIER genType mirrorRepeat + ( + genType const & Texcoord + ) + { + genType const Clamp = genType(int(glm::floor(Texcoord)) % 2); + genType const Floor = glm::floor(Texcoord); + genType const Rest = Texcoord - Floor; + genType const Mirror = Clamp + Rest; + + genType Out; + if(Mirror >= genType(1)) + Out = genType(1) - Rest; + else + Out = Rest; + return Out; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec2<T> mirrorRepeat + ( + detail::tvec2<T> const & Texcoord + ) + { + detail::tvec2<T> Result; + for(typename detail::tvec2<T>::size_type i = 0; i < detail::tvec2<T>::value_size(); ++i) + Result[i] = mirrorRepeat(Texcoord[i]); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec3<T> mirrorRepeat + ( + detail::tvec3<T> const & Texcoord + ) + { + detail::tvec3<T> Result; + for(typename detail::tvec3<T>::size_type i = 0; i < detail::tvec3<T>::value_size(); ++i) + Result[i] = mirrorRepeat(Texcoord[i]); + return Result; + } + + template <typename T> + GLM_FUNC_QUALIFIER detail::tvec4<T> mirrorRepeat + ( + detail::tvec4<T> const & Texcoord + ) + { + detail::tvec4<T> Result; + for(typename detail::tvec4<T>::size_type i = 0; i < detail::tvec4<T>::value_size(); ++i) + Result[i] = mirrorRepeat(Texcoord[i]); + return Result; + } +}//namespace glm |