Fixed merge with 0.9.5

This commit is contained in:
Christophe Riccio 2014-06-28 21:26:24 +02:00
commit 7659e901c9
18 changed files with 1011 additions and 1265 deletions

View file

@ -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

View file

@ -51,6 +51,7 @@
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../gtc/constants.hpp"
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
# pragma message("GLM: GLM_GTC_matrix_transform extension included")
@ -164,8 +165,8 @@ namespace glm
/// @param far
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
/// @see gtc_matrix_transform
template <typename T, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> frustum(
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> frustum(
T const & left,
T const & right,
T const & bottom,
@ -181,8 +182,8 @@ namespace glm
/// @param far
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
/// @see gtc_matrix_transform
template <typename T, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> perspective(
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> perspective(
T const & fovy,
T const & aspect,
T const & near,
@ -197,8 +198,8 @@ namespace glm
/// @param far
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
/// @see gtc_matrix_transform
template <typename T, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> perspectiveFov(
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> perspectiveFov(
T const & fov,
T const & width,
T const & height,
@ -212,8 +213,8 @@ namespace glm
/// @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, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> infinitePerspective(
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> infinitePerspective(
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.
@ -223,10 +224,21 @@ namespace glm
/// @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, precision P>
GLM_FUNC_DECL detail::tmat4x4<T, P> tweakedInfinitePerspective(
template <typename T>
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> tweakedInfinitePerspective(
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.
///
/// @param obj

View file

@ -167,7 +167,7 @@ namespace glm
detail::tmat4x4<T, defaultp> Result(1);
Result[0][0] = static_cast<T>(2) / (right - left);
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][1] = - (top + bottom) / (top - bottom);
Result[3][2] = - (zFar + zNear) / (zFar - zNear);
@ -186,93 +186,93 @@ namespace glm
detail::tmat4x4<T, defaultp> Result(1);
Result[0][0] = static_cast<T>(2) / (right - left);
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][1] = - (top + bottom) / (top - bottom);
return Result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> frustum
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> frustum
(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & nearVal,
valType const & farVal
T const & left,
T const & right,
T const & bottom,
T const & top,
T const & nearVal,
T const & farVal
)
{
detail::tmat4x4<valType, defaultp> Result(0);
Result[0][0] = (valType(2) * nearVal) / (right - left);
Result[1][1] = (valType(2) * nearVal) / (top - bottom);
detail::tmat4x4<T, defaultp> Result(0);
Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left);
Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom);
Result[2][0] = (right + left) / (right - left);
Result[2][1] = (top + bottom) / (top - bottom);
Result[2][2] = -(farVal + nearVal) / (farVal - nearVal);
Result[2][3] = valType(-1);
Result[3][2] = -(valType(2) * farVal * nearVal) / (farVal - nearVal);
Result[2][3] = static_cast<T>(-1);
Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal);
return Result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspective
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> perspective
(
valType const & fovy,
valType const & aspect,
valType const & zNear,
valType const & zFar
T const & fovy,
T const & aspect,
T const & zNear,
T const & zFar
)
{
assert(aspect != valType(0));
assert(aspect != static_cast<T>(0));
assert(zFar != zNear);
#ifdef GLM_FORCE_RADIANS
valType const rad = fovy;
T const rad = fovy;
#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.")
valType const rad = glm::radians(fovy);
T const rad = glm::radians(fovy);
#endif
valType tanHalfFovy = tan(rad / valType(2));
T tanHalfFovy = tan(rad / static_cast<T>(2));
detail::tmat4x4<valType, defaultp> Result(valType(0));
Result[0][0] = valType(1) / (aspect * tanHalfFovy);
Result[1][1] = valType(1) / (tanHalfFovy);
detail::tmat4x4<T, defaultp> Result(static_cast<T>(0));
Result[0][0] = static_cast<T>(1) / (aspect * tanHalfFovy);
Result[1][1] = static_cast<T>(1) / (tanHalfFovy);
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
Result[2][3] = - static_cast<T>(1);
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
return Result;
}
template <typename valType>
GLM_FUNC_QUALIFIER detail::tmat4x4<valType, defaultp> perspectiveFov
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> perspectiveFov
(
valType const & fov,
valType const & width,
valType const & height,
valType const & zNear,
valType const & zFar
T const & fov,
T const & width,
T const & height,
T const & zNear,
T const & zFar
)
{
assert(width > valType(0));
assert(height > valType(0));
assert(fov > valType(0));
assert(width > static_cast<T>(0));
assert(height > static_cast<T>(0));
assert(fov > static_cast<T>(0));
#ifdef GLM_FORCE_RADIANS
valType rad = fov;
T rad = fov;
#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.")
valType rad = glm::radians(fov);
T rad = glm::radians(fov);
#endif
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
valType w = h * height / width; ///todo max(width , Height) / min(width , Height)?
T h = glm::cos(static_cast<T>(0.5) * rad) / glm::sin(static_cast<T>(0.5) * rad);
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[1][1] = h;
Result[2][2] = - (zFar + zNear) / (zFar - zNear);
Result[2][3] = - valType(1);
Result[3][2] = - (valType(2) * zFar * zNear) / (zFar - zNear);
Result[2][3] = - static_cast<T>(1);
Result[3][2] = - (static_cast<T>(2) * zFar * zNear) / (zFar - zNear);
return Result;
}
@ -304,12 +304,14 @@ namespace glm
return Result;
}
// Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf
template <typename T>
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> tweakedInfinitePerspective
(
T fovy,
T aspect,
T zNear
T zNear,
T ep
)
{
#ifdef GLM_FORCE_RADIANS
@ -324,14 +326,25 @@ namespace glm
T top = range;
detail::tmat4x4<T, defaultp> Result(T(0));
Result[0][0] = (T(2) * zNear) / (right - left);
Result[1][1] = (T(2) * zNear) / (top - bottom);
Result[2][2] = static_cast<T>(0.0001) - T(1);
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
Result[2][2] = ep - 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;
}
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>
GLM_FUNC_QUALIFIER detail::tvec3<T, P> project
(

View file

@ -62,7 +62,7 @@ namespace glm
/// @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/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.
///
@ -74,7 +74,7 @@ namespace glm
/// @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/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.
/// Then, the results are packed into the returned 16-bit unsigned integer.
@ -106,7 +106,7 @@ namespace glm
/// @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/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.
/// 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 <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>
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.
/// 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 <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>
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.
/// Then, the results are packed into the returned 16-bit unsigned integer.
@ -164,7 +164,7 @@ namespace glm
/// @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/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.
/// 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 <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>
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.
/// 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 <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>
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.
/// Then, the results are packed into the returned 64-bit unsigned integer.
@ -222,7 +222,7 @@ namespace glm
/// @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/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.
/// 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 <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>
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.
/// 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 <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>
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.
/// 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 <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>
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,
/// 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 <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>
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
/// 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 <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>
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
/// 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 vec4 unpackSnorm3x10_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
/// 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 vec4 unpackSnorm3x10_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.
/// 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 uvec4 unpackI3x10_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.
/// 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 uvec4 unpackI3x10_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.
/// 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 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

View file

@ -31,11 +31,12 @@
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../detail/type_half.hpp"
#include <cstring>
namespace glm{
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
// 11 bits => EEE EEFFFFFF
@ -53,7 +54,7 @@ namespace detail
((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
// 11 bits => EEE EEFFFFFF
@ -71,7 +72,7 @@ namespace detail
((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
// 11 bits => EEE EEFFFFFF
@ -89,7 +90,7 @@ namespace detail
((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
// 11 bits => EEE EEFFFFFF
@ -110,7 +111,7 @@ namespace detail
((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
// 11 bits => EEE EEFFFFFF
@ -131,7 +132,7 @@ namespace detail
((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);
}
@ -145,7 +146,14 @@ namespace detail
else if(glm::isinf(x))
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)
@ -157,8 +165,15 @@ namespace detail
else if(x == (0x1f << 6))
return ~0;//Inf
uint result = packed11ToFloat(x);
return reinterpret_cast<float&>(result);
uint Result = packed11ToFloat(x);
# 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)
@ -170,7 +185,14 @@ namespace detail
else if(glm::isinf(x))
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)
@ -182,8 +204,15 @@ namespace detail
else if(x == (0x1f << 5))
return ~0;//Inf
uint result = packed10ToFloat(x);
return reinterpret_cast<float&>(result);
uint Result = packed10ToFloat(x);
# 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)
@ -217,12 +246,12 @@ 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));
}
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 const & p)
GLM_FUNC_QUALIFIER float unpackUnorm1x8(uint8 p)
{
float Unpack(static_cast<float>(p));
return Unpack * static_cast<float>(0.0039215686274509803921568627451); // 1 / 255
@ -235,20 +264,20 @@ namespace detail
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));
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)));
uint8* Packed = reinterpret_cast<uint8*>(&Topack);
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)));
return clamp(
@ -263,7 +292,7 @@ namespace detail
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));
return clamp(
@ -271,12 +300,12 @@ namespace detail
-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));
}
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 const & p)
GLM_FUNC_QUALIFIER float unpackUnorm1x16(uint16 p)
{
float Unpack = static_cast<float>(*const_cast<uint16*>(&p));
return Unpack * 1.5259021896696421759365224689097e-5f; // 1.0 / 65535.0
@ -289,20 +318,20 @@ namespace detail
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));
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));
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
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));
return clamp(
@ -317,7 +346,7 @@ namespace detail
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)));
return clamp(
@ -325,14 +354,14 @@ namespace detail
-1.0f, 1.0f);
}
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float const & v)
GLM_FUNC_QUALIFIER uint16 packHalf1x16(float v)
{
int16 Topack = detail::toFloat16(v);
uint16* Packed = reinterpret_cast<uint16*>(&Topack);
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));
return detail::toFloat32(*Unpack);
@ -350,7 +379,7 @@ namespace detail
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 Unpack(*p);
@ -372,7 +401,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER ivec4 unpackI3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
@ -393,7 +422,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER uvec4 unpackU3x10_1x2(uint32 v)
{
detail::u10u10u10u2 Unpack;
Unpack.pack = v;
@ -414,7 +443,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER vec4 unpackSnorm3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
@ -436,7 +465,7 @@ namespace detail
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 const & v)
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x10_1x2(uint32 v)
{
detail::i10i10i10i2 Unpack;
Unpack.pack = v;
@ -456,7 +485,7 @@ namespace detail
((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(
detail::packed11bitToFloat(v >> 0),

View file

@ -59,7 +59,7 @@ namespace detail
{
enum ctor{null};
typedef T value_type;
typedef T value_type;
typedef tvec4<bool, P> bool_type;
public:

View file

@ -199,10 +199,12 @@ namespace glm
template <>
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());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MAX);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return _nextafterf(x, FLT_MAX);
# else
return nextafterf(x, FLT_MAX);
# endif
@ -211,7 +213,7 @@ namespace glm
template <>
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());
# 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());
@ -231,10 +233,12 @@ namespace glm
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());
# elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
return detail::nextafterf(x, FLT_MIN);
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
return _nextafterf(x, FLT_MIN);
# else
return nextafterf(x, FLT_MIN);
# endif
@ -242,9 +246,9 @@ namespace glm
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());
# 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);
# else
return nextafter(x, DBL_MIN);

View file

@ -57,13 +57,13 @@ namespace detail
struct tdualquat
{
enum ctor{null};
typedef T value_type;
typedef glm::detail::tquat<T, P> part_type;
public:
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
GLM_FUNC_DECL tdualquat();

View file

@ -33,7 +33,7 @@ namespace glm{
namespace detail
{
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;
}

View file

@ -57,178 +57,168 @@
namespace glm
{
/// @addtogroup gtx_io
/// @{
namespace io
{
enum order_type { column_major, row_major, };
template <typename CTy>
class format_punct : public std::locale::facet {
/// @addtogroup gtx_io
/// @{
typedef CTy char_type;
public:
namespace io
{
enum order_type { column_major, row_major};
static std::locale::id id;
template <typename CTy>
class format_punct : public std::locale::facet
{
typedef CTy char_type;
bool formatted;
unsigned precision;
unsigned width;
char_type separator;
char_type delim_left;
char_type delim_right;
char_type space;
char_type newline;
order_type order;
explicit format_punct(size_t a = 0);
explicit format_punct(format_punct const&);
};
public:
template <typename CTy, typename CTr = std::char_traits<CTy> >
class basic_state_saver {
static std::locale::id id;
public:
bool formatted;
unsigned precision;
unsigned width;
char_type separator;
char_type delim_left;
char_type delim_right;
char_type space;
char_type newline;
order_type order;
explicit basic_state_saver(std::basic_ios<CTy,CTr>&);
~basic_state_saver();
explicit format_punct(size_t a = 0);
explicit format_punct(format_punct const&);
};
private:
template <typename CTy, typename CTr = std::char_traits<CTy> >
class basic_state_saver {
typedef ::std::basic_ios<CTy,CTr> state_type;
typedef typename state_type::char_type char_type;
typedef ::std::ios_base::fmtflags flags_type;
typedef ::std::streamsize streamsize_type;
typedef ::std::locale const locale_type;
state_type& state_;
flags_type flags_;
streamsize_type precision_;
streamsize_type width_;
char_type fill_;
locale_type locale_;
basic_state_saver& operator=(basic_state_saver const&);
};
public:
typedef basic_state_saver<char> state_saver;
typedef basic_state_saver<wchar_t> wstate_saver;
template <typename CTy, typename CTr = std::char_traits<CTy> >
class basic_format_saver {
explicit basic_state_saver(std::basic_ios<CTy,CTr>&);
~basic_state_saver();
public:
private:
explicit basic_format_saver(std::basic_ios<CTy,CTr>&);
~basic_format_saver();
typedef ::std::basic_ios<CTy,CTr> state_type;
typedef typename state_type::char_type char_type;
typedef ::std::ios_base::fmtflags flags_type;
typedef ::std::streamsize streamsize_type;
typedef ::std::locale const locale_type;
private:
state_type& state_;
flags_type flags_;
streamsize_type precision_;
streamsize_type width_;
char_type fill_;
locale_type locale_;
basic_state_saver<CTy> const bss_;
basic_state_saver& operator=(basic_state_saver const&);
};
basic_format_saver& operator=(basic_format_saver const&);
};
typedef basic_state_saver<char> state_saver;
typedef basic_state_saver<wchar_t> wstate_saver;
typedef basic_format_saver<char> format_saver;
typedef basic_format_saver<wchar_t> wformat_saver;
struct precision {
template <typename CTy, typename CTr = std::char_traits<CTy> >
class basic_format_saver
{
public:
unsigned value;
explicit precision(unsigned);
};
explicit basic_format_saver(std::basic_ios<CTy,CTr>&);
~basic_format_saver();
struct width {
private:
unsigned value;
explicit width(unsigned);
};
basic_state_saver<CTy> const bss_;
template <typename CTy>
struct delimeter {
basic_format_saver& operator=(basic_format_saver const&);
};
CTy value[3];
explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ',');
};
typedef basic_format_saver<char> format_saver;
typedef basic_format_saver<wchar_t> wformat_saver;
struct order {
struct precision
{
unsigned value;
order_type value;
explicit order(order_type);
};
// functions, inlined (inline)
explicit precision(unsigned);
};
template <typename FTy, typename CTy, typename CTr>
FTy const& get_facet(std::basic_ios<CTy,CTr>&);
template <typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&);
template <typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& unformattet(std::basic_ios<CTy,CTr>&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, width const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&);
}//namespace io
struct width
{
unsigned value;
namespace detail
{
explicit width(unsigned);
};
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&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
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>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&,
std::pair<tmat4x4<T,P> const,
tmat4x4<T,P> const> const&);
}//namespace detail
/// @}
template <typename CTy>
struct delimeter
{
CTy value[3];
explicit delimeter(CTy /* left */, CTy /* right */, CTy /* separator */ = ',');
};
struct order
{
order_type value;
explicit order(order_type);
};
// functions, inlined (inline)
template <typename FTy, typename CTy, typename CTr>
FTy const& get_facet(std::basic_ios<CTy,CTr>&);
template <typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&);
template <typename FTy, typename CTy, typename CTr>
std::basic_ios<CTy,CTr>& unformattet(std::basic_ios<CTy,CTr>&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, width const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, delimeter<CTy> const&);
template <typename CTy, typename CTr>
std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, order const&);
}//namespace io
namespace detail
{
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&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tvec4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat2x4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat3x4<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x2<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr>& operator<<(std::basic_ostream<CTy,CTr>&, tmat4x3<T,P> const&);
template <typename CTy, typename CTr, typename T, precision P>
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>
GLM_FUNC_DECL std::basic_ostream<CTy,CTr> & operator<<(
std::basic_ostream<CTy,CTr> &,
std::pair<tmat4x4<T,P> const,
tmat4x4<T,P> const> const &);
}//namespace detail
/// @}
}//namespace glm
#include "io.inl"

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <limits>
#include "../gtc/constants.hpp"
namespace glm
{
@ -40,7 +41,7 @@ namespace glm
detail::tquat<T, P> const & s2,
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>
@ -52,7 +53,7 @@ namespace glm
)
{
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>
@ -62,7 +63,10 @@ namespace glm
)
{
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);
return detail::tquat<T, P>(cos(Angle), sin(Angle) * v);
}
@ -73,18 +77,20 @@ namespace glm
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))
return detail::tquat<T, P>(log(q.w), T(0), T(0), T(0));
else if(q.w < T(0))
return detail::tquat<T, P>(log(-q.w), T(3.1415926535897932384626433832795), T(0),T(0));
if(q.w > static_cast<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 < static_cast<T>(0))
return detail::tquat<T, P>(log(-q.w), pi<T>(), static_cast<T>(0), static_cast<T>(0));
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());
}
else
{
T Vec3Len = sqrt(q.x * q.x + q.y * q.y + q.z * q.z);
T QuatLen = sqrt(Vec3Len * Vec3Len + q.w * q.w);
T t = atan(Vec3Len, T(q.w)) / Vec3Len;
return detail::tquat<T, P>(log(QuatLen), t * q.x, t * q.y, t * q.z);
@ -98,11 +104,11 @@ namespace glm
T const & y
)
{
if(abs(x.w) > T(0.9999))
if(abs(x.w) > (static_cast<T>(1) - epsilon<T>()))
return x;
float Angle = acos(y);
float NewAngle = Angle * y;
float Div = sin(NewAngle) / sin(Angle);
T Angle = acos(y);
T NewAngle = Angle * y;
T Div = sin(NewAngle) / sin(Angle);
return detail::tquat<T, P>(
cos(NewAngle),
x.x * Div,
@ -146,7 +152,7 @@ namespace glm
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))
return T(0);
else
@ -170,12 +176,12 @@ namespace glm
T const & a
)
{
if(a <= T(0)) return x;
if(a >= T(1)) return y;
if(a <= static_cast<T>(0)) return x;
if(a >= static_cast<T>(1)) return y;
T fCos = dot(x, y);
detail::tquat<T, P> y2(y); //BUG!!! tquat<T> y2;
if(fCos < T(0))
if(fCos < static_cast<T>(0))
{
y2 = -y;
fCos = -fCos;
@ -183,7 +189,7 @@ namespace glm
//if(fCos > 1.0f) // problem
T k0, k1;
if(fCos > T(0.9999))
if(fCos > (static_cast<T>(1) - epsilon<T>()))
{
k0 = static_cast<T>(1) - 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 fAngle = atan(fSin, fCos);
T fOneOverSin = static_cast<T>(1) / fSin;
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
k0 = sin((static_cast<T>(1) - a) * fAngle) * fOneOverSin;
k1 = sin((static_cast<T>(0) + a) * fAngle) * fOneOverSin;
}
return detail::tquat<T, P>(
@ -212,7 +218,7 @@ namespace glm
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>
@ -225,7 +231,7 @@ namespace glm
T cosTheta = dot(orig, dest);
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 :
// there is no "ideal" rotation axis
@ -243,11 +249,11 @@ namespace glm
// Implementation from Stan Melax's Game Programming Gems 1 article
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;
return detail::tquat<T, P>(
s * T(0.5f),
s * static_cast<T>(0.5f),
rotationAxis.x * invs,
rotationAxis.y * invs,
rotationAxis.z * invs);

View file

@ -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

View file

@ -44,8 +44,14 @@ GLM 0.9.6.0: 2014-XX-XX
- Removed GLM_FORCE_RADIANS, active by default
- 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
- 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
- Added GTX_io for io with <iostream> #144
- 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

View file

@ -228,10 +228,10 @@ int test_inverse_perf(std::size_t Instance, char const * Message)
//glm::uint Ulp = 0;
//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;
};
}
int main()
{

View file

@ -94,28 +94,41 @@ int test_std_copy()
int Error = 0;
{
std::vector<glm::dvec4> High4;
std::vector<glm::vec4> Medium4(High4.size());
std::vector<int> High;
High.resize(64);
std::vector<int> Medium(High.size());
std::copy(High.begin(), High.end(), Medium.begin());
std::copy(&High4.begin()[0], &High4.end()[0], Medium4.begin());
*Medium.begin() = *High.begin();
}
{
std::vector<glm::dvec4> High4;
High4.resize(64);
std::vector<glm::vec4> Medium4(High4.size());
std::copy(High4.begin(), High4.end(), Medium4.begin());
*Medium4.begin() = *High4.begin();
}
{
std::vector<glm::dvec3> High3;
High3.resize(64);
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();
}
{
std::vector<glm::dvec2> High2;
High2.resize(64);
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();
}

View file

@ -11,16 +11,54 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/constants.hpp>
int main()
int test_perspective()
{
int Error = 0;
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));
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_mat4 m(0);
glm::lowp_mat4 t = glm::translate(m, v);
return Error;
}
int main()
{
int Error = 0;
Error += test_translate();
Error += test_tweakedInfinitePerspective();
Error += test_pick();
Error += test_perspective();
return Error;
}

View file

@ -100,7 +100,7 @@ int test_Half1x16()
glm::uint32 p0 = glm::packHalf1x16(Tests[i]);
float v0 = glm::unpackHalf1x16(p0);
glm::uint32 p1 = glm::packHalf1x16(v0);
float v1 = glm::unpackHalf1x16(p0);
float v1 = glm::unpackHalf1x16(p1);
Error += (v0 == v1) ? 0 : 1;
}
@ -124,7 +124,7 @@ int test_Half4x16()
glm::uint64 p0 = glm::packHalf4x16(Tests[i]);
glm::vec4 v0 = glm::unpackHalf4x16(p0);
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;
}
@ -148,7 +148,7 @@ int test_I3x10_1x2()
glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]);
glm::ivec4 v0 = glm::unpackI3x10_1x2(p0);
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;
}
@ -172,7 +172,7 @@ int test_U3x10_1x2()
glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]);
glm::uvec4 v0 = glm::unpackU3x10_1x2(p0);
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;
}
@ -196,7 +196,7 @@ int test_Snorm3x10_1x2()
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
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;
}
@ -220,7 +220,7 @@ int test_Unorm3x10_1x2()
glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]);
glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0);
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;
}
@ -244,7 +244,7 @@ int test_F2x11_1x10()
glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]);
glm::vec3 v0 = glm::unpackF2x11_1x10(p0);
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;
}