mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Merge branch '0.9.5'
This commit is contained in:
commit
a5ab409ed2
@ -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 "../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")
|
||||
@ -225,7 +226,18 @@ namespace glm
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> tweakedInfinitePerspective(
|
||||
T fovy, T aspect, T near, T epsilon = epsilon<T>());
|
||||
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.
|
||||
///
|
||||
|
@ -267,7 +267,7 @@ namespace glm
|
||||
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(static_cast<T>(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);
|
||||
@ -311,7 +311,7 @@ namespace glm
|
||||
T fovy,
|
||||
T aspect,
|
||||
T zNear,
|
||||
T epsilon
|
||||
T ep
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
@ -328,12 +328,23 @@ namespace glm
|
||||
detail::tmat4x4<T, defaultp> Result(T(0));
|
||||
Result[0][0] = (static_cast<T>(2) * zNear) / (right - left);
|
||||
Result[1][1] = (static_cast<T>(2) * zNear) / (top - bottom);
|
||||
Result[2][2] = epsilon - static_cast<T>(1);
|
||||
Result[2][2] = ep - static_cast<T>(1);
|
||||
Result[2][3] = static_cast<T>(-1);
|
||||
Result[3][2] = (epsilon - static_cast<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
|
||||
(
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
@ -199,9 +199,9 @@ 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)))
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MAX);
|
||||
# else
|
||||
return nextafterf(x, FLT_MAX);
|
||||
@ -211,9 +211,9 @@ 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)))
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafter(x, std::numeric_limits<double>::max());
|
||||
# else
|
||||
return nextafter(x, DBL_MAX);
|
||||
@ -231,9 +231,9 @@ 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)))
|
||||
# elif((GLM_PLATFORM & GLM_PLATFORM_ANDROID) || (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
return detail::nextafterf(x, FLT_MIN);
|
||||
# else
|
||||
return nextafterf(x, FLT_MIN);
|
||||
@ -242,9 +242,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);
|
||||
|
@ -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
|
@ -62,6 +62,8 @@ GLM 0.9.5.4: 2014-0X-XX
|
||||
- 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
|
||||
|
||||
================================================================================
|
||||
GLM 0.9.5.3: 2014-04-02
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user