parent
1951e24cfc
commit
25a5c21a24
41 changed files with 23 additions and 4303 deletions
@ -1,685 +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 gtc_half_float
|
||||
/// @file glm/gtc/half_float.hpp
|
||||
/// @date 2009-04-29 / 2012-11-06
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
///
|
||||
/// @defgroup gtc_half_float GLM_GTC_half_float
|
||||
/// @ingroup gtc
|
||||
///
|
||||
/// Defines the half-precision floating-point type, along with various typedefs for vectors and matrices.
|
||||
/// <glm/gtc/half_float.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLM_GTC_half_float |
||||
#define GLM_GTC_half_float GLM_VERSION |
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp" |
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(glm_ext)) |
||||
# pragma message("GLM: GLM_GTC_half_float extension included") |
||||
#endif |
||||
|
||||
namespace glm{ |
||||
namespace detail |
||||
{ |
||||
#if(GLM_COMPONENT == GLM_COMPONENT_CXX98) |
||||
template <precision P> |
||||
struct tvec2<half, P> |
||||
{ |
||||
enum ctor{_null}; |
||||
typedef half value_type; |
||||
typedef std::size_t size_type; |
||||
|
||||
GLM_FUNC_DECL size_type length() const; |
||||
|
||||
typedef tvec2<half, P> type; |
||||
typedef tvec2<bool, P> bool_type; |
||||
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
|
||||
half x, y; |
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
||||
GLM_FUNC_DECL half & operator[](size_type i); |
||||
GLM_FUNC_DECL half const & operator[](size_type i) const; |
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
|
||||
GLM_FUNC_DECL tvec2(); |
||||
GLM_FUNC_DECL tvec2(tvec2<half, P> const & v); |
||||
|
||||
//////////////////////////////////////
|
||||
// Explicit basic constructors
|
||||
|
||||
GLM_FUNC_DECL explicit tvec2(ctor){} |
||||
GLM_FUNC_DECL explicit tvec2( |
||||
half const & s); |
||||
GLM_FUNC_DECL explicit tvec2( |
||||
half const & s1, |
||||
half const & s2); |
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec2(tref2<half, P> const & r); |
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U> |
||||
GLM_FUNC_DECL explicit tvec2(U const & x); |
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, typename V>
|
||||
GLM_FUNC_DECL explicit tvec2(U const & x, V const & y);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion vector constructors
|
||||
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, precision Q> |
||||
GLM_FUNC_DECL explicit tvec2(tvec2<U, Q> const & v); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, precision Q> |
||||
GLM_FUNC_DECL explicit tvec2(tvec3<U, Q> const & v); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, precision Q> |
||||
GLM_FUNC_DECL explicit tvec2(tvec4<U, Q> const & v); |
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
GLM_FUNC_DECL tvec2<half, P>& operator= (tvec2<half, P> const & v); |
||||
|
||||
GLM_FUNC_DECL tvec2<half, P>& operator+=(half const & s); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator+=(tvec2<half, P> const & v); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator-=(half const & s); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator-=(tvec2<half, P> const & v); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator*=(half const & s); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator*=(tvec2<half, P> const & v); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator/=(half const & s); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator/=(tvec2<half, P> const & v); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator++(); |
||||
GLM_FUNC_DECL tvec2<half, P>& operator--(); |
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle operators
|
||||
|
||||
GLM_FUNC_DECL half swizzle(comp X) const; |
||||
GLM_FUNC_DECL tvec2<half, P> swizzle(comp X, comp Y) const; |
||||
GLM_FUNC_DECL tvec3<half, P> swizzle(comp X, comp Y, comp Z) const; |
||||
GLM_FUNC_DECL tvec4<half, P> swizzle(comp X, comp Y, comp Z, comp W) const; |
||||
GLM_FUNC_DECL tref2<half, P> swizzle(comp X, comp Y); |
||||
}; |
||||
|
||||
template <precision P> |
||||
struct tvec3<half, P> |
||||
{ |
||||
enum ctor{_null}; |
||||
typedef half value_type; |
||||
typedef std::size_t size_type; |
||||
GLM_FUNC_DECL size_type length() const; |
||||
|
||||
typedef tvec3<half, P> type; |
||||
typedef tvec3<bool, P> bool_type; |
||||
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
|
||||
half x, y, z; |
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
||||
GLM_FUNC_DECL half & operator[](size_type i); |
||||
GLM_FUNC_DECL half const & operator[](size_type i) const; |
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
|
||||
GLM_FUNC_DECL tvec3(); |
||||
GLM_FUNC_DECL tvec3(tvec3<half, P> const & v); |
||||
|
||||
//////////////////////////////////////
|
||||
// Explicit basic constructors
|
||||
|
||||
GLM_FUNC_DECL explicit tvec3(ctor){} |
||||
GLM_FUNC_DECL explicit tvec3( |
||||
half const & s); |
||||
GLM_FUNC_DECL explicit tvec3( |
||||
half const & s1, |
||||
half const & s2, |
||||
half const & s3); |
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec3(tref3<half, P> const & r); |
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U> |
||||
GLM_FUNC_DECL explicit tvec3(U const & x); |
||||
|
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, typename V, typename W>
|
||||
GLM_FUNC_DECL explicit tvec3(U const & x, V const & y, W const & z);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion vector constructors
|
||||
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, precision Q> |
||||
GLM_FUNC_DECL explicit tvec3(tvec2<A, Q> const & v, B const & s); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, precision Q> |
||||
GLM_FUNC_DECL explicit tvec3(A const & s, tvec2<B, Q> const & v); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, precision Q> |
||||
GLM_FUNC_DECL explicit tvec3(tvec3<U, Q> const & v); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, precision Q> |
||||
GLM_FUNC_DECL explicit tvec3(tvec4<U, Q> const & v); |
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
GLM_FUNC_DECL tvec3<half, P>& operator= (tvec3<half, P> const & v); |
||||
|
||||
GLM_FUNC_DECL tvec3<half, P>& operator+=(half const & s); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator+=(tvec3<half, P> const & v); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator-=(half const & s); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator-=(tvec3<half, P> const & v); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator*=(half const & s); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator*=(tvec3<half, P> const & v); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator/=(half const & s); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator/=(tvec3<half, P> const & v); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator++(); |
||||
GLM_FUNC_DECL tvec3<half, P>& operator--(); |
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle operators
|
||||
|
||||
GLM_FUNC_DECL half swizzle(comp X) const; |
||||
GLM_FUNC_DECL tvec2<half, P> swizzle(comp X, comp Y) const; |
||||
GLM_FUNC_DECL tvec3<half, P> swizzle(comp X, comp Y, comp Z) const; |
||||
GLM_FUNC_DECL tvec4<half, P> swizzle(comp X, comp Y, comp Z, comp W) const; |
||||
GLM_FUNC_DECL tref3<half, P> swizzle(comp X, comp Y, comp Z); |
||||
}; |
||||
|
||||
template <precision P> |
||||
struct tvec4<half, P> |
||||
{ |
||||
enum ctor{_null}; |
||||
typedef half value_type; |
||||
typedef std::size_t size_type; |
||||
GLM_FUNC_DECL size_type length() const; |
||||
|
||||
typedef tvec4<half, P> type; |
||||
typedef tvec4<bool, P> bool_type; |
||||
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
|
||||
half x, y, z, w; |
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
||||
GLM_FUNC_DECL half & operator[](size_type i); |
||||
GLM_FUNC_DECL half const & operator[](size_type i) const; |
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
|
||||
GLM_FUNC_DECL tvec4(); |
||||
GLM_FUNC_DECL tvec4(tvec4<half, P> const & v); |
||||
|
||||
//////////////////////////////////////
|
||||
// Explicit basic constructors
|
||||
|
||||
|
||||
GLM_FUNC_DECL explicit tvec4(ctor){} |
||||
GLM_FUNC_DECL explicit tvec4( |
||||
half const & s); |
||||
GLM_FUNC_DECL explicit tvec4( |
||||
half const & s0, |
||||
half const & s1, |
||||
half const & s2, |
||||
half const & s3); |
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec4(tref4<half, P> const & r); |
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U> |
||||
GLM_FUNC_DECL explicit tvec4(U const & x); |
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C, typename D> |
||||
GLM_FUNC_DECL explicit tvec4(A const & x, B const & y, C const & z, D const & w);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion vector constructors
|
||||
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & v, B const & s1, C const & s2); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2<B, Q> const & v, C const & s2); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2<C, Q> const & v); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(tvec3<A, Q> const & v, B const & s); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(A const & s, tvec3<B, Q> const & v); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(tvec2<A, Q> const & v1, tvec2<B, Q> const & v2); |
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U, precision Q> |
||||
GLM_FUNC_DECL explicit tvec4(tvec4<U, Q> const & v); |
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
GLM_FUNC_DECL tvec4<half, P>& operator= (tvec4<half, P> const & v); |
||||
|
||||
GLM_FUNC_DECL tvec4<half, P>& operator+=(half const & s); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator+=(tvec4<half, P> const & v); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator-=(half const & s); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator-=(tvec4<half, P> const & v); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator*=(half const & s); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator*=(tvec4<half, P> const & v); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator/=(half const & s); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator/=(tvec4<half, P> const & v); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator++(); |
||||
GLM_FUNC_DECL tvec4<half, P>& operator--(); |
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle operators
|
||||
|
||||
GLM_FUNC_DECL half swizzle(comp X) const; |
||||
GLM_FUNC_DECL tvec2<half, P> swizzle(comp X, comp Y) const; |
||||
GLM_FUNC_DECL tvec3<half, P> swizzle(comp X, comp Y, comp Z) const; |
||||
GLM_FUNC_DECL tvec4<half, P> swizzle(comp X, comp Y, comp Z, comp W) const; |
||||
GLM_FUNC_DECL tref4<half, P> swizzle(comp X, comp Y, comp Z, comp W); |
||||
}; |
||||
#endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98)
|
||||
} |
||||
//namespace detail
|
||||
|
||||
/// @addtogroup gtc_half_float
|
||||
/// @{
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// High half precision floating-point numbers.
|
||||
|
||||
/// Vector of 2 high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec2<half_t, highp> highp_hvec2; |
||||
|
||||
/// Vector of 3 high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec3<half_t, highp> highp_hvec3; |
||||
|
||||
/// Vector of 4 high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec4<half_t, highp> highp_hvec4; |
||||
|
||||
/// 2 * 2 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x2<half_t, highp> highp_hmat2; |
||||
|
||||
/// 3 * 3 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x3<half_t, highp> highp_hmat3; |
||||
|
||||
/// 4 * 4 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x4<half_t, highp> highp_hmat4; |
||||
|
||||
/// 2 * 2 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x2<half_t, highp> highp_hmat2x2; |
||||
|
||||
/// 2 * 3 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x3<half_t, highp> highp_hmat2x3; |
||||
|
||||
/// 2 * 4 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x4<half_t, highp> highp_hmat2x4; |
||||
|
||||
/// 3 * 2 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x2<half_t, highp> highp_hmat3x2; |
||||
|
||||
/// 3 * 3 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x3<half_t, highp> highp_hmat3x3; |
||||
|
||||
/// 3 * 4 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x4<half_t, highp> highp_hmat3x4; |
||||
|
||||
/// 4 * 2 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x2<half_t, highp> highp_hmat4x2; |
||||
|
||||
/// 4 * 3 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x3<half_t, highp> highp_hmat4x3; |
||||
|
||||
/// 4 * 4 matrix of high half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x4<half_t, highp> highp_hmat4x4; |
||||
|
||||
//////////////////////////////////////////////
|
||||
// Medium half precision floating-point numbers.
|
||||
|
||||
/// Vector of 2 medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec2<half_t, mediump> mediump_hvec2; |
||||
|
||||
/// Vector of 3 medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec3<half_t, mediump> mediump_hvec3; |
||||
|
||||
/// Vector of 4 medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec4<half_t, mediump> mediump_hvec4; |
||||
|
||||
/// 2 * 2 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x2<half_t, mediump> mediump_hmat2; |
||||
|
||||
/// 3 * 3 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x3<half_t, mediump> mediump_hmat3; |
||||
|
||||
/// 4 * 4 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x4<half_t, mediump> mediump_hmat4; |
||||
|
||||
/// 2 * 2 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x2<half_t, mediump> mediump_hmat2x2; |
||||
|
||||
/// 2 * 3 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x3<half_t, mediump> mediump_hmat2x3; |
||||
|
||||
/// 2 * 4 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x4<half_t, mediump> mediump_hmat2x4; |
||||
|
||||
/// 3 * 2 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x2<half_t, mediump> mediump_hmat3x2; |
||||
|
||||
/// 3 * 3 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x3<half_t, mediump> mediump_hmat3x3; |
||||
|
||||
/// 3 * 4 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x4<half_t, mediump> mediump_hmat3x4; |
||||
|
||||
/// 4 * 2 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x2<half_t, mediump> mediump_hmat4x2; |
||||
|
||||
/// 4 * 3 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x3<half_t, mediump> mediump_hmat4x3; |
||||
|
||||
/// 4 * 4 matrix of medium half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x4<half_t, mediump> mediump_hmat4x4; |
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Low half precision floating-point numbers.
|
||||
|
||||
/// Vector of 2 low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec2<half_t, lowp> lowp_hvec2; |
||||
|
||||
/// Vector of 3 low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec3<half_t, lowp> lowp_hvec3; |
||||
|
||||
/// Vector of 4 low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tvec4<half_t, lowp> lowp_hvec4; |
||||
|
||||
/// 2 * 2 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x2<half_t, lowp> lowp_hmat2; |
||||
|
||||
/// 3 * 3 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x3<half_t, lowp> lowp_hmat3; |
||||
|
||||
/// 4 * 4 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x4<half_t, lowp> lowp_hmat4; |
||||
|
||||
/// 2 * 2 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x2<half_t, lowp> lowp_hmat2x2; |
||||
|
||||
/// 2 * 3 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x3<half_t, lowp> lowp_hmat2x3; |
||||
|
||||
/// 2 * 4 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat2x4<half_t, lowp> lowp_hmat2x4; |
||||
|
||||
/// 3 * 2 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x2<half_t, lowp> lowp_hmat3x2; |
||||
|
||||
/// 3 * 3 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x3<half_t, lowp> lowp_hmat3x3; |
||||
|
||||
/// 3 * 4 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat3x4<half_t, lowp> lowp_hmat3x4; |
||||
|
||||
/// 4 * 2 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x2<half_t, lowp> lowp_hmat4x2; |
||||
|
||||
/// 4 * 3 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x3<half_t, lowp> lowp_hmat4x3; |
||||
|
||||
/// 4 * 4 matrix of low half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef detail::tmat4x4<half_t, lowp> lowp_hmat4x4; |
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Default half precision floating-point numbers.
|
||||
|
||||
/// Type for default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef half_t half; |
||||
|
||||
|
||||
#if(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && defined(GLM_PRECISION_LOWP_HALF)) |
||||
typedef lowp_hvec2 hvec2; |
||||
typedef lowp_hvec3 hvec3; |
||||
typedef lowp_hvec4 hvec4; |
||||
typedef lowp_hmat2 hmat2; |
||||
typedef lowp_hmat3 hmat3; |
||||
typedef lowp_hmat4 hmat4; |
||||
typedef lowp_hmat2x2 hmat2x2; |
||||
typedef lowp_hmat2x3 hmat2x3; |
||||
typedef lowp_hmat2x4 hmat2x4; |
||||
typedef lowp_hmat3x2 hmat3x2; |
||||
typedef lowp_hmat3x3 hmat3x3; |
||||
typedef lowp_hmat3x4 hmat3x4; |
||||
typedef lowp_hmat4x2 hmat4x2; |
||||
typedef lowp_hmat4x3 hmat4x3; |
||||
typedef lowp_hmat4x4 hmat4x4; |
||||
#elif(!defined(GLM_PRECISION_HIGHP_HALF) && defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) |
||||
typedef mediump_hvec2 hvec2; |
||||
typedef mediump_hvec3 hvec3; |
||||
typedef mediump_hvec4 hvec4; |
||||
typedef mediump_hmat2 hmat2; |
||||
typedef mediump_hmat3 hmat3; |
||||
typedef mediump_hmat4 hmat4; |
||||
typedef mediump_hmat2x2 hmat2x2; |
||||
typedef mediump_hmat2x3 hmat2x3; |
||||
typedef mediump_hmat2x4 hmat2x4; |
||||
typedef mediump_hmat3x2 hmat3x2; |
||||
typedef mediump_hmat3x3 hmat3x3; |
||||
typedef mediump_hmat3x4 hmat3x4; |
||||
typedef mediump_hmat4x2 hmat4x2; |
||||
typedef mediump_hmat4x3 hmat4x3; |
||||
typedef mediump_hmat4x4 hmat4x4; |
||||
#else //(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF))
|
||||
//////////////////////////////////////////////
|
||||
// Default half precision floating-point numbers.
|
||||
|
||||
/// Vector of 2 default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hvec2 hvec2; |
||||
|
||||
/// Vector of 3 default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hvec3 hvec3; |
||||
|
||||
/// Vector of 4 default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hvec4 hvec4; |
||||
|
||||
/// 2 * 2 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat2x2 hmat2; |
||||
|
||||
/// 3 * 3 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat3x3 hmat3; |
||||
|
||||
/// 4 * 4 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat4x4 hmat4; |
||||
|
||||
/// 2 * 2 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat2x2 hmat2x2; |
||||
|
||||
/// 2 * 3 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat2x3 hmat2x3; |
||||
|
||||
/// 2 * 4 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat2x4 hmat2x4; |
||||
|
||||
/// 3 * 2 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat3x2 hmat3x2; |
||||
|
||||
/// 3 * 3 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat3x3 hmat3x3; |
||||
|
||||
/// 3 * 4 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat3x4 hmat3x4; |
||||
|
||||
/// 4 * 2 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat4x2 hmat4x2; |
||||
|
||||
/// 4 * 3 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat4x3 hmat4x3; |
||||
|
||||
/// 4 * 4 matrix of default half-precision floating-point numbers.
|
||||
/// @see gtc_half_float
|
||||
typedef highp_hmat4x4 hmat4x4; |
||||
#endif//GLM_PRECISION
|
||||
|
||||
/// Returns the absolute value of a half-precision floating-point value
|
||||
/// @see gtc_half_float
|
||||
GLM_FUNC_DECL half abs(half const & x); |
||||
|
||||
/// Returns the absolute value of a half-precision floating-point two dimensional vector
|
||||
/// @see gtc_half_float
|
||||
GLM_FUNC_DECL hvec2 abs(hvec2 const & x); |
||||
|
||||
/// Returns the absolute value of a half-precision floating-point three dimensional vector
|
||||
/// @see gtc_half_float
|
||||
GLM_FUNC_DECL hvec3 abs(hvec3 const & x); |
||||
|
||||
/// Returns the absolute value of a half-precision floating-point four dimensional vector
|
||||
/// @see gtc_half_float
|
||||
GLM_FUNC_DECL hvec4 abs(hvec4 const & x); |
||||
|
||||
/// Selects which vector each returned component comes
|
||||
/// from. For a component of <a> that is false, the
|
||||
/// corresponding component of x is returned. For a
|
||||
/// component of a that is true, the corresponding
|
||||
/// component of y is returned. Components of x and y that
|
||||
/// are not selected are allowed to be invalid floating point
|
||||
/// values and will have no effect on the results. Thus, this
|
||||
/// provides different functionality than
|
||||
/// genType mix(genType x, genType y, genType(a))
|
||||
/// where a is a Boolean vector.
|
||||
///
|
||||
/// @see gtc_half_float
|
||||
GLM_FUNC_DECL half mix(half const & x, half const & y, bool const & a); |
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
||||
#include "half_float.inl" |
||||
|
||||
#endif//GLM_GTC_half_float
|
File diff suppressed because it is too large
Load Diff
@ -1,191 +0,0 @@ |
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-08-31
|
||||
// Updated : 2011-09-20
|
||||
// Licence : This source is under MIT licence
|
||||
// File : test/core/type_half.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <glm/gtc/half_float.hpp> |
||||
|
||||
int test_half_ctor() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::half A(1.0f); |
||||
Error += float(A) == 1.0f ? 0 : 1; |
||||
|
||||
glm::half B = glm::half(1.0f); |
||||
Error += float(B) == 1.0f ? 0 : 1; |
||||
|
||||
glm::half C = B; |
||||
Error += float(C) == 1.0f ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_cast() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::half A(2.0f); |
||||
Error += float(A) == 2.0f ? 0 : 1; |
||||
|
||||
glm::half B(2.0); |
||||
Error += float(B) == 2.0f ? 0 : 1; |
||||
|
||||
glm::half C(2); |
||||
Error += float(C) == 2.0f ? 0 : 1; |
||||
|
||||
float D(A); |
||||
Error += D == 2.0f ? 0 : 1; |
||||
|
||||
double E(A); |
||||
Error += E == 2.0 ? 0 : 1; |
||||
|
||||
int F(A); |
||||
Error += F == 2.0 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_relational() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::half A(1.0f); |
||||
glm::half B(2.0f); |
||||
|
||||
Error += !(A == B) ? 0 : 1; |
||||
Error += (A != B) ? 0 : 1; |
||||
Error += (A <= B) ? 0 : 1; |
||||
Error += (A < B) ? 0 : 1; |
||||
Error += !(A >= B) ? 0 : 1; |
||||
Error += !(A > B) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_arithmetic_unary_ops() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
A += B; |
||||
Error += (A == glm::half( 5.0f) ? 0 : 1); |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
A -= B; |
||||
Error += (A == glm::half(-1.0f) ? 0 : 1); |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
B -= A; |
||||
Error += (B == glm::half( 1.0f) ? 0 : 1); |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
A *= B; |
||||
Error += (A == glm::half(6.0f) ? 0 : 1); |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
A /= B; |
||||
Error += (A == glm::half(2.0f / 3.0f) ? 0 : 1); |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
B /= A; |
||||
Error += (B == glm::half(3.0f / 2.0f) ? 0 : 1); |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_arithmetic_binary_ops() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
glm::half A(2.0f); |
||||
glm::half B(3.0f); |
||||
|
||||
Error += A + B == glm::half( 5.0f) ? 0 : 1; |
||||
Error += A - B == glm::half(-1.0f) ? 0 : 1; |
||||
Error += B - A == glm::half( 1.0f) ? 0 : 1; |
||||
Error += A * B == glm::half( 6.0f) ? 0 : 1; |
||||
Error += A / B == glm::half(2.0f / 3.0f) ? 0 : 1; |
||||
Error += B / A == glm::half(3.0f / 2.0f) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_arithmetic_counter_ops() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
Error += A == glm::half(2.0f) ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B = A++; |
||||
Error += B == glm::half(3.0f) ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B = A--; |
||||
Error += B == glm::half(1.0f) ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B = ++A; |
||||
Error += B == glm::half(3.0f) ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B = --A; |
||||
Error += B == glm::half(1.0f) ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::half A(2.0f); |
||||
glm::half B = -A; |
||||
Error += B == glm::half(-2.0f) ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
int Result = 0; |
||||
|
||||
Result += test_half_ctor(); |
||||
Result += test_half_cast(); |
||||
Result += test_half_relational(); |
||||
Result += test_half_arithmetic_unary_ops(); |
||||
Result += test_half_arithmetic_binary_ops(); |
||||
Result += test_half_arithmetic_counter_ops(); |
||||
|
||||
return Result; |
||||
} |
@ -1,845 +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 test
|
||||
/// @file test/gtc/half_float.cpp
|
||||
/// @date 2011-05-32 / 2012-04-07
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include <glm/glm.hpp> |
||||
#include <glm/gtc/half_float.hpp> |
||||
#include <cstdio> |
||||
|
||||
int test_half_precision_scalar() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::half) == 2 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_precision_vec() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hvec2) == 4 ? 0 : 1; |
||||
Error += sizeof(glm::hvec3) == 6 ? 0 : 1; |
||||
Error += sizeof(glm::hvec4) == 8 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_precision_mat() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hmat2) == 8 ? 0 : 1; |
||||
Error += sizeof(glm::hmat3) == 18 ? 0 : 1; |
||||
Error += sizeof(glm::hmat4) == 32 ? 0 : 1; |
||||
|
||||
Error += sizeof(glm::hmat2x2) == 8 ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x3) == 12 ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x4) == 16 ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x2) == 12 ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x3) == 18 ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x4) == 24 ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x2) == 16 ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x3) == 24 ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x4) == 32 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat2x2() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec2 A(1, 2); |
||||
glm::hvec2 B(3, 4); |
||||
glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f);
|
||||
glm::hmat2 D(1, 2, 3, 4); |
||||
|
||||
Error += C[0] == D[0] ? 0 : 1; |
||||
Error += C[1] == D[1] ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec2 A(1, 2.0); |
||||
glm::hvec2 B(3, 4.0); |
||||
glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f);
|
||||
glm::hmat2 D(1, 2.0, 3u, 4.0f); |
||||
|
||||
Error += C[0] == D[0] ? 0 : 1; |
||||
Error += C[1] == D[1] ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat2 A(1); |
||||
glm::mat2 B(1); |
||||
glm::hmat2 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat2x3() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec3 A(1, 2, 3); |
||||
glm::hvec3 B(4, 5, 6); |
||||
glm::hmat2x3 C(A, B); |
||||
glm::hmat2x3 D(1, 2, 3, 4, 5, 6); |
||||
|
||||
Error += C[0] == D[0] ? 0 : 1; |
||||
Error += C[1] == D[1] ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec3 A(1.0, 2.0f, 3u); |
||||
glm::hvec3 B(4, 5u, 6u); |
||||
glm::hmat2x3 C(A, B); |
||||
glm::hmat2x3 D(1, 2.0, 3u, 4.0f, 5.0, 6); |
||||
|
||||
Error += C[0] == D[0] ? 0 : 1; |
||||
Error += C[1] == D[1] ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat2x3 A(1); |
||||
glm::mat2x3 B(1); |
||||
glm::hmat2x3 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat2x4() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec4 A(1, 2, 3, 4); |
||||
glm::hvec4 B(5, 6, 7, 8); |
||||
glm::hmat2x4 C(A, B); |
||||
glm::hmat2x4 D(1, 2, 3, 4, 5, 6, 7, 8); |
||||
|
||||
Error += C[0] == D[0] ? 0 : 1; |
||||
Error += C[1] == D[1] ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec4 A(1.0, 2.0f, 3u, 4u); |
||||
glm::hvec4 B(5u, 6u, 7.0, 8.0); |
||||
glm::hmat2x4 C(A, B); |
||||
glm::hmat2x4 D(1, 2.0, 3u, 4.0f, 5.0, 6, 7.0f, 8.0f); |
||||
|
||||
Error += C[0] == D[0] ? 0 : 1; |
||||
Error += C[1] == D[1] ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat2x4 A(1); |
||||
glm::mat2x4 B(1); |
||||
glm::hmat2x4 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat3x2() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec2 A(1, 2); |
||||
glm::hvec2 B(3, 4); |
||||
glm::hvec2 C(5, 6); |
||||
glm::hmat3x2 M(A, B, C); |
||||
glm::hmat3x2 N(1, 2, 3, 4, 5, 6); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec2 A(1, 2.0); |
||||
glm::hvec2 B(3, 4.0f); |
||||
glm::hvec2 C(5u, 6.0f); |
||||
glm::hmat3x2 M(A, B, C); |
||||
glm::hmat3x2 N(1, 2.0, 3u, 4.0f, 5, 6); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat3x2 A(1); |
||||
glm::mat3x2 B(1); |
||||
glm::hmat3x2 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat3x3() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec3 A(1, 2, 3); |
||||
glm::hvec3 B(4, 5, 6); |
||||
glm::hvec3 C(7, 8, 9); |
||||
glm::hmat3x3 M(A, B, C); |
||||
glm::hmat3x3 N(1, 2, 3, 4, 5, 6, 7, 8, 9); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec3 A(1, 2.0, 3.0f); |
||||
glm::hvec3 B(4, 5.0f, 6.0); |
||||
glm::hvec3 C(7u, 8.0f, 9); |
||||
glm::hmat3x3 M(A, B, C); |
||||
glm::hmat3x3 N(1, 2.0, 3u, 4.0f, 5, 6, 7.0f, 8.0, 9u); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat3x3 A(1); |
||||
glm::mat3x3 B(1); |
||||
glm::hmat3x3 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat3x4() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec4 A(1, 2, 3, 4); |
||||
glm::hvec4 B(5, 6, 7, 8); |
||||
glm::hvec4 C(9, 10, 11, 12); |
||||
glm::hmat3x4 M(A, B, C); |
||||
glm::hmat3x4 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec4 A(1, 2.0, 3.0f, 4u); |
||||
glm::hvec4 B(5, 6.0f, 7.0, 8); |
||||
glm::hvec4 C(9u, 10.0f, 11, 12.f); |
||||
glm::hmat3x4 M(A, B, C); |
||||
glm::hmat3x4 N(1, 2.0, 3u, 4.0f, 5, 6, 7.0f, 8.0, 9u, 10, 11.f, 12.0); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat3x4 A(1); |
||||
glm::mat3x4 B(1); |
||||
glm::hmat3x4 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat4x2() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec2 A(1, 2); |
||||
glm::hvec2 B(3, 4); |
||||
glm::hvec2 C(5, 6); |
||||
glm::hvec2 D(7, 8); |
||||
glm::hmat4x2 M(A, B, C, D); |
||||
glm::hmat4x2 N(1, 2, 3, 4, 5, 6, 7, 8); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec2 A(1, 2.0); |
||||
glm::hvec2 B(3.0f, 4); |
||||
glm::hvec2 C(5.0, 6u); |
||||
glm::hvec2 D(7, 8u); |
||||
glm::hmat4x2 M(A, B, C, D); |
||||
glm::hmat4x2 N(1, 2.0, 3u, 4.0f, 5u, 6.0, 7, 8.0f); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat4x2 A(1); |
||||
glm::mat4x2 B(1); |
||||
glm::hmat4x2 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat4x3() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec3 A(1, 2, 3); |
||||
glm::hvec3 B(4, 5, 6); |
||||
glm::hvec3 C(7, 8, 9); |
||||
glm::hvec3 D(10, 11, 12); |
||||
glm::hmat4x3 M(A, B, C, D); |
||||
glm::hmat4x3 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec3 A(1, 2.0, 3u); |
||||
glm::hvec3 B(4.0f, 5, 6u); |
||||
glm::hvec3 C(7.0, 8u, 9.f); |
||||
glm::hvec3 D(10, 11u, 12.0); |
||||
glm::hmat4x3 M(A, B, C, D); |
||||
glm::hmat4x3 N(1, 2.0, 3u, 4.0f, 5u, 6.0, 7, 8.0f, 9, 10u, 11.f, 12.0); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat4x3 A(1); |
||||
glm::mat4x3 B(1); |
||||
glm::hmat4x3 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_mat4x4() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec4 A(1, 2, 3, 4); |
||||
glm::hvec4 B(5, 6, 7, 8); |
||||
glm::hvec4 C(9, 10, 11, 12); |
||||
glm::hvec4 D(13, 14, 15, 16); |
||||
glm::hmat4x4 M(A, B, C, D); |
||||
glm::hmat4x4 N(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec4 A(1, 2.0, 3u, 4); |
||||
glm::hvec4 B(5.0f, 6, 7u, 8.0); |
||||
glm::hvec4 C(9.0, 10u, 11.f, 12); |
||||
glm::hvec4 D(13, 14u, 15.0, 16u); |
||||
glm::hmat4x4 M(A, B, C, D); |
||||
glm::hmat4x4 N(1, 2.0, 3u, 4.0f, 5u, 6.0, 7, 8.0f, 9, 10u, 11.f, 12.0, 13, 14u, 15.0f, 16.0); |
||||
|
||||
Error += M == N ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hmat4x4 A(1); |
||||
glm::mat4x4 B(1); |
||||
glm::hmat4x4 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_vec2() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec2 A; |
||||
A.x = glm::half(1); |
||||
A.y = glm::half(2); |
||||
//glm::hvec2 A(1, 2);
|
||||
glm::hvec2 B(A); |
||||
glm::vec2 C(1, 2); |
||||
glm::hvec2 D(C); |
||||
glm::dvec2 E(1, 2); |
||||
glm::hvec2 F(E); |
||||
glm::hvec2 G(1, 2.0); |
||||
glm::hvec2 H; |
||||
H = A; |
||||
|
||||
Error += A == B ? 0 : 1; |
||||
//Error += C == D ? 0 : 1; //Error
|
||||
//Error += E == F ? 0 : 1; //Error
|
||||
Error += A == G ? 0 : 1; |
||||
Error += A == H ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec2 A(1); |
||||
glm::vec2 B(1); |
||||
glm::hvec2 C(A); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_vec3() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec3 A(1, 2, 3); |
||||
glm::hvec3 B(A); |
||||
glm::vec3 C(1, 2, 3); |
||||
glm::hvec3 D(C); |
||||
glm::dvec3 E(1, 2, 3); |
||||
glm::hvec3 F(E); |
||||
glm::hvec3 G(1, 2.0, 3); |
||||
glm::hvec3 H; |
||||
H = A; |
||||
|
||||
Error += A == B ? 0 : 1; |
||||
//Error += C == D ? 0 : 1;
|
||||
//Error += E == F ? 0 : 1;
|
||||
Error += A == G ? 0 : 1; |
||||
Error += A == H ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec3 A(1); |
||||
glm::vec3 B(1); |
||||
glm::hvec3 C(B); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_half_ctor_vec4() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
{ |
||||
glm::hvec4 A(1, 2, 3, 4); |
||||
glm::hvec4 B(A); |
||||
glm::vec4 C(1, 2, 3, 4); |
||||
glm::hvec4 D(C); |
||||
glm::dvec4 E(1, 2, 3, 4); |
||||
glm::hvec4 F(E); |
||||
glm::hvec4 G(1, 2.0, 3, 4); |
||||
glm::hvec4 H; |
||||
H = A; |
||||
|
||||
Error += A == B ? 0 : 1; |
||||
//Error += C == D ? 0 : 1;
|
||||
//Error += E == F ? 0 : 1;
|
||||
Error += A == G ? 0 : 1; |
||||
Error += A == H ? 0 : 1; |
||||
} |
||||
|
||||
{ |
||||
glm::hvec4 A(1); |
||||
glm::vec4 B(1); |
||||
glm::hvec4 C(B); |
||||
|
||||
Error += A == C ? 0 : 1; |
||||
} |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_hvec2_size() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hvec2) <= sizeof(glm::lowp_vec2) ? 0 : 1; |
||||
Error += 4 == sizeof(glm::hvec2) ? 0 : 1; |
||||
Error += glm::hvec2().length() == 2 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_hvec3_size() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hvec3) <= sizeof(glm::lowp_vec3) ? 0 : 1; |
||||
Error += 6 <= sizeof(glm::hvec3) ? 0 : 1; |
||||
Error += glm::hvec3().length() == 3 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int test_hvec4_size() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hvec4) <= sizeof(glm::lowp_vec4) ? 0 : 1; |
||||
Error += 8 <= sizeof(glm::hvec4) ? 0 : 1; |
||||
Error += glm::hvec4().length() == 4 ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_hvec_precision() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hvec2) == sizeof(glm::highp_hvec2) ? 0 : 1; |
||||
Error += sizeof(glm::hvec3) == sizeof(glm::highp_hvec3) ? 0 : 1; |
||||
Error += sizeof(glm::hvec4) == sizeof(glm::highp_hvec4) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
static int test_hmat_precision() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += sizeof(glm::hmat2) == sizeof(glm::lowp_hmat2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3) == sizeof(glm::lowp_hmat3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4) == sizeof(glm::lowp_hmat4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2) == sizeof(glm::mediump_hmat2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3) == sizeof(glm::mediump_hmat3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4) == sizeof(glm::mediump_hmat4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2) == sizeof(glm::highp_hmat2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3) == sizeof(glm::highp_hmat3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4) == sizeof(glm::highp_hmat4) ? 0 : 1; |
||||
|
||||
Error += sizeof(glm::hmat2x2) == sizeof(glm::lowp_hmat2x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x2) == sizeof(glm::lowp_hmat3x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x2) == sizeof(glm::lowp_hmat4x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x2) == sizeof(glm::mediump_hmat2x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x2) == sizeof(glm::mediump_hmat3x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x2) == sizeof(glm::mediump_hmat4x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x2) == sizeof(glm::highp_hmat2x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x2) == sizeof(glm::highp_hmat3x2) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x2) == sizeof(glm::highp_hmat4x2) ? 0 : 1; |
||||
|
||||
Error += sizeof(glm::hmat2x3) == sizeof(glm::lowp_hmat2x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x3) == sizeof(glm::lowp_hmat3x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x3) == sizeof(glm::lowp_hmat4x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x3) == sizeof(glm::mediump_hmat2x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x3) == sizeof(glm::mediump_hmat3x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x3) == sizeof(glm::mediump_hmat4x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x3) == sizeof(glm::highp_hmat2x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x3) == sizeof(glm::highp_hmat3x3) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x3) == sizeof(glm::highp_hmat4x3) ? 0 : 1; |
||||
|
||||
Error += sizeof(glm::hmat2x4) == sizeof(glm::lowp_hmat2x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x4) == sizeof(glm::lowp_hmat3x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x4) == sizeof(glm::lowp_hmat4x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x4) == sizeof(glm::mediump_hmat2x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x4) == sizeof(glm::mediump_hmat3x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x4) == sizeof(glm::mediump_hmat4x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat2x4) == sizeof(glm::highp_hmat2x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat3x4) == sizeof(glm::highp_hmat3x4) ? 0 : 1; |
||||
Error += sizeof(glm::hmat4x4) == sizeof(glm::highp_hmat4x4) ? 0 : 1; |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
|
||||
namespace detail |
||||
{ |
||||
glm::uint16 float2half(glm::uint32 const & f) |
||||
{ |
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x00007c00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003ff => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return |
||||
((f >> 16) & 0x8000) | // sign
|
||||
((((f & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | // exponential
|
||||
((f >> 13) & 0x03ff); // Mantissa
|
||||
} |
||||
|
||||
glm::uint16 float2packed11(glm::uint32 const & f) |
||||
{ |
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x000007c0 => 00000000 00000000 00000111 11000000
|
||||
// 0x00007c00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003ff => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return |
||||
((((f & 0x7f800000) - 0x38000000) >> 17) & 0x07c0) | // exponential
|
||||
((f >> 17) & 0x003f); // Mantissa
|
||||
} |
||||
|
||||
glm::uint float2packed10(glm::uint const & f) |
||||
{ |
||||
// 10 bits => EE EEEFFFFF
|
||||
// 11 bits => EEE EEFFFFFF
|
||||
// Half bits => SEEEEEFF FFFFFFFF
|
||||
// Float bits => SEEEEEEE EFFFFFFF FFFFFFFF FFFFFFFF
|
||||
|
||||
// 0x0000001F => 00000000 00000000 00000000 00011111
|
||||
// 0x0000003F => 00000000 00000000 00000000 00111111
|
||||
// 0x000003E0 => 00000000 00000000 00000011 11100000
|
||||
// 0x000007C0 => 00000000 00000000 00000111 11000000
|
||||
// 0x00007C00 => 00000000 00000000 01111100 00000000
|
||||
// 0x000003FF => 00000000 00000000 00000011 11111111
|
||||
// 0x38000000 => 00111000 00000000 00000000 00000000
|
||||
// 0x7f800000 => 01111111 10000000 00000000 00000000
|
||||
// 0x00008000 => 00000000 00000000 10000000 00000000
|
||||
return |
||||
((((f & 0x7f800000) - 0x38000000) >> 18) & 0x03E0) | // exponential
|
||||
((f >> 18) & 0x001f); // Mantissa
|
||||
} |
||||
|
||||
glm::uint half2float(glm::uint const & h) |
||||
{ |
||||
return ((h & 0x8000) << 16) | ((( h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13); |
||||
} |
||||
|
||||
union uif |
||||
{ |
||||
glm::uint i; |
||||
float f; |
||||
}; |
||||
|
||||
glm::uint floatTo11bit(float x) |
||||
{ |
||||
if(x == 0.0f) |
||||
return 0; |
||||
else if(glm::isnan(x)) |
||||
return ~0; |
||||
else if(glm::isinf(x)) |
||||
return 0x1f << 6; |
||||
|
||||
uif Union; |
||||
Union.f = x; |
||||
return float2packed11(Union.i); |
||||
} |
||||
|
||||
glm::uint floatTo10bit(float x) |
||||
{ |
||||
if(x == 0.0f) |
||||
return 0; |
||||
else if(glm::isnan(x)) |
||||
return ~0; |
||||
else if(glm::isinf(x)) |
||||
return 0x1f << 5; |
||||
|
||||
uif Union; |
||||
Union.f = x; |
||||
return float2packed10(Union.i); |
||||
} |
||||
|
||||
glm::uint f11_f11_f10(float x, float y, float z) |
||||
{ |
||||
return ((floatTo11bit(x) & ((1 << 11) - 1)) << 0) | ((floatTo11bit(y) & ((1 << 11) - 1)) << 11) | ((floatTo10bit(z) & ((1 << 10) - 1)) << 22); |
||||
} |
||||
}//namespace detail
|
||||
|
||||
class f11f11f10 |
||||
{ |
||||
public: |
||||
f11f11f10(float x, float y, float z) : |
||||
x(detail::floatTo11bit(x)), |
||||
y(detail::floatTo11bit(y)), |
||||
z(detail::floatTo10bit(z)) |
||||
{} |
||||
/*
|
||||
operator glm::vec3() |
||||
{ |
||||
return glm::vec3( |
||||
float(x) / 511.0f, |
||||
float(y) / 511.0f, |
||||
float(z) / 511.0f); |
||||
} |
||||
*/ |
||||
private: |
||||
int x : 11; |
||||
int y : 11; |
||||
int z : 10; |
||||
}; |
||||
|
||||
void print_bits(glm::half const & s) |
||||
{ |
||||
union
|
||||
{ |
||||
glm::detail::hdata h; |
||||
unsigned short i; |
||||
} uif; |
||||
|
||||
uif.h = s._data(); |
||||
|
||||
printf("f16: "); |
||||
for(std::size_t j = sizeof(s) * 8; j > 0; --j) |
||||
{ |
||||
if(j == 10 || j == 15) |
||||
printf(" "); |
||||
printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); |
||||
} |
||||
} |
||||
|
||||
void print_bits(float const & s) |
||||
{ |
||||
union
|
||||
{ |
||||
float f; |
||||
unsigned int i; |
||||
} uif; |
||||
|
||||
uif.f = s; |
||||
|
||||
printf("f32: "); |
||||
for(std::size_t j = sizeof(s) * 8; j > 0; --j) |
||||
{ |
||||
if(j == 23 || j == 31) |
||||
printf(" "); |
||||
printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); |
||||
} |
||||
} |
||||
|
||||
void print_10bits(glm::uint const & s) |
||||
{ |
||||
printf("10b: "); |
||||
for(std::size_t j = 10; j > 0; --j) |
||||
{ |
||||
if(j == 5) |
||||
printf(" "); |
||||
printf("%d", (s & (1 << (j - 1))) ? 1 : 0); |
||||
} |
||||
} |
||||
|
||||
void print_11bits(glm::uint const & s) |
||||
{ |
||||
printf("11b: "); |
||||
for(std::size_t j = 11; j > 0; --j) |
||||
{ |
||||
if(j == 6) |
||||
printf(" "); |
||||
printf("%d", (s & (1 << (j - 1))) ? 1 : 0); |
||||
} |
||||
} |
||||
|
||||
void print_value(float const & s) |
||||
{ |
||||
printf("%2.5f, ", s); |
||||
print_bits(s); |
||||
printf(", "); |
||||
print_bits(glm::half(s)); |
||||
printf(", "); |
||||
print_11bits(detail::floatTo11bit(s)); |
||||
printf(", "); |
||||
print_10bits(detail::floatTo10bit(s)); |
||||
printf("\n"); |
||||
} |
||||
|
||||
int test_half() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
print_value(0.0); |
||||
print_value(0.1); |
||||
print_value(0.2); |
||||
print_value(0.3); |
||||
print_value(0.4); |
||||
print_value(0.5); |
||||
print_value(0.6); |
||||
print_value(1.0); |
||||
print_value(1.1); |
||||
print_value(1.2); |
||||
print_value(1.3); |
||||
print_value(1.4); |
||||
print_value(1.5); |
||||
print_value(1.6); |
||||
print_value(2.0); |
||||
print_value(2.1); |
||||
print_value(2.2); |
||||
print_value(2.3); |
||||
print_value(2.4); |
||||
print_value(2.5); |
||||
print_value(2.6); |
||||
|
||||
return Error; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
int Error = 0; |
||||
|
||||
Error += test_half(); |
||||
Error += test_hvec_precision(); |
||||
Error += test_hvec2_size(); |
||||
Error += test_hvec3_size(); |
||||
Error += test_hvec4_size(); |
||||
Error += test_half_ctor_vec2(); |
||||
Error += test_half_ctor_vec3(); |
||||
Error += test_half_ctor_vec4(); |
||||
Error += test_half_ctor_mat2x2(); |
||||
Error += test_half_ctor_mat2x3(); |
||||
Error += test_half_ctor_mat2x4(); |
||||
Error += test_half_ctor_mat3x2(); |
||||
Error += test_half_ctor_mat3x3(); |
||||
Error += test_half_ctor_mat3x4(); |
||||
Error += test_half_ctor_mat4x2(); |
||||
Error += test_half_ctor_mat4x3(); |
||||
Error += test_half_ctor_mat4x4(); |
||||
Error += test_half_precision_scalar(); |
||||
Error += test_half_precision_vec(); |
||||
Error += test_half_precision_mat(); |
||||
|
||||
return Error; |
||||
} |
Loading…
Reference in New Issue