diff --git a/glm/core/func_common.hpp b/glm/core/func_common.hpp
index 8d1a6dfd..1457930d 100644
--- a/glm/core/func_common.hpp
+++ b/glm/core/func_common.hpp
@@ -262,7 +262,7 @@ namespace glm
genTypeT const & y,
genTypeU const & a);
- /// Returns 0.0 if x < edge, otherwise it returns 1.0.
+ /// Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
///
/// @see GLSL step man page
/// @see GLSL 4.20.8 specification, section 8.3 Common Functions
@@ -271,10 +271,14 @@ namespace glm
genType const & edge,
genType const & x);
- template
- GLM_FUNC_DECL genType step(
- typename genType::T const & edge,
- genType const & x);
+ /// Returns 0.0 if x < edge, otherwise it returns 1.0.
+ ///
+ /// @see GLSL step man page
+ /// @see GLSL 4.20.8 specification, section 8.3 Common Functions
+ template class vecType, typename T, precision P>
+ GLM_FUNC_DECL vecType step(
+ T const & edge,
+ vecType const & x);
/// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and
/// performs smooth Hermite interpolation between 0 and 1
@@ -331,28 +335,38 @@ namespace glm
GLM_FUNC_DECL typename genType::bool_type isinf(genType const & x);
/// Returns a signed integer value representing
- /// the encoding of a floating-point value. The floatingpoint
+ /// the encoding of a floating-point value. The floating-point
/// value's bit-level representation is preserved.
- ///
- /// @tparam genType Single-precision floating-point scalar or vector types.
- /// @tparam genIType Signed integer scalar or vector types.
///
/// @see GLSL floatBitsToInt man page
/// @see GLSL 4.20.8 specification, section 8.3 Common Functions
- template
- GLM_FUNC_DECL genIType floatBitsToInt(genType const & value);
+ GLM_FUNC_DECL int floatBitsToInt(float const & v);
+
+ /// Returns a signed integer value representing
+ /// the encoding of a floating-point value. The floatingpoint
+ /// value's bit-level representation is preserved.
+ ///
+ /// @see GLSL floatBitsToInt man page
+ /// @see GLSL 4.20.8 specification, section 8.3 Common Functions
+ template class vecType, precision P>
+ GLM_FUNC_DECL vecType floatBitsToInt(vecType const & v);
/// Returns a unsigned integer value representing
/// the encoding of a floating-point value. The floatingpoint
/// value's bit-level representation is preserved.
- ///
- /// @tparam genType Single-precision floating-point scalar or vector types.
- /// @tparam genUType Unsigned integer scalar or vector types.
///
/// @see GLSL floatBitsToUint man page
/// @see GLSL 4.20.8 specification, section 8.3 Common Functions
- template
- GLM_FUNC_DECL genUType floatBitsToUint(genType const & value);
+ GLM_FUNC_DECL uint floatBitsToUint(float const & v);
+
+ /// Returns a unsigned integer value representing
+ /// the encoding of a floating-point value. The floatingpoint
+ /// value's bit-level representation is preserved.
+ ///
+ /// @see GLSL floatBitsToUint man page
+ /// @see GLSL 4.20.8 specification, section 8.3 Common Functions
+ template class vecType, precision P>
+ GLM_FUNC_DECL vecType floatBitsToUint(vecType const & v);
/// Returns a floating-point value corresponding to a signed
/// integer encoding of a floating-point value.
@@ -360,15 +374,20 @@ namespace glm
/// resulting floating point value is unspecified. Otherwise,
/// the bit-level representation is preserved.
///
- /// @tparam genType Single-precision floating-point scalar or vector types.
- /// @tparam genIType Signed integer scalar or vector types.
+ /// @see GLSL intBitsToFloat man page
+ /// @see GLSL 4.20.8 specification, section 8.3 Common Functions
+ GLM_FUNC_DECL float intBitsToFloat(int const & v);
+
+ /// Returns a floating-point value corresponding to a signed
+ /// integer encoding of a floating-point value.
+ /// If an inf or NaN is passed in, it will not signal, and the
+ /// resulting floating point value is unspecified. Otherwise,
+ /// the bit-level representation is preserved.
///
/// @see GLSL intBitsToFloat man page
/// @see GLSL 4.20.8 specification, section 8.3 Common Functions
- ///
- /// @todo Clarify this declaration, we don't need to actually specify the return type
- template
- GLM_FUNC_DECL genType intBitsToFloat(genIType const & value);
+ template class vecType, precision P>
+ GLM_FUNC_DECL vecType intBitsToFloat(vecType const & v);
/// Returns a floating-point value corresponding to a
/// unsigned integer encoding of a floating-point value.
@@ -376,15 +395,20 @@ namespace glm
/// resulting floating point value is unspecified. Otherwise,
/// the bit-level representation is preserved.
///
- /// @tparam genType Single-precision floating-point scalar or vector types.
- /// @tparam genUType Unsigned integer scalar or vector types.
+ /// @see GLSL uintBitsToFloat man page
+ /// @see GLSL 4.20.8 specification, section 8.3 Common Functions
+ GLM_FUNC_DECL float uintBitsToFloat(uint const & v);
+
+ /// Returns a floating-point value corresponding to a
+ /// unsigned integer encoding of a floating-point value.
+ /// If an inf or NaN is passed in, it will not signal, and the
+ /// resulting floating point value is unspecified. Otherwise,
+ /// the bit-level representation is preserved.
///
/// @see GLSL uintBitsToFloat man page
/// @see GLSL 4.20.8 specification, section 8.3 Common Functions
- ///
- /// @todo Clarify this declaration, we don't need to actually specify the return type
- template
- GLM_FUNC_DECL genType uintBitsToFloat(genUType const & value);
+ template class vecType, precision P>
+ GLM_FUNC_DECL vecType uintBitsToFloat(vecType const & v);
/// Computes and returns a * b + c.
///
diff --git a/glm/core/func_common.inl b/glm/core/func_common.inl
index ae37ae0b..c0023ed5 100644
--- a/glm/core/func_common.inl
+++ b/glm/core/func_common.inl
@@ -26,6 +26,10 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
+#include "type_vec2.hpp"
+#include "type_vec3.hpp"
+#include "type_vec4.hpp"
+#include "_vectorize.hpp"
#include
namespace glm{
@@ -708,113 +712,21 @@ namespace detail
genType const & x
)
{
- GLM_STATIC_ASSERT(
- std::numeric_limits::is_iec559,
- "'step' only accept floating-point inputs");
-
- return x < edge ? static_cast(0) : static_cast(1);
+ return mix(genType(1), genType(0), glm::lessThan(x, edge));
}
- template
- GLM_FUNC_QUALIFIER detail::tvec2 step
+ template class vecType, typename T, precision P>
+ GLM_FUNC_QUALIFIER vecType step
(
T const & edge,
- detail::tvec2 const & x
+ vecType const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits::is_iec559,
"'step' only accept floating-point inputs");
- return detail::tvec2(
- x.x < edge ? T(0) : T(1),
- x.y < edge ? T(0) : T(1));
- }
-
- template
- GLM_FUNC_QUALIFIER detail::tvec3 step
- (
- T const & edge,
- detail::tvec3 const & x
- )
- {
- GLM_STATIC_ASSERT(
- std::numeric_limits::is_iec559,
- "'step' only accept floating-point inputs");
-
- return detail::tvec3(
- x.x < edge ? T(0) : T(1),
- x.y < edge ? T(0) : T(1),
- x.z < edge ? T(0) : T(1));
- }
-
- template
- GLM_FUNC_QUALIFIER detail::tvec4 step
- (
- T const & edge,
- detail::tvec4 const & x
- )
- {
- GLM_STATIC_ASSERT(
- std::numeric_limits::is_iec559,
- "'step' only accept floating-point inputs");
-
- return detail::tvec4(
- x.x < edge ? T(0) : T(1),
- x.y < edge ? T(0) : T(1),
- x.z < edge ? T(0) : T(1),
- x.w < edge ? T(0) : T(1));
- }
-
- template
- GLM_FUNC_QUALIFIER detail::tvec2 step
- (
- detail::tvec2 const & edge,
- detail::tvec2 const & x
- )
- {
- GLM_STATIC_ASSERT(
- std::numeric_limits::is_iec559,
- "'step' only accept floating-point inputs");
-
- return detail::tvec2(
- x.x < edge.x ? T(0) : T(1),
- x.y < edge.y ? T(0) : T(1));
- }
-
- template
- GLM_FUNC_QUALIFIER detail::tvec3 step
- (
- detail::tvec3 const & edge,
- detail::tvec3 const & x
- )
- {
- GLM_STATIC_ASSERT(
- std::numeric_limits::is_iec559,
- "'step' only accept floating-point inputs");
-
- return detail::tvec3(
- x.x < edge.x ? T(0) : T(1),
- x.y < edge.y ? T(0) : T(1),
- x.z < edge.z ? T(0) : T(1));
- }
-
- template
- GLM_FUNC_QUALIFIER detail::tvec4 step
- (
- detail::tvec4 const & edge,
- detail::tvec4 const & x
- )
- {
- GLM_STATIC_ASSERT(
- std::numeric_limits::is_iec559,
- "'step' only accept floating-point inputs");
-
- return detail::tvec4(
- x.x < edge.x ? T(0) : T(1),
- x.y < edge.y ? T(0) : T(1),
- x.z < edge.z ? T(0) : T(1),
- x.w < edge.w ? T(0) : T(1));
+ return mix(vecType(1), vecType(0), glm::lessThan(x, vecType(edge)));
}
// smoothstep
@@ -1090,28 +1002,10 @@ namespace detail
return *reinterpret_cast(const_cast(&v));
}
- GLM_FUNC_QUALIFIER detail::tvec2 floatBitsToInt
- (
- detail::tvec2 const & v
- )
+ template class vecType, precision P>
+ GLM_FUNC_QUALIFIER vecType floatBitsToInt(vecType const & v)
{
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec3 floatBitsToInt
- (
- detail::tvec3 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec4 floatBitsToInt
- (
- detail::tvec4 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
+ return *reinterpret_cast*>(const_cast*>(&v));
}
GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v)
@@ -1119,28 +1013,10 @@ namespace detail
return *reinterpret_cast(const_cast(&v));
}
- GLM_FUNC_QUALIFIER detail::tvec2 floatBitsToUint
- (
- detail::tvec2 const & v
- )
+ template class vecType, precision P>
+ GLM_FUNC_QUALIFIER vecType floatBitsToUint(vecType const & v)
{
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec3 floatBitsToUint
- (
- detail::tvec3 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec4 floatBitsToUint
- (
- detail::tvec4 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
+ return *reinterpret_cast*>(const_cast*>(&v));
}
GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v)
@@ -1148,28 +1024,10 @@ namespace detail
return *reinterpret_cast(const_cast(&v));
}
- GLM_FUNC_QUALIFIER detail::tvec2 intBitsToFloat
- (
- detail::tvec2 const & v
- )
+ template class vecType, precision P>
+ GLM_FUNC_QUALIFIER vecType intBitsToFloat(vecType const & v)
{
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec3 intBitsToFloat
- (
- detail::tvec3 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec4 intBitsToFloat
- (
- detail::tvec4 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
+ return *reinterpret_cast*>(const_cast*>(&v));
}
GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v)
@@ -1177,30 +1035,12 @@ namespace detail
return *reinterpret_cast(const_cast(&v));
}
- GLM_FUNC_QUALIFIER detail::tvec2 uintBitsToFloat
- (
- detail::tvec2 const & v
- )
+ template class vecType, precision P>
+ GLM_FUNC_QUALIFIER vecType uintBitsToFloat(vecType const & v)
{
- return *reinterpret_cast*>(const_cast*>(&v));
+ return *reinterpret_cast*>(const_cast*>(&v));
}
-
- GLM_FUNC_QUALIFIER detail::tvec3 uintBitsToFloat
- (
- detail::tvec3 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
- GLM_FUNC_QUALIFIER detail::tvec4 uintBitsToFloat
- (
- detail::tvec4 const & v
- )
- {
- return *reinterpret_cast*>(const_cast*>(&v));
- }
-
+
template
GLM_FUNC_QUALIFIER genType fma
(
diff --git a/glm/core/func_geometric.hpp b/glm/core/func_geometric.hpp
index a49e045c..079a91b2 100644
--- a/glm/core/func_geometric.hpp
+++ b/glm/core/func_geometric.hpp
@@ -36,6 +36,8 @@
#ifndef glm_core_func_geometric
#define glm_core_func_geometric GLM_VERSION
+#include "type_vec3.hpp"
+
namespace glm
{
/// @addtogroup core_func_geometric
@@ -124,11 +126,11 @@ namespace glm
///
/// @see GLSL refract man page
/// @see GLSL 4.20.8 specification, section 8.5 Geometric Functions
- template
- GLM_FUNC_DECL genType refract(
- genType const & I,
- genType const & N,
- typename genType::T const & eta);
+ template class vecType>
+ GLM_FUNC_DECL vecType refract(
+ vecType const & I,
+ vecType const & N,
+ T const & eta);
/// @}
}//namespace glm
diff --git a/glm/core/func_geometric.inl b/glm/core/func_geometric.inl
index 75d1da7b..2832e7c8 100644
--- a/glm/core/func_geometric.inl
+++ b/glm/core/func_geometric.inl
@@ -26,6 +26,8 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
+#include "type_vec2.hpp"
+#include "type_vec4.hpp"
#include "type_float.hpp"
namespace glm
diff --git a/glm/core/func_integer.hpp b/glm/core/func_integer.hpp
index bc0c0c01..87daa476 100644
--- a/glm/core/func_integer.hpp
+++ b/glm/core/func_integer.hpp
@@ -38,6 +38,8 @@
#ifndef glm_core_func_integer
#define glm_core_func_integer GLM_VERSION
+#include "setup.hpp"
+
namespace glm
{
/// @addtogroup core_func_integer
diff --git a/glm/core/func_integer.inl b/glm/core/func_integer.inl
index 03bccdae..4d564f30 100644
--- a/glm/core/func_integer.inl
+++ b/glm/core/func_integer.inl
@@ -26,6 +26,11 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
+#include "type_vec2.hpp"
+#include "type_vec3.hpp"
+#include "type_vec4.hpp"
+#include "type_int.hpp"
+#include "_vectorize.hpp"
#if(GLM_ARCH != GLM_ARCH_PURE)
#if(GLM_COMPILER & GLM_COMPILER_VC)
# include
diff --git a/glm/core/func_noise.hpp b/glm/core/func_noise.hpp
index 0ef0b974..8e9f8ebe 100644
--- a/glm/core/func_noise.hpp
+++ b/glm/core/func_noise.hpp
@@ -38,6 +38,11 @@
#ifndef glm_core_func_noise
#define glm_core_func_noise GLM_VERSION
+#include "type_vec1.hpp"
+#include "type_vec2.hpp"
+#include "type_vec3.hpp"
+#include "setup.hpp"
+
namespace glm
{
/// @addtogroup core_func_noise
diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp
index 221f3aca..466ca7e3 100644
--- a/glm/core/func_packing.hpp
+++ b/glm/core/func_packing.hpp
@@ -36,6 +36,9 @@
#ifndef GLM_CORE_func_packing
#define GLM_CORE_func_packing GLM_VERSION
+#include "type_vec2.hpp"
+#include "type_vec4.hpp"
+
namespace glm
{
/// @addtogroup core_func_packing
@@ -52,7 +55,7 @@ namespace glm
///
/// @see GLSL packUnorm2x16 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL uint32 packUnorm2x16(vec2 const & v);
+ GLM_FUNC_DECL uint packUnorm2x16(vec2 const & v);
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
@@ -65,7 +68,7 @@ namespace glm
///
/// @see GLSL packSnorm2x16 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL uint32 packSnorm2x16(vec2 const & v);
+ GLM_FUNC_DECL uint packSnorm2x16(vec2 const & v);
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
@@ -78,7 +81,7 @@ namespace glm
///
/// @see GLSL packUnorm4x8 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL uint32 packUnorm4x8(vec4 const & v);
+ GLM_FUNC_DECL uint packUnorm4x8(vec4 const & v);
/// First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.
/// Then, the results are packed into the returned 32-bit unsigned integer.
@@ -91,7 +94,7 @@ namespace glm
///
/// @see GLSL packSnorm4x8 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL uint32 packSnorm4x8(vec4 const & v);
+ GLM_FUNC_DECL uint packSnorm4x8(vec4 const & v);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
@@ -104,7 +107,7 @@ namespace glm
///
/// @see GLSL unpackUnorm2x16 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL vec2 unpackUnorm2x16(uint32 const & p);
+ GLM_FUNC_DECL vec2 unpackUnorm2x16(uint const & p);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
@@ -117,7 +120,7 @@ namespace glm
///
/// @see GLSL unpackSnorm2x16 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL vec2 unpackSnorm2x16(uint32 const & p);
+ GLM_FUNC_DECL vec2 unpackSnorm2x16(uint const & p);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
@@ -130,7 +133,7 @@ namespace glm
///
/// @see GLSL unpackUnorm4x8 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL vec4 unpackUnorm4x8(uint32 const & p);
+ GLM_FUNC_DECL vec4 unpackUnorm4x8(uint const & p);
/// First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.
/// Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.
@@ -143,7 +146,7 @@ namespace glm
///
/// @see GLSL unpackSnorm4x8 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL vec4 unpackSnorm4x8(uint32 const & p);
+ GLM_FUNC_DECL vec4 unpackSnorm4x8(uint const & p);
/// Returns a double-precision value obtained by packing the components of v into a 64-bit value.
/// If an IEEE 754 Inf or NaN is created, it will not signal, and the resulting floating point value is unspecified.
@@ -172,7 +175,7 @@ namespace glm
///
/// @see GLSL packHalf2x16 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL uint32 packHalf2x16(vec2 const & v);
+ GLM_FUNC_DECL uint packHalf2x16(vec2 const & v);
/// Returns a two-component floating-point vector with components obtained by unpacking a 32-bit unsigned integer into a pair of 16-bit values,
/// interpreting those values as 16-bit floating-point numbers according to the OpenGL Specification,
@@ -182,7 +185,7 @@ namespace glm
///
/// @see GLSL unpackHalf2x16 man page
/// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions
- GLM_FUNC_DECL vec2 unpackHalf2x16(uint32 const & v);
+ GLM_FUNC_DECL vec2 unpackHalf2x16(uint const & v);
/// @}
}//namespace glm
@@ -190,4 +193,3 @@ namespace glm
#include "func_packing.inl"
#endif//GLM_CORE_func_packing
-
diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl
index 918abe60..eab7753f 100644
--- a/glm/core/func_packing.inl
+++ b/glm/core/func_packing.inl
@@ -26,57 +26,59 @@
/// @author Christophe Riccio
///////////////////////////////////////////////////////////////////////////////////
+#include "func_common.hpp"
#include "type_half.hpp"
+#include "../fwd.hpp"
namespace glm
{
- GLM_FUNC_QUALIFIER uint32 packUnorm2x16(vec2 const & v)
+ GLM_FUNC_QUALIFIER uint packUnorm2x16(vec2 const & v)
{
u16vec2 Topack(round(clamp(v, 0.0f, 1.0f) * 65535.0f));
- return *reinterpret_cast(&Topack);
+ return *reinterpret_cast(&Topack);
}
- GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint32 const & p)
+ GLM_FUNC_QUALIFIER vec2 unpackUnorm2x16(uint const & p)
{
- vec2 Unpack(*reinterpret_cast(const_cast(&p)));
+ vec2 Unpack(*reinterpret_cast(const_cast(&p)));
return Unpack * float(1.5259021896696421759365224689097e-5); // 1.0 / 65535.0
}
- GLM_FUNC_QUALIFIER uint32 packSnorm2x16(vec2 const & v)
+ GLM_FUNC_QUALIFIER uint packSnorm2x16(vec2 const & v)
{
i16vec2 Topack(round(clamp(v ,-1.0f, 1.0f) * 32767.0f));
return *reinterpret_cast(&Topack);
}
- GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint32 const & p)
+ GLM_FUNC_QUALIFIER vec2 unpackSnorm2x16(uint const & p)
{
- vec2 Unpack(*reinterpret_cast(const_cast(&p)));
+ vec2 Unpack(*reinterpret_cast(const_cast(&p)));
return clamp(
Unpack * 3.0518509475997192297128208258309e-5f, //1.0f / 32767.0f,
-1.0f, 1.0f);
}
- GLM_FUNC_QUALIFIER uint32 packUnorm4x8(vec4 const & v)
+ GLM_FUNC_QUALIFIER uint packUnorm4x8(vec4 const & v)
{
u8vec4 Topack(round(clamp(v, 0.0f, 1.0f) * 255.0f));
- return *reinterpret_cast(&Topack);
+ return *reinterpret_cast(&Topack);
}
- GLM_FUNC_QUALIFIER vec4 unpackUnorm4x8(uint32 const & p)
+ GLM_FUNC_QUALIFIER vec4 unpackUnorm4x8(uint const & p)
{
- vec4 Unpack(*reinterpret_cast(const_cast(&p)));
+ vec4 Unpack(*reinterpret_cast(const_cast(&p)));
return Unpack * float(0.0039215686274509803921568627451); // 1 / 255
}
- GLM_FUNC_QUALIFIER uint32 packSnorm4x8(vec4 const & v)
+ GLM_FUNC_QUALIFIER uint packSnorm4x8(vec4 const & v)
{
i8vec4 Topack(round(clamp(v ,-1.0f, 1.0f) * 127.0f));
- return *reinterpret_cast(&Topack);
+ return *reinterpret_cast(&Topack);
}
- GLM_FUNC_QUALIFIER glm::vec4 unpackSnorm4x8(uint32 const & p)
+ GLM_FUNC_QUALIFIER glm::vec4 unpackSnorm4x8(uint const & p)
{
- vec4 Unpack(*reinterpret_cast(const_cast(&p)));
+ vec4 Unpack(*reinterpret_cast(const_cast(&p)));
return clamp(
Unpack * 0.0078740157480315f, // 1.0f / 127.0f
-1.0f, 1.0f);
diff --git a/glm/core/type_float.hpp b/glm/core/type_float.hpp
index 023e2b71..11859338 100644
--- a/glm/core/type_float.hpp
+++ b/glm/core/type_float.hpp
@@ -134,24 +134,6 @@ namespace detail
enum{ID = float_or_int_value::GLM_FLOAT};
};
- union uif32
- {
- GLM_FUNC_QUALIFIER uif32() :
- i(0)
- {}
-
- GLM_FUNC_QUALIFIER uif32(float f) :
- f(f)
- {}
-
- GLM_FUNC_QUALIFIER uif32(uint32 i) :
- i(i)
- {}
-
- float f;
- uint32 i;
- };
-
union uif64
{
GLM_FUNC_QUALIFIER uif64() :
diff --git a/glm/core/type_half.inl b/glm/core/type_half.inl
index fb33cf49..16fb7318 100644
--- a/glm/core/type_half.inl
+++ b/glm/core/type_half.inl
@@ -43,6 +43,24 @@ namespace detail
return f;
}
+ union uif32
+ {
+ GLM_FUNC_QUALIFIER uif32() :
+ i(0)
+ {}
+
+ GLM_FUNC_QUALIFIER uif32(float f) :
+ f(f)
+ {}
+
+ GLM_FUNC_QUALIFIER uif32(uint32 i) :
+ i(i)
+ {}
+
+ float f;
+ uint32 i;
+ };
+
GLM_FUNC_QUALIFIER float toFloat32(hdata value)
{
int s = (value >> 15) & 0x00000001;
diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp
index 385ae2ea..4de6d179 100644
--- a/test/core/core_func_common.cpp
+++ b/test/core/core_func_common.cpp
@@ -10,7 +10,6 @@
//#include
//#include
//#include
-#include
#include
#include
#include
@@ -320,6 +319,57 @@ namespace test_mix
}
}//namespace test_mix
+namespace test_step
+{
+ template
+ struct test
+ {
+ EDGE edge;
+ VEC x;
+ VEC result;
+ };
+
+ test TestVec4Scalar [] =
+ {
+ { 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
+ { 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
+ { 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) }
+ };
+
+ test TestVec4Vector [] =
+ {
+ { glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) },
+ { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) },
+ { glm::vec4( 2.0f, 3.0f, 4.0f, 5.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(0.0f) },
+ { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) }
+ };
+
+ int run()
+ {
+ int Error = 0;
+
+ // vec4 and float
+ {
+ for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(test); ++i)
+ {
+ glm::vec4 Result = glm::step(TestVec4Scalar[i].edge, TestVec4Scalar[i].x);
+ Error += glm::all(glm::epsilonEqual(Result, TestVec4Scalar[i].result, glm::epsilon())) ? 0 : 1;
+ }
+ }
+
+ // vec4 and vec4
+ {
+ for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(test); ++i)
+ {
+ glm::vec4 Result = glm::step(TestVec4Vector[i].edge, TestVec4Vector[i].x);
+ Error += glm::all(glm::epsilonEqual(Result, TestVec4Vector[i].result, glm::epsilon())) ? 0 : 1;
+ }
+ }
+
+ return Error;
+ }
+}//namespace test_step
+
int test_round()
{
int Error = 0;
@@ -582,6 +632,7 @@ int main()
Error += test_modf();
Error += test_floatBitsToInt();
Error += test_floatBitsToUint();
+ Error += test_step::run();
Error += test_mix::run();
Error += test_round();
Error += test_roundEven();
diff --git a/test/core/core_func_geometric.cpp b/test/core/core_func_geometric.cpp
index ee6dbf2a..304a7ae2 100644
--- a/test/core/core_func_geometric.cpp
+++ b/test/core/core_func_geometric.cpp
@@ -7,7 +7,7 @@
// File : test/core/func_geometric.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include
int test_reflect()
diff --git a/test/core/core_func_integer.cpp b/test/core/core_func_integer.cpp
index 0bcc560a..ac803c0a 100644
--- a/test/core/core_func_integer.cpp
+++ b/test/core/core_func_integer.cpp
@@ -7,7 +7,7 @@
// File : test/core/func_integer.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include
enum result
diff --git a/test/core/core_func_noise.cpp b/test/core/core_func_noise.cpp
index 17692eba..24bcb4a2 100644
--- a/test/core/core_func_noise.cpp
+++ b/test/core/core_func_noise.cpp
@@ -7,7 +7,7 @@
// File : test/core/func_noise.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
-#include
+#include
int main()
{
diff --git a/test/core/core_func_packing.cpp b/test/core/core_func_packing.cpp
index a972e426..c149d7b1 100644
--- a/test/core/core_func_packing.cpp
+++ b/test/core/core_func_packing.cpp
@@ -7,7 +7,7 @@
// File : test/core/func_packing.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include
#include
#include