Fixed std::nextafter not supported with C++11 on Android #213

This commit is contained in:
Christophe Riccio 2014-06-21 15:07:03 +02:00
parent 2b38221f80
commit 08ff93925f
4 changed files with 36 additions and 13 deletions

View File

@ -226,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 = glm::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.
///

View File

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

View File

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

View File

@ -54,7 +54,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 aliasing issues #212, #152
- 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