Fixed merge with 0.9.5
This commit is contained in:
commit
7659e901c9
@ -1,224 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// 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 core
|
|
||||||
/// @file glm/core/func_exponential.inl
|
|
||||||
/// @date 2008-08-03 / 2011-06-15
|
|
||||||
/// @author Christophe Riccio
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "func_vector_relational.hpp"
|
|
||||||
#include "_vectorize.hpp"
|
|
||||||
#include <limits>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace glm
|
|
||||||
{
|
|
||||||
// pow
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType pow
|
|
||||||
(
|
|
||||||
genType const & x,
|
|
||||||
genType const & y
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'pow' only accept floating-point inputs");
|
|
||||||
|
|
||||||
return std::pow(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC_VEC(pow)
|
|
||||||
|
|
||||||
// exp
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType exp
|
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'exp' only accept floating-point inputs");
|
|
||||||
|
|
||||||
return std::exp(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC(exp)
|
|
||||||
|
|
||||||
// log
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType log
|
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'log' only accept floating-point inputs");
|
|
||||||
|
|
||||||
return std::log(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC(log)
|
|
||||||
|
|
||||||
//exp2, ln2 = 0.69314718055994530941723212145818f
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType exp2
|
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'exp2' only accept floating-point inputs");
|
|
||||||
|
|
||||||
return std::exp(static_cast<genType>(0.69314718055994530941723212145818) * x);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC(exp2)
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template <bool isFloat>
|
|
||||||
struct compute_log2
|
|
||||||
{
|
|
||||||
template <typename T>
|
|
||||||
T operator() (T const & Value) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct compute_log2<true>
|
|
||||||
{
|
|
||||||
template <typename T>
|
|
||||||
T operator() (T const & Value) const
|
|
||||||
{
|
|
||||||
return static_cast<T>(::std::log(Value)) * static_cast<T>(1.4426950408889634073599246810019);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}//namespace detail
|
|
||||||
|
|
||||||
// log2, ln2 = 0.69314718055994530941723212145818f
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType log2
|
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || std::numeric_limits<genType>::is_integer,
|
|
||||||
"GLM core 'log2' only accept floating-point inputs. Include <glm/gtx/integer.hpp> for additional integer support.");
|
|
||||||
|
|
||||||
assert(x > genType(0)); // log2 is only defined on the range (0, inf]
|
|
||||||
return detail::compute_log2<std::numeric_limits<genType>::is_iec559>()(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC(log2)
|
|
||||||
|
|
||||||
// sqrt
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType sqrt
|
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'sqrt' only accept floating-point inputs");
|
|
||||||
|
|
||||||
assert(x >= genType(0));
|
|
||||||
|
|
||||||
return std::sqrt(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC(sqrt)
|
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER genType inversesqrt
|
|
||||||
(
|
|
||||||
genType const & x
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GLM_STATIC_ASSERT(
|
|
||||||
std::numeric_limits<genType>::is_iec559,
|
|
||||||
"'inversesqrt' only accept floating-point inputs");
|
|
||||||
|
|
||||||
assert(x > genType(0));
|
|
||||||
|
|
||||||
return genType(1) / std::sqrt(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
VECTORIZE_VEC(inversesqrt)
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template <typename genType, typename genUType>
|
|
||||||
genType fastInversesqrt(genType const & v)
|
|
||||||
{
|
|
||||||
genType tmp(v);
|
|
||||||
genType xhalf(tmp * genType(0.5f));
|
|
||||||
genUType i = *reinterpret_cast<genUType*>(const_cast<genType*>(&v));
|
|
||||||
i = genUType(0x5f375a86) - (i >> genUType(1));
|
|
||||||
// tmp = *reinterpret_cast<genType*>(&i);
|
|
||||||
{
|
|
||||||
genType* ptr(reinterpret_cast<genType*>(&i));
|
|
||||||
tmp = *ptr;
|
|
||||||
}
|
|
||||||
tmp = tmp * (genType(1.5f) - xhalf * tmp * tmp);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
GLM_FUNC_QUALIFIER lowp_vec1 inversesqrt(lowp_vec1 const & v)
|
|
||||||
{
|
|
||||||
assert(glm::all(glm::greaterThan(v, lowp_vec1(0))));
|
|
||||||
|
|
||||||
return detail::fastInversesqrt<lowp_vec1, uint>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
GLM_FUNC_QUALIFIER lowp_vec2 inversesqrt(lowp_vec2 const & v)
|
|
||||||
{
|
|
||||||
assert(glm::all(glm::greaterThan(v, lowp_vec2(0))));
|
|
||||||
|
|
||||||
return detail::fastInversesqrt<lowp_vec2, lowp_uvec2>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
GLM_FUNC_QUALIFIER lowp_vec3 inversesqrt(lowp_vec3 const & v)
|
|
||||||
{
|
|
||||||
assert(glm::all(glm::greaterThan(v, lowp_vec3(0))));
|
|
||||||
|
|
||||||
return detail::fastInversesqrt<lowp_vec3, lowp_uvec3>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
GLM_FUNC_QUALIFIER lowp_vec4 inversesqrt(lowp_vec4 const & v)
|
|
||||||
{
|
|
||||||
assert(glm::all(glm::greaterThan(v, lowp_vec4(0))));
|
|
||||||
|
|
||||||
return detail::fastInversesqrt<lowp_vec4, lowp_uvec4>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace glm
|
|
@ -51,6 +51,7 @@
|
|||||||
#include "../vec2.hpp"
|
#include "../vec2.hpp"
|
||||||
#include "../vec3.hpp"
|
#include "../vec3.hpp"
|
||||||
#include "../vec4.hpp"
|
#include "../vec4.hpp"
|
||||||
|
#include "../gtc/constants.hpp"
|
||||||
|
|
||||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||||
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
|
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
|
||||||
@ -164,8 +165,8 @@ namespace glm
|
|||||||
/// @param far
|
/// @param far
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
/// @see gtc_matrix_transform
|
/// @see gtc_matrix_transform
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_DECL detail::tmat4x4<T, P> frustum(
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> frustum(
|
||||||
T const & left,
|
T const & left,
|
||||||
T const & right,
|
T const & right,
|
||||||
T const & bottom,
|
T const & bottom,
|
||||||
@ -181,8 +182,8 @@ namespace glm
|
|||||||
/// @param far
|
/// @param far
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
/// @see gtc_matrix_transform
|
/// @see gtc_matrix_transform
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_DECL detail::tmat4x4<T, P> perspective(
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> perspective(
|
||||||
T const & fovy,
|
T const & fovy,
|
||||||
T const & aspect,
|
T const & aspect,
|
||||||
T const & near,
|
T const & near,
|
||||||
@ -197,8 +198,8 @@ namespace glm
|
|||||||
/// @param far
|
/// @param far
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
/// @see gtc_matrix_transform
|
/// @see gtc_matrix_transform
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_DECL detail::tmat4x4<T, P> perspectiveFov(
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> perspectiveFov(
|
||||||
T const & fov,
|
T const & fov,
|
||||||
T const & width,
|
T const & width,
|
||||||
T const & height,
|
T const & height,
|
||||||
@ -212,8 +213,8 @@ namespace glm
|
|||||||
/// @param near
|
/// @param near
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
/// @see gtc_matrix_transform
|
/// @see gtc_matrix_transform
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_DECL detail::tmat4x4<T, P> infinitePerspective(
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> infinitePerspective(
|
||||||
T fovy, T aspect, T near);
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||||
@ -223,10 +224,21 @@ namespace glm
|
|||||||
/// @param near
|
/// @param near
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
/// @see gtc_matrix_transform
|
/// @see gtc_matrix_transform
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_DECL detail::tmat4x4<T, P> tweakedInfinitePerspective(
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||||
T fovy, T aspect, T near);
|
T fovy, T aspect, T near);
|
||||||
|
|
||||||
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||||
|
///
|
||||||
|
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
|
/// @param aspect
|
||||||
|
/// @param near
|
||||||
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
/// @see gtc_matrix_transform
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||||
|
T fovy, T aspect, T near, T ep);
|
||||||
|
|
||||||
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
/// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
|
||||||
///
|
///
|
||||||
/// @param obj
|
/// @param obj
|
||||||
|
@ -167,7 +167,7 @@ namespace glm
|
|||||||
detail::tmat4x4<T, defaultp> Result(1);
|
detail::tmat4x4<T, defaultp> Result(1);
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
Result[2][2] = - T(2) / (zFar - zNear);
|
Result[2][2] = - static_cast<T>(2) / (zFar - zNear);
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
@ -186,93 +186,93 @@ namespace glm
|
|||||||
detail::tmat4x4<T, defaultp> Result(1);
|
detail::tmat4x4<T, defaultp> Result(1);
|
||||||
Result[0][0] = static_cast<T>(2) / (right - left);
|
Result[0][0] = static_cast<T>(2) / (right - left);
|
||||||
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
Result[1][1] = static_cast<T>(2) / (top - bottom);
|
||||||
Result[2][2] = - T(1);
|
Result[2][2] = - static_cast<T>(1);
|
||||||
Result[3][0] = - (right + left) / (right - left);
|
Result[3][0] = - (right + left) / (right - left);
|
||||||
Result[3][1] = - (top + bottom) / (top - bottom);
|
Result[3][1] = - (top + bottom) / (top - bottom);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> frustum
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> frustum
|
||||||
(
|
(
|
||||||
valType const & left,
|
T const & left,
|
||||||
valType const & right,
|
T const & right,
|
||||||
valType const & bottom,
|
T const & bottom,
|
||||||
valType const & top,
|
T const & top,
|
||||||
valType const & nearVal,
|
T const & nearVal,
|
||||||
valType const & farVal
|
T const & farVal
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tmat4x4<valType, defaultp> Result(0);
|
detail::tmat4x4<T, defaultp> Result(0);
|
||||||
Result[0][0] = (valType(2) * nearVal) / (right - left);
|
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
|
||||||
Result[1][1] = (valType(2) * nearVal) / (top - bottom);
|
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
|
||||||
Result[2][0] = (right + left) / (right - left);
|
Result[2][0] = (right + left) / (right - left);
|
||||||
Result[2][1] = (top + bottom) / (top - bottom);
|
Result[2][1] = (top + bottom) / (top - bottom);
|
||||||
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
|
||||||
Result[2][3] = valType(-1);
|
Result[2][3] = static_cast<T>(-1);
|
||||||
Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal);
|
Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspective
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> perspective
|
||||||
(
|
(
|
||||||
valType const & fovy,
|
T const & fovy,
|
||||||
valType const & aspect,
|
T const & aspect,
|
||||||
valType const & zNear,
|
T const & zNear,
|
||||||
valType const & zFar
|
T const & zFar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assert(aspect != valType(0));
|
assert(aspect != static_cast<T>(0));
|
||||||
assert(zFar != zNear);
|
assert(zFar != zNear);
|
||||||
|
|
||||||
#ifdef GLM_FORCE_RADIANS
|
#ifdef GLM_FORCE_RADIANS
|
||||||
valType const rad = fovy;
|
T const rad = fovy;
|
||||||
#else
|
#else
|
||||||
# pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
# pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||||
valType const rad = glm::radians(fovy);
|
T const rad = glm::radians(fovy);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
valType tanHalfFovy = tan(rad / valType(2));
|
T tanHalfFovy = tan(rad / static_cast<T>(2));
|
||||||
|
|
||||||
detail::tmat4x4<valType, defaultp> Result(valType(0));
|
detail::tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||||
Result[0][0] = valType(1) / (aspect * tanHalfFovy);
|
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
|
||||||
Result[1][1] = valType(1) / (tanHalfFovy);
|
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
Result[2][3] = - valType(1);
|
Result[2][3] = - static_cast<T>(1);
|
||||||
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspectiveFov
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> perspectiveFov
|
||||||
(
|
(
|
||||||
valType const & fov,
|
T const & fov,
|
||||||
valType const & width,
|
T const & width,
|
||||||
valType const & height,
|
T const & height,
|
||||||
valType const & zNear,
|
T const & zNear,
|
||||||
valType const & zFar
|
T const & zFar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assert(width > valType(0));
|
assert(width > static_cast<T>(0));
|
||||||
assert(height > valType(0));
|
assert(height > static_cast<T>(0));
|
||||||
assert(fov > valType(0));
|
assert(fov > static_cast<T>(0));
|
||||||
|
|
||||||
#ifdef GLM_FORCE_RADIANS
|
#ifdef GLM_FORCE_RADIANS
|
||||||
valType rad = fov;
|
T rad = fov;
|
||||||
#else
|
#else
|
||||||
# pragma message("GLM: perspectiveFov function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
# pragma message("GLM: perspectiveFov function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
|
||||||
valType rad = glm::radians(fov);
|
T rad = glm::radians(fov);
|
||||||
#endif
|
#endif
|
||||||
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
|
T h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
|
||||||
valType w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
T w = h * height / width; ///todo max(width , Height) / min(width , Height)?
|
||||||
|
|
||||||
detail::tmat4x4<valType, defaultp> Result(valType(0));
|
detail::tmat4x4<T, defaultp> Result(static_cast<T>(0));
|
||||||
Result[0][0] = w;
|
Result[0][0] = w;
|
||||||
Result[1][1] = h;
|
Result[1][1] = h;
|
||||||
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
|
||||||
Result[2][3] = - valType(1);
|
Result[2][3] = - static_cast<T>(1);
|
||||||
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
|
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,12 +304,14 @@ namespace glm
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||||
(
|
(
|
||||||
T fovy,
|
T fovy,
|
||||||
T aspect,
|
T aspect,
|
||||||
T zNear
|
T zNear,
|
||||||
|
T ep
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef GLM_FORCE_RADIANS
|
#ifdef GLM_FORCE_RADIANS
|
||||||
@ -324,14 +326,25 @@ namespace glm
|
|||||||
T top = range;
|
T top = range;
|
||||||
|
|
||||||
detail::tmat4x4<T, defaultp> Result(T(0));
|
detail::tmat4x4<T, defaultp> Result(T(0));
|
||||||
Result[0][0] = (T(2) * zNear) / (right - left);
|
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||||
Result[1][1] = (T(2) * zNear) / (top - bottom);
|
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||||
Result[2][2] = static_cast<T>(0.0001) - T(1);
|
Result[2][2] = ep - static_cast<T>(1);
|
||||||
Result[2][3] = static_cast<T>(-1);
|
Result[2][3] = static_cast<T>(-1);
|
||||||
Result[3][2] = - (T(0.0001) - T(2)) * zNear;
|
Result[3][2] = (ep - static_cast<T>(2)) * zNear;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
|
||||||
|
(
|
||||||
|
T fovy,
|
||||||
|
T aspect,
|
||||||
|
T zNear
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon<T>());
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, typename U, precision P>
|
template <typename T, typename U, precision P>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> project
|
GLM_FUNC_QUALIFIER detail::tvec3<T, P> project
|
||||||
(
|
(
|
||||||
|
@ -62,7 +62,7 @@ namespace glm
|
|||||||
/// @see uint32 packUnorm4x8(vec4 const & v)
|
/// @see uint32 packUnorm4x8(vec4 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL uint8 packUnorm1x8(float const & v);
|
GLM_FUNC_DECL uint8 packUnorm1x8(float v);
|
||||||
|
|
||||||
/// Convert a single 8-bit integer to a normalized floating-point value.
|
/// Convert a single 8-bit integer to a normalized floating-point value.
|
||||||
///
|
///
|
||||||
@ -74,7 +74,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackUnorm4x8(uint32 p)
|
/// @see vec4 unpackUnorm4x8(uint32 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL float unpackUnorm1x8(uint8 const & p);
|
GLM_FUNC_DECL float unpackUnorm1x8(uint8 p);
|
||||||
|
|
||||||
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
||||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||||
@ -106,7 +106,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackUnorm4x8(uint32 p)
|
/// @see vec4 unpackUnorm4x8(uint32 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 const & p);
|
GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 p);
|
||||||
|
|
||||||
/// First, converts the normalized floating-point value v into 8-bit integer value.
|
/// First, converts the normalized floating-point value v into 8-bit integer value.
|
||||||
/// Then, the results are packed into the returned 8-bit unsigned integer.
|
/// Then, the results are packed into the returned 8-bit unsigned integer.
|
||||||
@ -119,7 +119,7 @@ namespace glm
|
|||||||
/// @see uint32 packSnorm4x8(vec4 const & v)
|
/// @see uint32 packSnorm4x8(vec4 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL uint8 packSnorm1x8(float const & s);
|
GLM_FUNC_DECL uint8 packSnorm1x8(float s);
|
||||||
|
|
||||||
/// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers.
|
/// First, unpacks a single 8-bit unsigned integer p into a single 8-bit signed integers.
|
||||||
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
||||||
@ -132,7 +132,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackSnorm4x8(uint32 p)
|
/// @see vec4 unpackSnorm4x8(uint32 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL float unpackSnorm1x8(uint8 const & p);
|
GLM_FUNC_DECL float unpackSnorm1x8(uint8 p);
|
||||||
|
|
||||||
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
/// First, converts each component of the normalized floating-point value v into 8-bit integer values.
|
||||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||||
@ -164,7 +164,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackSnorm4x8(uint32 p)
|
/// @see vec4 unpackSnorm4x8(uint32 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 const & p);
|
GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 p);
|
||||||
|
|
||||||
/// First, converts the normalized floating-point value v into a 16-bit integer value.
|
/// First, converts the normalized floating-point value v into a 16-bit integer value.
|
||||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||||
@ -177,7 +177,7 @@ namespace glm
|
|||||||
/// @see uint64 packSnorm4x16(vec4 const & v)
|
/// @see uint64 packSnorm4x16(vec4 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL uint16 packUnorm1x16(float const & v);
|
GLM_FUNC_DECL uint16 packUnorm1x16(float v);
|
||||||
|
|
||||||
/// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers.
|
/// First, unpacks a single 16-bit unsigned integer p into a of 16-bit unsigned integers.
|
||||||
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
/// Then, the value is converted to a normalized floating-point value to generate the returned scalar.
|
||||||
@ -190,7 +190,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackUnorm4x16(uint64 p)
|
/// @see vec4 unpackUnorm4x16(uint64 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL float unpackUnorm1x16(uint16 const & p);
|
GLM_FUNC_DECL float unpackUnorm1x16(uint16 p);
|
||||||
|
|
||||||
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
|
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
|
||||||
/// Then, the results are packed into the returned 64-bit unsigned integer.
|
/// Then, the results are packed into the returned 64-bit unsigned integer.
|
||||||
@ -222,7 +222,7 @@ namespace glm
|
|||||||
/// @see vec2 unpackUnorm2x16(uint32 p)
|
/// @see vec2 unpackUnorm2x16(uint32 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 const & p);
|
GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 p);
|
||||||
|
|
||||||
/// First, converts the normalized floating-point value v into 16-bit integer value.
|
/// First, converts the normalized floating-point value v into 16-bit integer value.
|
||||||
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
/// Then, the results are packed into the returned 16-bit unsigned integer.
|
||||||
@ -235,7 +235,7 @@ namespace glm
|
|||||||
/// @see uint64 packSnorm4x16(vec4 const & v)
|
/// @see uint64 packSnorm4x16(vec4 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL uint16 packSnorm1x16(float const & v);
|
GLM_FUNC_DECL uint16 packSnorm1x16(float v);
|
||||||
|
|
||||||
/// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers.
|
/// First, unpacks a single 16-bit unsigned integer p into a single 16-bit signed integers.
|
||||||
/// Then, each component is converted to a normalized floating-point value to generate the returned scalar.
|
/// Then, each component is converted to a normalized floating-point value to generate the returned scalar.
|
||||||
@ -248,7 +248,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackSnorm4x16(uint64 p)
|
/// @see vec4 unpackSnorm4x16(uint64 p)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm1x16.xml">GLSL unpackSnorm4x8 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm1x16.xml">GLSL unpackSnorm4x8 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL float unpackSnorm1x16(uint16 const & p);
|
GLM_FUNC_DECL float unpackSnorm1x16(uint16 p);
|
||||||
|
|
||||||
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
|
/// First, converts each component of the normalized floating-point value v into 16-bit integer values.
|
||||||
/// Then, the results are packed into the returned 64-bit unsigned integer.
|
/// Then, the results are packed into the returned 64-bit unsigned integer.
|
||||||
@ -291,7 +291,7 @@ namespace glm
|
|||||||
/// @see uint64 packHalf4x16(vec4 const & v)
|
/// @see uint64 packHalf4x16(vec4 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packHalf2x16.xml">GLSL packHalf2x16 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL uint16 packHalf1x16(float const & v);
|
GLM_FUNC_DECL uint16 packHalf1x16(float v);
|
||||||
|
|
||||||
/// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value,
|
/// Returns a floating-point scalar with components obtained by unpacking a 16-bit unsigned integer into a 16-bit value,
|
||||||
/// interpreted as a 16-bit floating-point number according to the OpenGL Specification,
|
/// interpreted as a 16-bit floating-point number according to the OpenGL Specification,
|
||||||
@ -302,7 +302,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackHalf4x16(uint64 const & v)
|
/// @see vec4 unpackHalf4x16(uint64 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL float unpackHalf1x16(uint16 const & v);
|
GLM_FUNC_DECL float unpackHalf1x16(uint16 v);
|
||||||
|
|
||||||
/// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector
|
/// Returns an unsigned integer obtained by converting the components of a four-component floating-point vector
|
||||||
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
/// to the 16-bit floating-point representation found in the OpenGL Specification,
|
||||||
@ -328,7 +328,7 @@ namespace glm
|
|||||||
/// @see vec2 unpackHalf2x16(uint32 const & v)
|
/// @see vec2 unpackHalf2x16(uint32 const & v)
|
||||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackHalf2x16.xml">GLSL unpackHalf2x16 man page</a>
|
||||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions</a>
|
||||||
GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 const & p);
|
GLM_FUNC_DECL vec4 unpackHalf4x16(uint64 p);
|
||||||
|
|
||||||
/// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector
|
/// Returns an unsigned integer obtained by converting the components of a four-component signed integer vector
|
||||||
/// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification,
|
/// to the 10-10-10-2-bit signed integer representation found in the OpenGL Specification,
|
||||||
@ -352,7 +352,7 @@ namespace glm
|
|||||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
||||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
||||||
GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 const & p);
|
GLM_FUNC_DECL ivec4 unpackI3x10_1x2(uint32 p);
|
||||||
|
|
||||||
/// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector
|
/// Returns an unsigned integer obtained by converting the components of a four-component unsigned integer vector
|
||||||
/// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification,
|
/// to the 10-10-10-2-bit unsigned integer representation found in the OpenGL Specification,
|
||||||
@ -376,7 +376,7 @@ namespace glm
|
|||||||
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
/// @see uint32 packU3x10_1x2(uvec4 const & v)
|
||||||
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
/// @see vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
||||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
/// @see uvec4 unpackI3x10_1x2(uint32 const & p);
|
||||||
GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 const & p);
|
GLM_FUNC_DECL uvec4 unpackU3x10_1x2(uint32 p);
|
||||||
|
|
||||||
/// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values.
|
/// First, converts the first three components of the normalized floating-point value v into 10-bit signed integer values.
|
||||||
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values.
|
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed integer values.
|
||||||
@ -411,7 +411,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackUnorm3x10_1x2(uint32 const & p))
|
/// @see vec4 unpackUnorm3x10_1x2(uint32 const & p))
|
||||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
||||||
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
||||||
GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 const & p);
|
GLM_FUNC_DECL vec4 unpackSnorm3x10_1x2(uint32 p);
|
||||||
|
|
||||||
/// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values.
|
/// First, converts the first three components of the normalized floating-point value v into 10-bit unsigned integer values.
|
||||||
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values.
|
/// Then, converts the forth component of the normalized floating-point value v into 2-bit signed uninteger values.
|
||||||
@ -446,7 +446,7 @@ namespace glm
|
|||||||
/// @see vec4 unpackInorm3x10_1x2(uint32 const & p))
|
/// @see vec4 unpackInorm3x10_1x2(uint32 const & p))
|
||||||
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
/// @see uvec4 unpackI3x10_1x2(uint32 const & p)
|
||||||
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
/// @see uvec4 unpackU3x10_1x2(uint32 const & p)
|
||||||
GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 const & p);
|
GLM_FUNC_DECL vec4 unpackUnorm3x10_1x2(uint32 p);
|
||||||
|
|
||||||
/// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
|
/// First, converts the first two components of the normalized floating-point value v into 11-bit signless floating-point values.
|
||||||
/// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
|
/// Then, converts the third component of the normalized floating-point value v into a 10-bit signless floating-point value.
|
||||||
@ -467,7 +467,7 @@ namespace glm
|
|||||||
///
|
///
|
||||||
/// @see gtc_packing
|
/// @see gtc_packing
|
||||||
/// @see uint32 packF2x11_1x10(vec3 const & v)
|
/// @see uint32 packF2x11_1x10(vec3 const & v)
|
||||||
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 const & p);
|
GLM_FUNC_DECL vec3 unpackF2x11_1x10(uint32 p);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
}// namespace glm
|
}// namespace glm
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
#include "../vec3.hpp"
|
#include "../vec3.hpp"
|
||||||
#include "../vec4.hpp"
|
#include "../vec4.hpp"
|
||||||
#include "../detail/type_half.hpp"
|
#include "../detail/type_half.hpp"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace glm{
|
namespace glm{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 const & f)
|
GLM_FUNC_QUALIFIER glm::uint16 float2half(glm::uint32 f)
|
||||||
{
|
{
|
||||||
// 10 bits => EE EEEFFFFF
|
// 10 bits => EE EEEFFFFF
|
||||||
// 11 bits => EEE EEFFFFFF
|
// 11 bits => EEE EEFFFFFF
|
||||||
@ -53,7 +54,7 @@ namespace detail
|
|||||||
((f >> 13) & 0x03ff); // Mantissa
|
((f >> 13) & 0x03ff); // Mantissa
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 const & f)
|
GLM_FUNC_QUALIFIER glm::uint32 float2packed11(glm::uint32 f)
|
||||||
{
|
{
|
||||||
// 10 bits => EE EEEFFFFF
|
// 10 bits => EE EEEFFFFF
|
||||||
// 11 bits => EEE EEFFFFFF
|
// 11 bits => EEE EEFFFFFF
|
||||||
@ -71,7 +72,7 @@ namespace detail
|
|||||||
((f >> 17) & 0x003f); // Mantissa
|
((f >> 17) & 0x003f); // Mantissa
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 const & p)
|
GLM_FUNC_QUALIFIER glm::uint32 packed11ToFloat(glm::uint32 p)
|
||||||
{
|
{
|
||||||
// 10 bits => EE EEEFFFFF
|
// 10 bits => EE EEEFFFFF
|
||||||
// 11 bits => EEE EEFFFFFF
|
// 11 bits => EEE EEFFFFFF
|
||||||
@ -89,7 +90,7 @@ namespace detail
|
|||||||
((p & 0x003f) << 17); // Mantissa
|
((p & 0x003f) << 17); // Mantissa
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 const & f)
|
GLM_FUNC_QUALIFIER glm::uint32 float2packed10(glm::uint32 f)
|
||||||
{
|
{
|
||||||
// 10 bits => EE EEEFFFFF
|
// 10 bits => EE EEEFFFFF
|
||||||
// 11 bits => EEE EEFFFFFF
|
// 11 bits => EEE EEFFFFFF
|
||||||
@ -110,7 +111,7 @@ namespace detail
|
|||||||
((f >> 18) & 0x001f); // Mantissa
|
((f >> 18) & 0x001f); // Mantissa
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 const & p)
|
GLM_FUNC_QUALIFIER glm::uint32 packed10ToFloat(glm::uint32 p)
|
||||||
{
|
{
|
||||||
// 10 bits => EE EEEFFFFF
|
// 10 bits => EE EEEFFFFF
|
||||||
// 11 bits => EEE EEFFFFFF
|
// 11 bits => EEE EEFFFFFF
|
||||||
@ -131,7 +132,7 @@ namespace detail
|
|||||||
((p & 0x001f) << 18); // Mantissa
|
((p & 0x001f) << 18); // Mantissa
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint const & h)
|
GLM_FUNC_QUALIFIER glm::uint half2float(glm::uint h)
|
||||||
{
|
{
|
||||||
return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
|
return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
|
||||||
}
|
}
|
||||||
@ -145,7 +146,14 @@ namespace detail
|
|||||||
else if(glm::isinf(x))
|
else if(glm::isinf(x))
|
||||||
return 0x1f << 6;
|
return 0x1f << 6;
|
||||||
|
|
||||||
return float2packed11(reinterpret_cast<uint&>(x));
|
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||||
|
uint Pack = 0;
|
||||||
|
memcpy(&Pack, &x, sizeof(Pack));
|
||||||
|
# else
|
||||||
|
uint Pack = reinterpret_cast<uint&>(x);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return float2packed11(Pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float packed11bitToFloat(glm::uint x)
|
GLM_FUNC_QUALIFIER float packed11bitToFloat(glm::uint x)
|
||||||
@ -157,8 +165,15 @@ namespace detail
|
|||||||
else if(x == (0x1f << 6))
|
else if(x == (0x1f << 6))
|
||||||
return ~0;//Inf
|
return ~0;//Inf
|
||||||
|
|
||||||
uint result = packed11ToFloat(x);
|
uint Result = packed11ToFloat(x);
|
||||||
return reinterpret_cast<float&>(result);
|
|
||||||
|
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||||
|
float Temp = 0;
|
||||||
|
memcpy(&Temp, &Result, sizeof(Temp));
|
||||||
|
return Temp;
|
||||||
|
# else
|
||||||
|
return reinterpret_cast<float&>(Result);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x)
|
GLM_FUNC_QUALIFIER glm::uint floatTo10bit(float x)
|
||||||
@ -170,7 +185,14 @@ namespace detail
|
|||||||
else if(glm::isinf(x))
|
else if(glm::isinf(x))
|
||||||
return 0x1f << 5;
|
return 0x1f << 5;
|
||||||
|
|
||||||
return float2packed10(reinterpret_cast<uint&>(x));
|
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||||
|
uint Pack = 0;
|
||||||
|
memcpy(&Pack, &x, sizeof(Pack));
|
||||||
|
# else
|
||||||
|
uint Pack = reinterpret_cast<uint&>(x);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
return float2packed10(Pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float packed10bitToFloat(glm::uint x)
|
GLM_FUNC_QUALIFIER float packed10bitToFloat(glm::uint x)
|
||||||
@ -182,8 +204,15 @@ namespace detail
|
|||||||
else if(x == (0x1f << 5))
|
else if(x == (0x1f << 5))
|
||||||
return ~0;//Inf
|
return ~0;//Inf
|
||||||
|
|
||||||
uint result = packed10ToFloat(x);
|
uint Result = packed10ToFloat(x);
|
||||||
return reinterpret_cast<float&>(result);
|
|
||||||
|
# if(GLM_COMPILER & GLM_COMPILER_GCC || GLM_COMPILER & GLM_COMPILER_CLANG)
|
||||||
|
float Temp = 0;
|
||||||
|
memcpy(&Temp, &Result, sizeof(Temp));
|
||||||
|
return Temp;
|
||||||
|
# else
|
||||||
|
return reinterpret_cast<float&>(Result);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z)
|
// GLM_FUNC_QUALIFIER glm::uint f11_f11_f10(float x, float y, float z)
|
||||||
@ -217,12 +246,12 @@ namespace detail
|
|||||||
|
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float const & v)
|
GLM_FUNC_QUALIFIER uint8 packUnorm1x8(float v)
|
||||||
{
|
{
|
||||||
return static_cast<uint8>(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
return static_cast<uint8>(round(clamp(v, 0.0f, 1.0f) * 255.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 const & p)
|
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 p)
|
||||||
{
|
{
|
||||||
float Unpack(static_cast<float>(p));
|
float Unpack(static_cast<float>(p));
|
||||||
return Unpack * static_cast<float>(0.0039215686274509803921568627451); // 1 / 255
|
return Unpack * static_cast<float>(0.0039215686274509803921568627451); // 1 / 255
|
||||||
@ -235,20 +264,20 @@ namespace detail
|
|||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 const & p)
|
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x8(uint16 p)
|
||||||
{
|
{
|
||||||
u8vec2* Unpacked = reinterpret_cast<u8vec2*>(const_cast<uint16*>(&p));
|
u8vec2* Unpacked = reinterpret_cast<u8vec2*>(const_cast<uint16*>(&p));
|
||||||
return vec2(*Unpacked) * float(0.0039215686274509803921568627451); // 1 / 255
|
return vec2(*Unpacked) * float(0.0039215686274509803921568627451); // 1 / 255
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float const & v)
|
GLM_FUNC_QUALIFIER uint8 packSnorm1x8(float v)
|
||||||
{
|
{
|
||||||
int8 Topack(static_cast<int8>(round(clamp(v ,-1.0f, 1.0f) * 127.0f)));
|
int8 Topack(static_cast<int8>(round(clamp(v ,-1.0f, 1.0f) * 127.0f)));
|
||||||
uint8* Packed = reinterpret_cast<uint8*>(&Topack);
|
uint8* Packed = reinterpret_cast<uint8*>(&Topack);
|
||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 const & p)
|
GLM_FUNC_QUALIFIER float unpackSnorm1x8(uint8 p)
|
||||||
{
|
{
|
||||||
float Unpack(static_cast<float>(*const_cast<uint8*>(&p)));
|
float Unpack(static_cast<float>(*const_cast<uint8*>(&p)));
|
||||||
return clamp(
|
return clamp(
|
||||||
@ -263,7 +292,7 @@ namespace detail
|
|||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 const & p)
|
GLM_FUNC_QUALIFIER vec2 unpackSnorm2x8(uint16 p)
|
||||||
{
|
{
|
||||||
i8vec2* Unpack = reinterpret_cast<i8vec2*>(const_cast<uint16*>(&p));
|
i8vec2* Unpack = reinterpret_cast<i8vec2*>(const_cast<uint16*>(&p));
|
||||||
return clamp(
|
return clamp(
|
||||||
@ -271,12 +300,12 @@ namespace detail
|
|||||||
-1.0f, 1.0f);
|
-1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float const & s)
|
GLM_FUNC_QUALIFIER uint16 packUnorm1x16(float s)
|
||||||
{
|
{
|
||||||
return static_cast<uint16>(round(clamp(s, 0.0f, 1.0f) * 65535.0f));
|
return static_cast<uint16>(round(clamp(s, 0.0f, 1.0f) * 65535.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 const & p)
|
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 p)
|
||||||
{
|
{
|
||||||
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
|
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
|
||||||
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||||
@ -289,20 +318,20 @@ namespace detail
|
|||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 const & p)
|
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x16(uint64 p)
|
||||||
{
|
{
|
||||||
u16vec4* Unpack = reinterpret_cast<u16vec4*>(const_cast<uint64*>(&p));
|
u16vec4* Unpack = reinterpret_cast<u16vec4*>(const_cast<uint64*>(&p));
|
||||||
return vec4(*Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
return vec4(*Unpack) * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float const & v)
|
GLM_FUNC_QUALIFIER uint16 packSnorm1x16(float v)
|
||||||
{
|
{
|
||||||
int16 Topack = static_cast<int16>(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
int16 Topack = static_cast<int16>(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
|
||||||
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 const & p)
|
GLM_FUNC_QUALIFIER float unpackSnorm1x16(uint16 p)
|
||||||
{
|
{
|
||||||
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
|
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
|
||||||
return clamp(
|
return clamp(
|
||||||
@ -317,7 +346,7 @@ namespace detail
|
|||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 const & p)
|
GLM_FUNC_QUALIFIER vec4 unpackSnorm4x16(uint64 p)
|
||||||
{
|
{
|
||||||
i16vec4* Unpack(reinterpret_cast<i16vec4*>(const_cast<uint64*>(&p)));
|
i16vec4* Unpack(reinterpret_cast<i16vec4*>(const_cast<uint64*>(&p)));
|
||||||
return clamp(
|
return clamp(
|
||||||
@ -325,14 +354,14 @@ namespace detail
|
|||||||
-1.0f, 1.0f);
|
-1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float const & v)
|
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float v)
|
||||||
{
|
{
|
||||||
int16 Topack = detail::toFloat16(v);
|
int16 Topack = detail::toFloat16(v);
|
||||||
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
|
||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 const & v)
|
GLM_FUNC_QUALIFIER float unpackHalf1x16(uint16 v)
|
||||||
{
|
{
|
||||||
int16* Unpack = reinterpret_cast<int16*>(const_cast<uint16*>(&v));
|
int16* Unpack = reinterpret_cast<int16*>(const_cast<uint16*>(&v));
|
||||||
return detail::toFloat32(*Unpack);
|
return detail::toFloat32(*Unpack);
|
||||||
@ -350,7 +379,7 @@ namespace detail
|
|||||||
return *Packed;
|
return *Packed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 const & v)
|
GLM_FUNC_QUALIFIER glm::vec4 unpackHalf4x16(uint64 v)
|
||||||
{
|
{
|
||||||
i16vec4* p = reinterpret_cast<i16vec4*>(const_cast<uint64*>(&v));
|
i16vec4* p = reinterpret_cast<i16vec4*>(const_cast<uint64*>(&v));
|
||||||
i16vec4 Unpack(*p);
|
i16vec4 Unpack(*p);
|
||||||
@ -372,7 +401,7 @@ namespace detail
|
|||||||
return Result.pack;
|
return Result.pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 const & v)
|
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v)
|
||||||
{
|
{
|
||||||
detail::i10i10i10i2 Unpack;
|
detail::i10i10i10i2 Unpack;
|
||||||
Unpack.pack = v;
|
Unpack.pack = v;
|
||||||
@ -393,7 +422,7 @@ namespace detail
|
|||||||
return Result.pack;
|
return Result.pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 const & v)
|
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v)
|
||||||
{
|
{
|
||||||
detail::u10u10u10u2 Unpack;
|
detail::u10u10u10u2 Unpack;
|
||||||
Unpack.pack = v;
|
Unpack.pack = v;
|
||||||
@ -414,7 +443,7 @@ namespace detail
|
|||||||
return Result.pack;
|
return Result.pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 const & v)
|
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 v)
|
||||||
{
|
{
|
||||||
detail::i10i10i10i2 Unpack;
|
detail::i10i10i10i2 Unpack;
|
||||||
Unpack.pack = v;
|
Unpack.pack = v;
|
||||||
@ -436,7 +465,7 @@ namespace detail
|
|||||||
return Result.pack;
|
return Result.pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 const & v)
|
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v)
|
||||||
{
|
{
|
||||||
detail::i10i10i10i2 Unpack;
|
detail::i10i10i10i2 Unpack;
|
||||||
Unpack.pack = v;
|
Unpack.pack = v;
|
||||||
@ -456,7 +485,7 @@ namespace detail
|
|||||||
((detail::floatTo10bit(v.z) & ((1 << 10) - 1)) << 22);
|
((detail::floatTo10bit(v.z) & ((1 << 10) - 1)) << 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 const & v)
|
GLM_FUNC_QUALIFIER vec3 unpackF2x11_1x10(uint32 v)
|
||||||
{
|
{
|
||||||
return vec3(
|
return vec3(
|
||||||
detail::packed11bitToFloat(v >> 0),
|
detail::packed11bitToFloat(v >> 0),
|
||||||
|
@ -199,10 +199,12 @@ namespace glm
|
|||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER float next_float(float const & x)
|
GLM_FUNC_QUALIFIER float next_float(float const & x)
|
||||||
{
|
{
|
||||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
|
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||||
return std::nextafter(x, std::numeric_limits<float>::max());
|
return std::nextafter(x, std::numeric_limits<float>::max());
|
||||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||||
return detail::nextafterf(x, FLT_MAX);
|
return detail::nextafterf(x, FLT_MAX);
|
||||||
|
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||||
|
return _nextafterf(x, FLT_MAX);
|
||||||
# else
|
# else
|
||||||
return nextafterf(x, FLT_MAX);
|
return nextafterf(x, FLT_MAX);
|
||||||
# endif
|
# endif
|
||||||
@ -211,7 +213,7 @@ namespace glm
|
|||||||
template <>
|
template <>
|
||||||
GLM_FUNC_QUALIFIER double next_float(double const & x)
|
GLM_FUNC_QUALIFIER double next_float(double const & x)
|
||||||
{
|
{
|
||||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
|
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||||
return std::nextafter(x, std::numeric_limits<double>::max());
|
return std::nextafter(x, std::numeric_limits<double>::max());
|
||||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||||
return detail::nextafter(x, std::numeric_limits<double>::max());
|
return detail::nextafter(x, std::numeric_limits<double>::max());
|
||||||
@ -231,10 +233,12 @@ namespace glm
|
|||||||
|
|
||||||
GLM_FUNC_QUALIFIER float prev_float(float const & x)
|
GLM_FUNC_QUALIFIER float prev_float(float const & x)
|
||||||
{
|
{
|
||||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
|
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||||
return std::nextafter(x, std::numeric_limits<float>::min());
|
return std::nextafter(x, std::numeric_limits<float>::min());
|
||||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||||
return detail::nextafterf(x, FLT_MIN);
|
return detail::nextafterf(x, FLT_MIN);
|
||||||
|
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
|
||||||
|
return _nextafterf(x, FLT_MIN);
|
||||||
# else
|
# else
|
||||||
return nextafterf(x, FLT_MIN);
|
return nextafterf(x, FLT_MIN);
|
||||||
# endif
|
# endif
|
||||||
@ -242,9 +246,9 @@ namespace glm
|
|||||||
|
|
||||||
GLM_FUNC_QUALIFIER double prev_float(double const & x)
|
GLM_FUNC_QUALIFIER double prev_float(double const & x)
|
||||||
{
|
{
|
||||||
# if((GLM_LANG & GLM_LANG_CXX11_FLAG))
|
# if((GLM_LANG & GLM_LANG_CXX11_FLAG) && !(GLM_PLATFORM & GLM_PLATFORM_ANDROID))
|
||||||
return std::nextafter(x, std::numeric_limits<double>::min());
|
return std::nextafter(x, std::numeric_limits<double>::min());
|
||||||
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||||
return _nextafter(x, DBL_MIN);
|
return _nextafter(x, DBL_MIN);
|
||||||
# else
|
# else
|
||||||
return nextafter(x, DBL_MIN);
|
return nextafter(x, DBL_MIN);
|
||||||
|
@ -57,13 +57,13 @@ namespace detail
|
|||||||
struct tdualquat
|
struct tdualquat
|
||||||
{
|
{
|
||||||
enum ctor{null};
|
enum ctor{null};
|
||||||
|
typedef T value_type;
|
||||||
typedef glm::detail::tquat<T, P> part_type;
|
typedef glm::detail::tquat<T, P> part_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
glm::detail::tquat<T, P> real, dual;
|
glm::detail::tquat<T, P> real, dual;
|
||||||
|
|
||||||
GLM_FUNC_DECL GLM_CONSTEXPR int length() const;
|
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
GLM_FUNC_DECL tdualquat();
|
GLM_FUNC_DECL tdualquat();
|
||||||
|
@ -33,7 +33,7 @@ namespace glm{
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR int tdualquat<T, P>::length() const
|
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tdualquat<T, P>::length() const
|
||||||
{
|
{
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,11 @@ namespace glm
|
|||||||
|
|
||||||
namespace io
|
namespace io
|
||||||
{
|
{
|
||||||
|
enum order_type { column_major, row_major};
|
||||||
enum order_type { column_major, row_major, };
|
|
||||||
|
|
||||||
template <typename CTy>
|
template <typename CTy>
|
||||||
class format_punct : public std::locale::facet {
|
class format_punct : public std::locale::facet
|
||||||
|
{
|
||||||
typedef CTy char_type;
|
typedef CTy char_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -86,7 +85,6 @@ namespace glm
|
|||||||
|
|
||||||
explicit format_punct(size_t a = 0);
|
explicit format_punct(size_t a = 0);
|
||||||
explicit format_punct(format_punct const&);
|
explicit format_punct(format_punct const&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename CTy, typename CTr = std::char_traits<CTy> >
|
template <typename CTy, typename CTr = std::char_traits<CTy> >
|
||||||
@ -113,15 +111,14 @@ namespace glm
|
|||||||
locale_type locale_;
|
locale_type locale_;
|
||||||
|
|
||||||
basic_state_saver& operator=(basic_state_saver const&);
|
basic_state_saver& operator=(basic_state_saver const&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef basic_state_saver<char> state_saver;
|
typedef basic_state_saver<char> state_saver;
|
||||||
typedef basic_state_saver<wchar_t> wstate_saver;
|
typedef basic_state_saver<wchar_t> wstate_saver;
|
||||||
|
|
||||||
template <typename CTy, typename CTr = std::char_traits<CTy> >
|
template <typename CTy, typename CTr = std::char_traits<CTy> >
|
||||||
class basic_format_saver {
|
class basic_format_saver
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit basic_format_saver(std::basic_ios<CTy,CTr>&);
|
explicit basic_format_saver(std::basic_ios<CTy,CTr>&);
|
||||||
@ -132,43 +129,38 @@ namespace glm
|
|||||||
basic_state_saver<CTy> const bss_;
|
basic_state_saver<CTy> const bss_;
|
||||||
|
|
||||||
basic_format_saver& operator=(basic_format_saver const&);
|
basic_format_saver& operator=(basic_format_saver const&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef basic_format_saver<char> format_saver;
|
typedef basic_format_saver<char> format_saver;
|
||||||
typedef basic_format_saver<wchar_t> wformat_saver;
|
typedef basic_format_saver<wchar_t> wformat_saver;
|
||||||
|
|
||||||
struct precision {
|
struct precision
|
||||||
|
{
|
||||||
unsigned value;
|
unsigned value;
|
||||||
|
|
||||||
explicit precision(unsigned);
|
explicit precision(unsigned);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct width {
|
struct width
|
||||||
|
{
|
||||||
unsigned value;
|
unsigned value;
|
||||||
|
|
||||||
explicit width(unsigned);
|
explicit width(unsigned);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename CTy>
|
template <typename CTy>
|
||||||
struct delimeter {
|
struct delimeter
|
||||||
|
{
|
||||||
CTy value[3];
|
CTy value[3];
|
||||||
|
|
||||||
explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ',');
|
explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ',');
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct order {
|
struct order
|
||||||
|
{
|
||||||
order_type value;
|
order_type value;
|
||||||
|
|
||||||
explicit order(order_type);
|
explicit order(order_type);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// functions, inlined (inline)
|
// functions, inlined (inline)
|
||||||
@ -188,12 +180,10 @@ namespace glm
|
|||||||
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&);
|
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&);
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&);
|
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&);
|
||||||
|
|
||||||
}//namespace io
|
}//namespace io
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tquat<T,P> const&);
|
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tquat<T,P> const&);
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
@ -222,10 +212,10 @@ namespace glm
|
|||||||
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x4<T,P> const&);
|
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x4<T,P> const&);
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&,
|
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(
|
||||||
|
std::basic_ostream<CTy,CTr> &,
|
||||||
std::pair<tmat4x4<T,P> const,
|
std::pair<tmat4x4<T,P> const,
|
||||||
tmat4x4<T,P> const> const&);
|
tmat4x4<T,P> const> const &);
|
||||||
|
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
305
glm/gtx/io.inl
305
glm/gtx/io.inl
@ -10,11 +10,9 @@
|
|||||||
#include <iomanip> // std::setfill<>, std::fixed, std::setprecision, std::right, std::setw
|
#include <iomanip> // std::setfill<>, std::fixed, std::setprecision, std::right, std::setw
|
||||||
#include <ostream> // std::basic_ostream<>
|
#include <ostream> // std::basic_ostream<>
|
||||||
|
|
||||||
namespace glm
|
namespace glm{
|
||||||
|
namespace io
|
||||||
{
|
{
|
||||||
namespace io
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename CTy>
|
template <typename CTy>
|
||||||
/* explicit */ GLM_FUNC_QUALIFIER
|
/* explicit */ GLM_FUNC_QUALIFIER
|
||||||
format_punct<CTy>::format_punct(size_t a)
|
format_punct<CTy>::format_punct(size_t a)
|
||||||
@ -48,8 +46,7 @@ namespace glm
|
|||||||
template <typename CTy> std::locale::id format_punct<CTy>::id;
|
template <typename CTy> std::locale::id format_punct<CTy>::id;
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
/* explicit */ GLM_FUNC_QUALIFIER
|
/* explicit */ GLM_FUNC_QUALIFIER basic_state_saver<CTy,CTr>::basic_state_saver(std::basic_ios<CTy,CTr>& a)
|
||||||
basic_state_saver<CTy,CTr>::basic_state_saver(std::basic_ios<CTy,CTr>& a)
|
|
||||||
: state_ (a),
|
: state_ (a),
|
||||||
flags_ (a.flags()),
|
flags_ (a.flags()),
|
||||||
precision_(a.precision()),
|
precision_(a.precision()),
|
||||||
@ -59,8 +56,7 @@ namespace glm
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER
|
GLM_FUNC_QUALIFIER basic_state_saver<CTy,CTr>::~basic_state_saver()
|
||||||
basic_state_saver<CTy,CTr>::~basic_state_saver()
|
|
||||||
{
|
{
|
||||||
state_.imbue(locale_);
|
state_.imbue(locale_);
|
||||||
state_.fill(fill_);
|
state_.fill(fill_);
|
||||||
@ -70,8 +66,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
/* explicit */ GLM_FUNC_QUALIFIER
|
/* explicit */ GLM_FUNC_QUALIFIER basic_format_saver<CTy,CTr>::basic_format_saver(std::basic_ios<CTy,CTr>& a)
|
||||||
basic_format_saver<CTy,CTr>::basic_format_saver(std::basic_ios<CTy,CTr>& a)
|
|
||||||
: bss_(a)
|
: bss_(a)
|
||||||
{
|
{
|
||||||
a.imbue(std::locale(a.getloc(), new format_punct<CTy>(get_facet<format_punct<CTy> >(a))));
|
a.imbue(std::locale(a.getloc(), new format_punct<CTy>(get_facet<format_punct<CTy> >(a))));
|
||||||
@ -82,19 +77,16 @@ namespace glm
|
|||||||
basic_format_saver<CTy,CTr>::~basic_format_saver()
|
basic_format_saver<CTy,CTr>::~basic_format_saver()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* explicit */ GLM_FUNC_QUALIFIER
|
/* explicit */ GLM_FUNC_QUALIFIER precision::precision(unsigned a)
|
||||||
precision::precision(unsigned a)
|
|
||||||
: value(a)
|
: value(a)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* explicit */ GLM_FUNC_QUALIFIER
|
/* explicit */ GLM_FUNC_QUALIFIER width::width(unsigned a)
|
||||||
width::width(unsigned a)
|
|
||||||
: value(a)
|
: value(a)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename CTy>
|
template <typename CTy>
|
||||||
/* explicit */ GLM_FUNC_QUALIFIER
|
/* explicit */ GLM_FUNC_QUALIFIER delimeter<CTy>::delimeter(CTy a, CTy b, CTy c)
|
||||||
delimeter<CTy>::delimeter(CTy a, CTy b, CTy c)
|
|
||||||
: value()
|
: value()
|
||||||
{
|
{
|
||||||
value[0] = a;
|
value[0] = a;
|
||||||
@ -108,8 +100,7 @@ namespace glm
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename FTy, typename CTy, typename CTr>
|
template <typename FTy, typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER FTy const&
|
GLM_FUNC_QUALIFIER FTy const& get_facet(std::basic_ios<CTy,CTr>& ios)
|
||||||
get_facet(std::basic_ios<CTy,CTr>& ios)
|
|
||||||
{
|
{
|
||||||
if (!std::has_facet<FTy>(ios.getloc())) {
|
if (!std::has_facet<FTy>(ios.getloc())) {
|
||||||
ios.imbue(std::locale(ios.getloc(), new FTy));
|
ios.imbue(std::locale(ios.getloc(), new FTy));
|
||||||
@ -119,8 +110,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>& ios)
|
||||||
formatted(std::basic_ios<CTy,CTr>& ios)
|
|
||||||
{
|
{
|
||||||
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = true;
|
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = true;
|
||||||
|
|
||||||
@ -128,8 +118,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>& unformatted(std::basic_ios<CTy,CTr>& ios)
|
||||||
unformatted(std::basic_ios<CTy,CTr>& ios)
|
|
||||||
{
|
{
|
||||||
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = false;
|
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(ios)).formatted = false;
|
||||||
|
|
||||||
@ -137,8 +126,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, precision const& a)
|
||||||
operator<<(std::basic_ostream<CTy, CTr>& os, precision const& a)
|
|
||||||
{
|
{
|
||||||
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).precision = a.value;
|
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).precision = a.value;
|
||||||
|
|
||||||
@ -146,8 +134,7 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, width const& a)
|
||||||
operator<<(std::basic_ostream<CTy, CTr>& os, width const& a)
|
|
||||||
{
|
{
|
||||||
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).width = a.value;
|
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).width = a.value;
|
||||||
|
|
||||||
@ -155,10 +142,9 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os,
|
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, delimeter<CTy> const& a)
|
||||||
delimeter<CTy> const& a)
|
|
||||||
{
|
{
|
||||||
format_punct<CTy>& fmt(const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)));
|
format_punct<CTy> & fmt(const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)));
|
||||||
|
|
||||||
fmt.delim_left = a.value[0];
|
fmt.delim_left = a.value[0];
|
||||||
fmt.delim_right = a.value[1];
|
fmt.delim_right = a.value[1];
|
||||||
@ -168,28 +154,27 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr>
|
template <typename CTy, typename CTr>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>& os, order const& a)
|
||||||
operator<<(std::basic_ostream<CTy, CTr>& os, order const& a)
|
|
||||||
{
|
{
|
||||||
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).order = a.value;
|
const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy> >(os)).order = a.value;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
} // namespace io
|
||||||
|
|
||||||
} // namespace io
|
namespace detail
|
||||||
|
{
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tquat<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tquat<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
io::basic_state_saver<CTy> const bss(os);
|
io::basic_state_saver<CTy> const bss(os);
|
||||||
|
|
||||||
os << std::fixed
|
os << std::fixed
|
||||||
@ -202,7 +187,9 @@ namespace glm
|
|||||||
<< std::setw(fmt.width) << a.y << fmt.separator
|
<< std::setw(fmt.width) << a.y << fmt.separator
|
||||||
<< std::setw(fmt.width) << a.z
|
<< std::setw(fmt.width) << a.z
|
||||||
<< fmt.delim_right;
|
<< fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << a.w << fmt.space << a.x << fmt.space << a.y << fmt.space << a.z;
|
os << a.w << fmt.space << a.x << fmt.space << a.y << fmt.space << a.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,15 +198,16 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec2<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tvec2<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
io::basic_state_saver<CTy> const bss(os);
|
io::basic_state_saver<CTy> const bss(os);
|
||||||
|
|
||||||
os << std::fixed
|
os << std::fixed
|
||||||
@ -230,7 +218,9 @@ namespace glm
|
|||||||
<< std::setw(fmt.width) << a.x << fmt.separator
|
<< std::setw(fmt.width) << a.x << fmt.separator
|
||||||
<< std::setw(fmt.width) << a.y
|
<< std::setw(fmt.width) << a.y
|
||||||
<< fmt.delim_right;
|
<< fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << a.x << fmt.space << a.y;
|
os << a.x << fmt.space << a.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,15 +229,16 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec3<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tvec3<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
io::basic_state_saver<CTy> const bss(os);
|
io::basic_state_saver<CTy> const bss(os);
|
||||||
|
|
||||||
os << std::fixed
|
os << std::fixed
|
||||||
@ -259,7 +250,9 @@ namespace glm
|
|||||||
<< std::setw(fmt.width) << a.y << fmt.separator
|
<< std::setw(fmt.width) << a.y << fmt.separator
|
||||||
<< std::setw(fmt.width) << a.z
|
<< std::setw(fmt.width) << a.z
|
||||||
<< fmt.delim_right;
|
<< fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << a.x << fmt.space << a.y << fmt.space << a.z;
|
os << a.x << fmt.space << a.y << fmt.space << a.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,15 +261,16 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tvec4<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tvec4<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
io::basic_state_saver<CTy> const bss(os);
|
io::basic_state_saver<CTy> const bss(os);
|
||||||
|
|
||||||
os << std::fixed
|
os << std::fixed
|
||||||
@ -289,7 +283,9 @@ namespace glm
|
|||||||
<< std::setw(fmt.width) << a.z << fmt.separator
|
<< std::setw(fmt.width) << a.z << fmt.separator
|
||||||
<< std::setw(fmt.width) << a.w
|
<< std::setw(fmt.width) << a.w
|
||||||
<< fmt.delim_right;
|
<< fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << a.x << fmt.space << a.y << fmt.space << a.z << fmt.space << a.w;
|
os << a.x << fmt.space << a.y << fmt.space << a.z << fmt.space << a.w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,24 +294,26 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x2<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x2<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat2x2<T,P> m(a);
|
tmat2x2<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.delim_right;
|
<< fmt.space << m[1] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1];
|
os << m[0] << fmt.space << m[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,25 +322,27 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x3<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x3<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat3x2<T,P> m(a);
|
tmat3x2<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.newline
|
<< fmt.space << m[1] << fmt.newline
|
||||||
<< fmt.space << m[2] << fmt.delim_right;
|
<< fmt.space << m[2] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
|
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,26 +351,29 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x4<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat2x4<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat4x2<T,P> m(a);
|
tmat4x2<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
|
||||||
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.newline
|
<< fmt.space << m[1] << fmt.newline
|
||||||
<< fmt.space << m[2] << fmt.newline
|
<< fmt.space << m[2] << fmt.newline
|
||||||
<< fmt.space << m[3] << fmt.delim_right;
|
<< fmt.space << m[3] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
|
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,24 +382,26 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x2<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x2<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat2x3<T,P> m(a);
|
tmat2x3<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.delim_right;
|
<< fmt.space << m[1] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1];
|
os << m[0] << fmt.space << m[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,25 +410,27 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x3<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x3<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat3x3<T,P> m(a);
|
tmat3x3<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.newline
|
<< fmt.space << m[1] << fmt.newline
|
||||||
<< fmt.space << m[2] << fmt.delim_right;
|
<< fmt.space << m[2] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
|
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,26 +439,28 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x4<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat3x4<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat4x3<T,P> m(a);
|
tmat4x3<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if (fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.newline
|
<< fmt.space << m[1] << fmt.newline
|
||||||
<< fmt.space << m[2] << fmt.newline
|
<< fmt.space << m[2] << fmt.newline
|
||||||
<< fmt.space << m[3] << fmt.delim_right;
|
<< fmt.space << m[3] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
|
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -460,24 +469,26 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x2<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x2<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat2x4<T,P> m(a);
|
tmat2x4<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if (fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.delim_right;
|
<< fmt.space << m[1] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1];
|
os << m[0] << fmt.space << m[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,25 +497,27 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x3<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x3<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat3x4<T,P> m(a);
|
tmat3x4<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.newline
|
<< fmt.space << m[1] << fmt.newline
|
||||||
<< fmt.space << m[2] << fmt.delim_right;
|
<< fmt.space << m[2] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
|
os << m[0] << fmt.space << m[1] << fmt.space << m[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -513,26 +526,28 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr> & operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x4<T,P> const& a)
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os, tmat4x4<T,P> const& a)
|
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat4x4<T,P> m(a);
|
tmat4x4<T,P> m(a);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if (io::row_major == fmt.order)
|
||||||
m = transpose(a);
|
m = transpose(a);
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
|
{
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< fmt.delim_left << m[0] << fmt.newline
|
<< fmt.delim_left << m[0] << fmt.newline
|
||||||
<< fmt.space << m[1] << fmt.newline
|
<< fmt.space << m[1] << fmt.newline
|
||||||
<< fmt.space << m[2] << fmt.newline
|
<< fmt.space << m[2] << fmt.newline
|
||||||
<< fmt.space << m[3] << fmt.delim_right;
|
<< fmt.space << m[3] << fmt.delim_right;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
|
os << m[0] << fmt.space << m[1] << fmt.space << m[2] << fmt.space << m[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,39 +556,43 @@ namespace glm
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename CTy, typename CTr, typename T, precision P>
|
template <typename CTy, typename CTr, typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>&
|
GLM_FUNC_QUALIFIER std::basic_ostream<CTy,CTr>& operator<<(
|
||||||
operator<<(std::basic_ostream<CTy,CTr>& os,
|
std::basic_ostream<CTy,CTr> & os,
|
||||||
std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const& a)
|
std::pair<tmat4x4<T,P> const, tmat4x4<T,P> const> const& a)
|
||||||
{
|
{
|
||||||
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
typename std::basic_ostream<CTy,CTr>::sentry const cerberus(os);
|
||||||
|
|
||||||
if (cerberus) {
|
if(cerberus)
|
||||||
io::format_punct<CTy> const& fmt(io::get_facet<io::format_punct<CTy> >(os));
|
{
|
||||||
|
io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
|
||||||
tmat4x4<T,P> ml(a.first);
|
tmat4x4<T,P> ml(a.first);
|
||||||
tmat4x4<T,P> mr(a.second);
|
tmat4x4<T,P> mr(a.second);
|
||||||
|
|
||||||
if (io::row_major == fmt.order) {
|
if(io::row_major == fmt.order)
|
||||||
|
{
|
||||||
ml = transpose(a.first);
|
ml = transpose(a.first);
|
||||||
mr = transpose(a.second);
|
mr = transpose(a.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmt.formatted) {
|
if(fmt.formatted)
|
||||||
CTy const& l(fmt.delim_left);
|
{
|
||||||
CTy const& r(fmt.delim_right);
|
CTy const & l(fmt.delim_left);
|
||||||
CTy const& s(fmt.space);
|
CTy const & r(fmt.delim_right);
|
||||||
|
CTy const & s(fmt.space);
|
||||||
|
|
||||||
os << fmt.newline
|
os << fmt.newline
|
||||||
<< l << ml[0] << s << s << l << mr[0] << fmt.newline
|
<< l << ml[0] << s << s << l << mr[0] << fmt.newline
|
||||||
<< s << ml[1] << s << s << s << mr[1] << fmt.newline
|
<< s << ml[1] << s << s << s << mr[1] << fmt.newline
|
||||||
<< s << ml[2] << s << s << s << mr[2] << fmt.newline
|
<< s << ml[2] << s << s << s << mr[2] << fmt.newline
|
||||||
<< s << ml[3] << r << s << s << mr[3] << r;
|
<< s << ml[3] << r << s << s << mr[3] << r;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
os << ml << fmt.space << mr;
|
os << ml << fmt.space << mr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
}//namespace detail
|
||||||
}//namespace detail
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include "../gtc/constants.hpp"
|
||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ namespace glm
|
|||||||
detail::tquat<T, P> const & s2,
|
detail::tquat<T, P> const & s2,
|
||||||
T const & h)
|
T const & h)
|
||||||
{
|
{
|
||||||
return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * (T(1) - h) * h);
|
return mix(mix(q1, q2, h), mix(s1, s2, h), static_cast<T>(2) * (static_cast<T>(1) - h) * h);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
@ -52,7 +53,7 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tquat<T, P> invQuat = inverse(curr);
|
detail::tquat<T, P> invQuat = inverse(curr);
|
||||||
return exp((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr;
|
return exp((log(next + invQuat) + log(prev + invQuat)) / static_cast<T>(-4)) * curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
@ -62,7 +63,10 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec3<T, P> u(q.x, q.y, q.z);
|
detail::tvec3<T, P> u(q.x, q.y, q.z);
|
||||||
float Angle = glm::length(u);
|
T Angle = glm::length(u);
|
||||||
|
if (Angle < epsilon<T>())
|
||||||
|
return detail::tquat<T, P>();
|
||||||
|
|
||||||
detail::tvec3<T, P> v(u / Angle);
|
detail::tvec3<T, P> v(u / Angle);
|
||||||
return detail::tquat<T, P>(cos(Angle), sin(Angle) * v);
|
return detail::tquat<T, P>(cos(Angle), sin(Angle) * v);
|
||||||
}
|
}
|
||||||
@ -73,18 +77,20 @@ namespace glm
|
|||||||
detail::tquat<T, P> const & q
|
detail::tquat<T, P> const & q
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if((q.x == static_cast<T>(0)) && (q.y == static_cast<T>(0)) && (q.z == static_cast<T>(0)))
|
detail::tvec3<T, P> u(q.x, q.y, q.z);
|
||||||
|
T Vec3Len = length(u);
|
||||||
|
|
||||||
|
if (Vec3Len < epsilon<T>())
|
||||||
{
|
{
|
||||||
if(q.w > T(0))
|
if(q.w > static_cast<T>(0))
|
||||||
return detail::tquat<T, P>(log(q.w), T(0), T(0), T(0));
|
return detail::tquat<T, P>(log(q.w), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
|
||||||
else if(q.w < T(0))
|
else if(q.w < static_cast<T>(0))
|
||||||
return detail::tquat<T, P>(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0));
|
return detail::tquat<T, P>(log(-q.w), pi<T>(), static_cast<T>(0), static_cast<T>(0));
|
||||||
else
|
else
|
||||||
return detail::tquat<T, P>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity());
|
return detail::tquat<T, P>(std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity());
|
||||||
}
|
}
|
||||||
else
|
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 QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w);
|
||||||
T t = atan(Vec3Len, T(q.w)) / Vec3Len;
|
T t = atan(Vec3Len, T(q.w)) / Vec3Len;
|
||||||
return detail::tquat<T, P>(log(QuatLen), t * q.x, t * q.y, t * q.z);
|
return detail::tquat<T, P>(log(QuatLen), t * q.x, t * q.y, t * q.z);
|
||||||
@ -98,11 +104,11 @@ namespace glm
|
|||||||
T const & y
|
T const & y
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(abs(x.w) > T(0.9999))
|
if(abs(x.w) > (static_cast<T>(1) - epsilon<T>()))
|
||||||
return x;
|
return x;
|
||||||
float Angle = acos(y);
|
T Angle = acos(y);
|
||||||
float NewAngle = Angle * y;
|
T NewAngle = Angle * y;
|
||||||
float Div = sin(NewAngle) / sin(Angle);
|
T Div = sin(NewAngle) / sin(Angle);
|
||||||
return detail::tquat<T, P>(
|
return detail::tquat<T, P>(
|
||||||
cos(NewAngle),
|
cos(NewAngle),
|
||||||
x.x * Div,
|
x.x * Div,
|
||||||
@ -146,7 +152,7 @@ namespace glm
|
|||||||
detail::tquat<T, P> const & q
|
detail::tquat<T, P> const & q
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
T w = static_cast<T>(1.0) - q.x * q.x - q.y * q.y - q.z * q.z;
|
T w = static_cast<T>(1) - q.x * q.x - q.y * q.y - q.z * q.z;
|
||||||
if(w < T(0))
|
if(w < T(0))
|
||||||
return T(0);
|
return T(0);
|
||||||
else
|
else
|
||||||
@ -170,12 +176,12 @@ namespace glm
|
|||||||
T const & a
|
T const & a
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(a <= T(0)) return x;
|
if(a <= static_cast<T>(0)) return x;
|
||||||
if(a >= T(1)) return y;
|
if(a >= static_cast<T>(1)) return y;
|
||||||
|
|
||||||
T fCos = dot(x, y);
|
T fCos = dot(x, y);
|
||||||
detail::tquat<T, P> y2(y); //BUG!!! tquat<T> y2;
|
detail::tquat<T, P> y2(y); //BUG!!! tquat<T> y2;
|
||||||
if(fCos < T(0))
|
if(fCos < static_cast<T>(0))
|
||||||
{
|
{
|
||||||
y2 = -y;
|
y2 = -y;
|
||||||
fCos = -fCos;
|
fCos = -fCos;
|
||||||
@ -183,7 +189,7 @@ namespace glm
|
|||||||
|
|
||||||
//if(fCos > 1.0f) // problem
|
//if(fCos > 1.0f) // problem
|
||||||
T k0, k1;
|
T k0, k1;
|
||||||
if(fCos > T(0.9999))
|
if(fCos > (static_cast<T>(1) - epsilon<T>()))
|
||||||
{
|
{
|
||||||
k0 = static_cast<T>(1) - a;
|
k0 = static_cast<T>(1) - a;
|
||||||
k1 = static_cast<T>(0) + a; //BUG!!! 1.0f + a;
|
k1 = static_cast<T>(0) + a; //BUG!!! 1.0f + a;
|
||||||
@ -193,8 +199,8 @@ namespace glm
|
|||||||
T fSin = sqrt(T(1) - fCos * fCos);
|
T fSin = sqrt(T(1) - fCos * fCos);
|
||||||
T fAngle = atan(fSin, fCos);
|
T fAngle = atan(fSin, fCos);
|
||||||
T fOneOverSin = static_cast<T>(1) / fSin;
|
T fOneOverSin = static_cast<T>(1) / fSin;
|
||||||
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
|
k0 = sin((static_cast<T>(1) - a) * fAngle) * fOneOverSin;
|
||||||
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
|
k1 = sin((static_cast<T>(0) + a) * fAngle) * fOneOverSin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return detail::tquat<T, P>(
|
return detail::tquat<T, P>(
|
||||||
@ -212,7 +218,7 @@ namespace glm
|
|||||||
T const & a
|
T const & a
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return glm::normalize(x * (T(1) - a) + (y * a));
|
return glm::normalize(x * (static_cast<T>(1) - a) + (y * a));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
@ -225,7 +231,7 @@ namespace glm
|
|||||||
T cosTheta = dot(orig, dest);
|
T cosTheta = dot(orig, dest);
|
||||||
detail::tvec3<T, P> rotationAxis;
|
detail::tvec3<T, P> rotationAxis;
|
||||||
|
|
||||||
if(cosTheta < T(-1) + epsilon<T>())
|
if(cosTheta < static_cast<T>(-1) + epsilon<T>())
|
||||||
{
|
{
|
||||||
// special case when vectors in opposite directions :
|
// special case when vectors in opposite directions :
|
||||||
// there is no "ideal" rotation axis
|
// there is no "ideal" rotation axis
|
||||||
@ -243,11 +249,11 @@ namespace glm
|
|||||||
// Implementation from Stan Melax's Game Programming Gems 1 article
|
// Implementation from Stan Melax's Game Programming Gems 1 article
|
||||||
rotationAxis = cross(orig, dest);
|
rotationAxis = cross(orig, dest);
|
||||||
|
|
||||||
T s = sqrt((T(1) + cosTheta) * T(2));
|
T s = sqrt((T(1) + cosTheta) * static_cast<T>(2));
|
||||||
T invs = static_cast<T>(1) / s;
|
T invs = static_cast<T>(1) / s;
|
||||||
|
|
||||||
return detail::tquat<T, P>(
|
return detail::tquat<T, P>(
|
||||||
s * T(0.5f),
|
s * static_cast<T>(0.5f),
|
||||||
rotationAxis.x * invs,
|
rotationAxis.x * invs,
|
||||||
rotationAxis.y * invs,
|
rotationAxis.y * invs,
|
||||||
rotationAxis.z * invs);
|
rotationAxis.z * invs);
|
||||||
|
@ -1,166 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// 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 virtrev_xstream
|
|
||||||
/// @file glm/virtrev/xstream.hpp
|
|
||||||
/// @date 2008-05-24 / 2008-05-26
|
|
||||||
/// @author Mathieu Roumillac (matrem84.free.fr)
|
|
||||||
///
|
|
||||||
/// @see core (dependence)
|
|
||||||
/// @see gtc_matrix_access (dependence)
|
|
||||||
///
|
|
||||||
/// @defgroup virtrev_xstream GLM_VIRTREV_xstream: xml like output
|
|
||||||
/// @ingroup virtrev
|
|
||||||
///
|
|
||||||
/// @brief Streaming vector and matrix in a xml way.
|
|
||||||
///
|
|
||||||
/// Include <glm/virtrev/xstream.hpp> for this functionality.
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef GLM_VIRTREV_xstream
|
|
||||||
#define GLM_VIRTREV_xstream GLM_VERSION
|
|
||||||
|
|
||||||
#include "../glm.hpp"
|
|
||||||
#include "../gtc/matrix_access.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
|
|
||||||
# pragma message("GLM: GLM_VIRTREV_xstream extension included")
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
namespace glm{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template<typename T>
|
|
||||||
std::ostream & operator << (std::ostream & stream, glm::detail::tvec2<T, P> const & vec)
|
|
||||||
{
|
|
||||||
stream << "<glm_vec2 ";
|
|
||||||
stream << "x=\"" << vec.x << "\" ";
|
|
||||||
stream << "y=\"" << vec.y << "\" ";
|
|
||||||
stream << "/>";
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::ostream & operator << (std::ostream & stream, glm::detail::tvec3<T, P> const & vec)
|
|
||||||
{
|
|
||||||
stream << "<glm_vec3 ";
|
|
||||||
stream << "x=\"" << vec.x << "\" ";
|
|
||||||
stream << "y=\"" << vec.y << "\" ";
|
|
||||||
stream << "z=\"" << vec.z << "\" ";
|
|
||||||
stream << "/>";
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::ostream & operator << (std::ostream & stream, glm::detail::tvec4<T, P> const & vec)
|
|
||||||
{
|
|
||||||
stream << "<glm_vec4 ";
|
|
||||||
stream << "x=\"" << vec.x << "\" ";
|
|
||||||
stream << "y=\"" << vec.y << "\" ";
|
|
||||||
stream << "z=\"" << vec.z << "\" ";
|
|
||||||
stream << "w=\"" << vec.w << "\" ";
|
|
||||||
stream << "/>";
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::ostream & operator << (std::ostream & stream, glm::detail::tmat2x2<T, P> const & mat)
|
|
||||||
{
|
|
||||||
stream << "<glm_mat2>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 0)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 0)[1] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 1)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 1)[1] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "</glm_mat2>";
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::ostream & operator << (std::ostream & stream, glm::detail::tmat3x3<T, P> const & mat)
|
|
||||||
{
|
|
||||||
stream << "<glm_mat3>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 0)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 0)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 0)[2] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 1)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 1)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 1)[2] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 2)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 2)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 2)[2] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "</glm_mat3>";
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::ostream & operator << (std::ostream & stream, glm::detail::tmat4x4<T, P> const & mat)
|
|
||||||
{
|
|
||||||
stream << "<glm_mat4>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 0)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 0)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 0)[2] << "\" ";
|
|
||||||
stream << "w=\"" << glm::row(mat, 0)[3] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 1)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 1)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 1)[2] << "\" ";
|
|
||||||
stream << "w=\"" << glm::row(mat, 1)[3] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 2)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 2)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 2)[2] << "\" ";
|
|
||||||
stream << "w=\"" << glm::row(mat, 2)[3] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "<row ";
|
|
||||||
stream << "x=\"" << glm::row(mat, 3)[0] << "\" ";
|
|
||||||
stream << "y=\"" << glm::row(mat, 3)[1] << "\" ";
|
|
||||||
stream << "z=\"" << glm::row(mat, 3)[2] << "\" ";
|
|
||||||
stream << "w=\"" << glm::row(mat, 3)[3] << "\" ";
|
|
||||||
stream << "/>" << std::endl;
|
|
||||||
stream << "</glm_mat4>";
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace detail
|
|
||||||
}//namespace glm
|
|
||||||
*/
|
|
||||||
#endif//GLM_VIRTREV_xstream
|
|
14
readme.txt
14
readme.txt
@ -44,8 +44,14 @@ GLM 0.9.6.0: 2014-XX-XX
|
|||||||
- Removed GLM_FORCE_RADIANS, active by default
|
- Removed GLM_FORCE_RADIANS, active by default
|
||||||
- Added move contructors and assignment operators (#141)
|
- Added move contructors and assignment operators (#141)
|
||||||
|
|
||||||
|
GLM 0.9.5.5: 2014-XX-XX
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
- Fixed std::nextafter not supported with C++11 on Android #213
|
||||||
|
- Fixed missing value_type for dual quaternion
|
||||||
|
- Fixed return type of dual quaternion length
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.5.4: 2014-0X-XX
|
GLM 0.9.5.4: 2014-06-21
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
- Fixed non-utf8 character #196
|
- Fixed non-utf8 character #196
|
||||||
- Added FindGLM install for CMake #189
|
- Added FindGLM install for CMake #189
|
||||||
@ -59,6 +65,12 @@ GLM 0.9.5.4: 2014-0X-XX
|
|||||||
- Fixed lerp when cosTheta is close to 1 in quaternion slerp #210
|
- Fixed lerp when cosTheta is close to 1 in quaternion slerp #210
|
||||||
- Added GTX_io for io with <iostream> #144
|
- Added GTX_io for io with <iostream> #144
|
||||||
- Fixed fastDistance ambiguity #215
|
- Fixed fastDistance ambiguity #215
|
||||||
|
- Fixed tweakedInfinitePerspective #208 and added user-defined epsilon to
|
||||||
|
tweakedInfinitePerspective
|
||||||
|
- Fixed std::copy and std::vector with GLM types #214
|
||||||
|
- Fixed strict aliasing issues #212, #152
|
||||||
|
- Fixed std::nextafter not supported with C++11 on Android #213
|
||||||
|
- Fixed corner cases in exp and log functions for quaternions #199
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.5.3: 2014-04-02
|
GLM 0.9.5.3: 2014-04-02
|
||||||
|
@ -228,10 +228,10 @@ int test_inverse_perf(std::size_t Instance, char const * Message)
|
|||||||
//glm::uint Ulp = 0;
|
//glm::uint Ulp = 0;
|
||||||
//Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp);
|
//Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp);
|
||||||
|
|
||||||
printf("inverse<%s>(%f): %d\n", Message, Diff, EndTime - StartTime);
|
printf("inverse<%s>(%f): %lu\n", Message, Diff, EndTime - StartTime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -93,29 +93,42 @@ int test_std_copy()
|
|||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<int> High;
|
||||||
|
High.resize(64);
|
||||||
|
std::vector<int> Medium(High.size());
|
||||||
|
|
||||||
|
std::copy(High.begin(), High.end(), Medium.begin());
|
||||||
|
|
||||||
|
*Medium.begin() = *High.begin();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<glm::dvec4> High4;
|
std::vector<glm::dvec4> High4;
|
||||||
|
High4.resize(64);
|
||||||
std::vector<glm::vec4> Medium4(High4.size());
|
std::vector<glm::vec4> Medium4(High4.size());
|
||||||
|
|
||||||
std::copy(&High4.begin()[0], &High4.end()[0], Medium4.begin());
|
std::copy(High4.begin(), High4.end(), Medium4.begin());
|
||||||
|
|
||||||
*Medium4.begin() = *High4.begin();
|
*Medium4.begin() = *High4.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<glm::dvec3> High3;
|
std::vector<glm::dvec3> High3;
|
||||||
|
High3.resize(64);
|
||||||
std::vector<glm::vec3> Medium3(High3.size());
|
std::vector<glm::vec3> Medium3(High3.size());
|
||||||
|
|
||||||
std::copy(&High3.begin()[0], &High3.end()[0], Medium3.begin());
|
std::copy(High3.begin(), High3.end(), Medium3.begin());
|
||||||
|
|
||||||
*Medium3.begin() = *High3.begin();
|
*Medium3.begin() = *High3.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<glm::dvec2> High2;
|
std::vector<glm::dvec2> High2;
|
||||||
|
High2.resize(64);
|
||||||
std::vector<glm::vec2> Medium2(High2.size());
|
std::vector<glm::vec2> Medium2(High2.size());
|
||||||
|
|
||||||
std::copy(&High2.begin()[0], &High2.end()[0], Medium2.begin());
|
std::copy(High2.begin(), High2.end(), Medium2.begin());
|
||||||
|
|
||||||
*Medium2.begin() = *High2.begin();
|
*Medium2.begin() = *High2.begin();
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,54 @@
|
|||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/constants.hpp>
|
#include <glm/gtc/constants.hpp>
|
||||||
|
|
||||||
int main()
|
int test_perspective()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
|
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_pick()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240));
|
glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240));
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_tweakedInfinitePerspective()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
glm::mat4 ProjectionA = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f);
|
||||||
|
glm::mat4 ProjectionB = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f, 0.001f);
|
||||||
|
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_translate()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
glm::lowp_vec3 v(1.0);
|
glm::lowp_vec3 v(1.0);
|
||||||
glm::lowp_mat4 m(0);
|
glm::lowp_mat4 m(0);
|
||||||
glm::lowp_mat4 t = glm::translate(m, v);
|
glm::lowp_mat4 t = glm::translate(m, v);
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += test_translate();
|
||||||
|
Error += test_tweakedInfinitePerspective();
|
||||||
|
Error += test_pick();
|
||||||
|
Error += test_perspective();
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
@ -100,7 +100,7 @@ int test_Half1x16()
|
|||||||
glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
|
glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
|
||||||
float v0 = glm::unpackHalf1x16(p0);
|
float v0 = glm::unpackHalf1x16(p0);
|
||||||
glm::uint32 p1 = glm::packHalf1x16(v0);
|
glm::uint32 p1 = glm::packHalf1x16(v0);
|
||||||
float v1 = glm::unpackHalf1x16(p0);
|
float v1 = glm::unpackHalf1x16(p1);
|
||||||
Error += (v0 == v1) ? 0 : 1;
|
Error += (v0 == v1) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ int test_Half4x16()
|
|||||||
glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
|
glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
|
||||||
glm::vec4 v0 = glm::unpackHalf4x16(p0);
|
glm::vec4 v0 = glm::unpackHalf4x16(p0);
|
||||||
glm::uint64 p1 = glm::packHalf4x16(v0);
|
glm::uint64 p1 = glm::packHalf4x16(v0);
|
||||||
glm::vec4 v1 = glm::unpackHalf4x16(p0);
|
glm::vec4 v1 = glm::unpackHalf4x16(p1);
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ int test_I3x10_1x2()
|
|||||||
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
|
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
|
||||||
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
|
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
|
||||||
glm::uint32 p1 = glm::packI3x10_1x2(v0);
|
glm::uint32 p1 = glm::packI3x10_1x2(v0);
|
||||||
glm::ivec4 v1 = glm::unpackI3x10_1x2(p0);
|
glm::ivec4 v1 = glm::unpackI3x10_1x2(p1);
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ int test_U3x10_1x2()
|
|||||||
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
|
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
|
||||||
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
|
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
|
||||||
glm::uint32 p1 = glm::packU3x10_1x2(v0);
|
glm::uint32 p1 = glm::packU3x10_1x2(v0);
|
||||||
glm::uvec4 v1 = glm::unpackU3x10_1x2(p0);
|
glm::uvec4 v1 = glm::unpackU3x10_1x2(p1);
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ int test_Snorm3x10_1x2()
|
|||||||
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
|
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
|
||||||
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
|
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
|
||||||
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
|
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
|
||||||
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0);
|
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1);
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ int test_Unorm3x10_1x2()
|
|||||||
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
|
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
|
||||||
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
|
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
|
||||||
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
|
glm::uint32 p1 = glm::packSnorm3x10_1x2(v0);
|
||||||
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p0);
|
glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1);
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ int test_F2x11_1x10()
|
|||||||
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
|
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
|
||||||
glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
|
glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
|
||||||
glm::uint32 p1 = glm::packF2x11_1x10(v0);
|
glm::uint32 p1 = glm::packF2x11_1x10(v0);
|
||||||
glm::vec3 v1 = glm::unpackF2x11_1x10(p0);
|
glm::vec3 v1 = glm::unpackF2x11_1x10(p1);
|
||||||
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
Error += glm::all(glm::equal(v0, v1)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user