From 296e3d70070f37551513a4ee1ecd426f2b490aca Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 15 Apr 2013 11:04:24 +0200 Subject: [PATCH] Fixed half precision implementation --- glm/core/type_half.hpp | 7 +- glm/core/type_mat.hpp | 104 +++----- glm/core/type_vec.hpp | 272 ++++++++++++++------ glm/fwd.hpp | 95 ++++++- glm/gtc/half_float.hpp | 276 ++++++++++---------- glm/gtc/half_float.inl | 396 ++++++++++++++++++----------- glm/gtc/quaternion.hpp | 15 -- glm/gtc/quaternion.inl | 12 - glm/gtx/dual_quaternion.hpp | 4 +- test/core/core_setup_precision.cpp | 12 + test/core/core_type_vec2.cpp | 6 +- test/gtc/gtc_half_float.cpp | 73 +++++- test/gtc/gtc_quaternion.cpp | 2 +- test/gtx/gtx_bit.cpp | 2 - 14 files changed, 776 insertions(+), 500 deletions(-) diff --git a/glm/core/type_half.hpp b/glm/core/type_half.hpp index fb533f69..5afc7df3 100644 --- a/glm/core/type_half.hpp +++ b/glm/core/type_half.hpp @@ -121,14 +121,15 @@ namespace detail /// High half-precision floating-point numbers. typedef detail::half highp_half; -#if(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) - typedef mediump_half half_t; -#elif(defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) +#if(defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) typedef highp_half half_t; #elif(!defined(GLM_PRECISION_HIGHP_HALF) && defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) typedef mediump_half half_t; #elif(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && defined(GLM_PRECISION_LOWP_HALF)) typedef lowp_half half_t; +#elif(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) + /// Default half-precision floating-point numbers. + typedef highp_half half_t; #else # error "GLM error: Multiple default precisions requested for half-precision floating-point types" #endif diff --git a/glm/core/type_mat.hpp b/glm/core/type_mat.hpp index c12d554f..d0680f3a 100644 --- a/glm/core/type_mat.hpp +++ b/glm/core/type_mat.hpp @@ -370,16 +370,16 @@ namespace detail ////////////////////////// // Float definition -#if(defined(GLM_PRECISION_HIGHP_FLOAT)) - typedef highp_mat2x2 mat2x2; - typedef highp_mat2x3 mat2x3; - typedef highp_mat2x4 mat2x4; - typedef highp_mat3x2 mat3x2; - typedef highp_mat3x3 mat3x3; - typedef highp_mat3x4 mat3x4; - typedef highp_mat4x2 mat4x2; - typedef highp_mat4x3 mat4x3; - typedef highp_mat4x4 mat4x4; +#if(defined(GLM_PRECISION_LOWP_FLOAT)) + typedef lowp_mat2x2 mat2x2; + typedef lowp_mat2x3 mat2x3; + typedef lowp_mat2x4 mat2x4; + typedef lowp_mat3x2 mat3x2; + typedef lowp_mat3x3 mat3x3; + typedef lowp_mat3x4 mat3x4; + typedef lowp_mat4x2 mat4x2; + typedef lowp_mat4x3 mat4x3; + typedef lowp_mat4x4 mat4x4; #elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) typedef mediump_mat2x2 mat2x2; typedef mediump_mat2x3 mat2x3; @@ -390,61 +390,51 @@ namespace detail typedef mediump_mat4x2 mat4x2; typedef mediump_mat4x3 mat4x3; typedef mediump_mat4x4 mat4x4; -#elif(defined(GLM_PRECISION_LOWP_FLOAT)) - typedef lowp_mat2x2 mat2x2; - typedef lowp_mat2x3 mat2x3; - typedef lowp_mat2x4 mat2x4; - typedef lowp_mat3x2 mat3x2; - typedef lowp_mat3x3 mat3x3; - typedef lowp_mat3x4 mat3x4; - typedef lowp_mat4x2 mat4x2; - typedef lowp_mat4x3 mat4x3; - typedef lowp_mat4x4 mat4x4; #else //! 2 columns of 2 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat2x2 mat2x2; + typedef highp_mat2x2 mat2x2; //! 2 columns of 3 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat2x3 mat2x3; + typedef highp_mat2x3 mat2x3; //! 2 columns of 4 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat2x4 mat2x4; + typedef highp_mat2x4 mat2x4; //! 3 columns of 2 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat3x2 mat3x2; + typedef highp_mat3x2 mat3x2; //! 3 columns of 3 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat3x3 mat3x3; + typedef highp_mat3x3 mat3x3; //! 3 columns of 4 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat3x4 mat3x4; + typedef highp_mat3x4 mat3x4; //! 4 columns of 2 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat4x2 mat4x2; + typedef highp_mat4x2 mat4x2; //! 4 columns of 3 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat4x3 mat4x3; + typedef highp_mat4x3 mat4x3; //! 4 columns of 4 components matrix of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_mat4x4 mat4x4; + typedef highp_mat4x4 mat4x4; #endif//GLM_PRECISION @@ -727,16 +717,16 @@ namespace detail /// @} -#if(defined(GLM_PRECISION_HIGHP_DOUBLE)) - typedef highp_dmat2x2 dmat2x2; - typedef highp_dmat2x3 dmat2x3; - typedef highp_dmat2x4 dmat2x4; - typedef highp_dmat3x2 dmat3x2; - typedef highp_dmat3x3 dmat3x3; - typedef highp_dmat3x4 dmat3x4; - typedef highp_dmat4x2 dmat4x2; - typedef highp_dmat4x3 dmat4x3; - typedef highp_dmat4x4 dmat4x4; +#if(defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef lowp_dmat2x2 dmat2x2; + typedef lowp_dmat2x3 dmat2x3; + typedef lowp_dmat2x4 dmat2x4; + typedef lowp_dmat3x2 dmat3x2; + typedef lowp_dmat3x3 dmat3x3; + typedef lowp_dmat3x4 dmat3x4; + typedef lowp_dmat4x2 dmat4x2; + typedef lowp_dmat4x3 dmat4x3; + typedef lowp_dmat4x4 dmat4x4; #elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE)) typedef mediump_dmat2x2 dmat2x2; typedef mediump_dmat2x3 dmat2x3; @@ -747,77 +737,67 @@ namespace detail typedef mediump_dmat4x2 dmat4x2; typedef mediump_dmat4x3 dmat4x3; typedef mediump_dmat4x4 dmat4x4; -#elif(defined(GLM_PRECISION_LOWP_DOUBLE)) - typedef lowp_dmat2x2 dmat2x2; - typedef lowp_dmat2x3 dmat2x3; - typedef lowp_dmat2x4 dmat2x4; - typedef lowp_dmat3x2 dmat3x2; - typedef lowp_dmat3x3 dmat3x3; - typedef lowp_dmat3x4 dmat3x4; - typedef lowp_dmat4x2 dmat4x2; - typedef lowp_dmat4x3 dmat4x3; - typedef lowp_dmat4x4 dmat4x4; -#else +#else //defined(GLM_PRECISION_HIGHP_DOUBLE) //! 2 * 2 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat2x2 dmat2; + typedef highp_dmat2x2 dmat2; //! 3 * 3 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat3x3 dmat3; + typedef highp_dmat3x3 dmat3; //! 4 * 4 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat4x4 dmat4; + typedef highp_dmat4x4 dmat4; //! 2 * 2 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat2x2 dmat2x2; + typedef highp_dmat2x2 dmat2x2; //! 2 * 3 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat2x3 dmat2x3; + typedef highp_dmat2x3 dmat2x3; //! 2 * 4 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat2x4 dmat2x4; + typedef highp_dmat2x4 dmat2x4; //! 3 * 2 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat3x2 dmat3x2; + typedef highp_dmat3x2 dmat3x2; /// 3 * 3 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat3x3 dmat3x3; + typedef highp_dmat3x3 dmat3x3; /// 3 * 4 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat3x4 dmat3x4; + typedef highp_dmat3x4 dmat3x4; /// 4 * 2 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat4x2 dmat4x2; + typedef highp_dmat4x2 dmat4x2; /// 4 * 3 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat4x3 dmat4x3; + typedef highp_dmat4x3 dmat4x3; /// 4 * 4 matrix of double-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.6 Matrices - typedef mediump_dmat4x4 dmat4x4; + typedef highp_dmat4x4 dmat4x4; #endif//GLM_PRECISION diff --git a/glm/core/type_vec.hpp b/glm/core/type_vec.hpp index 0ee6b2a5..c5e74e21 100644 --- a/glm/core/type_vec.hpp +++ b/glm/core/type_vec.hpp @@ -74,27 +74,48 @@ namespace detail /// @addtogroup core_precision /// @{ - /// 2 components vector of high precision floating-point numbers. + /// 2 components vector of high single-precision floating-point numbers. /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec2 highp_vec2; - /// 2 components vector of medium precision floating-point numbers. + /// 2 components vector of medium single-precision floating-point numbers. /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec2 mediump_vec2; - /// 2 components vector of low precision floating-point numbers. + /// 2 components vector of low single-precision floating-point numbers. /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec2 lowp_vec2; + /// 2 components vector of high double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec2 highp_dvec2; + + /// 2 components vector of medium double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec2 mediump_dvec2; + + /// 2 components vector of low double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec2 lowp_dvec2; + /// 2 components vector of high precision signed integer numbers. /// There is no guarantee on the actual precision. /// @@ -136,6 +157,27 @@ namespace detail /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec2 lowp_uvec2; + + /// 2 components vector of high precision bool numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec2 highp_bvec2; + + /// 2 components vector of medium precision bool numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec2 mediump_bvec2; + + /// 2 components vector of low precision bool numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec2 lowp_bvec2; /// @} @@ -143,27 +185,48 @@ namespace detail /// @addtogroup core_precision /// @{ - /// 3 components vector of high precision floating-point numbers. + /// 3 components vector of high single-precision floating-point numbers. /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec3 highp_vec3; - /// 3 components vector of medium precision floating-point numbers. + /// 3 components vector of medium single-precision floating-point numbers. /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec3 mediump_vec3; - /// 3 components vector of low precision floating-point numbers. + /// 3 components vector of low single-precision floating-point numbers. /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec3 lowp_vec3; + /// 3 components vector of high double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec3 highp_dvec3; + + /// 3 components vector of medium double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec3 mediump_dvec3; + + /// 3 components vector of low double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec3 lowp_dvec3; + /// 3 components vector of high precision signed integer numbers. /// There is no guarantee on the actual precision. /// @@ -206,73 +269,118 @@ namespace detail /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec3 lowp_uvec3; + /// 3 components vector of high precision bool numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec3 highp_bvec3; + + /// 3 components vector of medium precision bool numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec3 mediump_bvec3; + + /// 3 components vector of low precision bool numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec3 lowp_bvec3; + /// @} /// @addtogroup core_precision /// @{ - - /// 4 components vector of high precision floating-point numbers. - /// There is no guarantee on the actual precision. + + /// 4 components vector of high single-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 highp_vec4; - /// 4 components vector of medium precision floating-point numbers. - /// There is no guarantee on the actual precision. + /// 4 components vector of medium single-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 mediump_vec4; - /// 4 components vector of low precision floating-point numbers. - /// There is no guarantee on the actual precision. + /// 4 components vector of low single-precision floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 lowp_vec4; + /// 4 components vector of high double-precision floating-point numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec4 highp_dvec4; + + /// 4 components vector of medium double-precision floating-point numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec4 mediump_dvec4; + + /// 4 components vector of low double-precision floating-point numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec4 lowp_dvec4; + /// 4 components vector of high precision signed integer numbers. - /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 highp_ivec4; /// 4 components vector of medium precision signed integer numbers. - /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 mediump_ivec4; /// 4 components vector of low precision signed integer numbers. - /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 lowp_ivec4; /// 4 components vector of high precision unsigned integer numbers. - /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 highp_uvec4; /// 4 components vector of medium precision unsigned integer numbers. - /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 mediump_uvec4; /// 4 components vector of low precision unsigned integer numbers. - /// There is no guarantee on the actual precision. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier typedef detail::tvec4 lowp_uvec4; + + /// 4 components vector of high precision bool numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec4 highp_bvec4; + + /// 4 components vector of medium precision bool numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec4 mediump_bvec4; + + /// 4 components vector of low precision bool numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + /// @see GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier + typedef detail::tvec4 lowp_bvec4; /// @} @@ -280,136 +388,144 @@ namespace detail /// @{ ////////////////////////// - // Float definition + // Default float definition -#if(defined(GLM_PRECISION_HIGHP_FLOAT)) - typedef highp_vec2 vec2; - typedef highp_vec3 vec3; - typedef highp_vec4 vec4; +#if(defined(GLM_PRECISION_LOWP_FLOAT)) + typedef lowp_vec2 vec2; + typedef lowp_vec3 vec3; + typedef lowp_vec4 vec4; #elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) typedef mediump_vec2 vec2; typedef mediump_vec3 vec3; typedef mediump_vec4 vec4; -#elif(defined(GLM_PRECISION_LOWP_FLOAT)) - typedef lowp_vec2 vec2; - typedef lowp_vec3 vec3; - typedef lowp_vec4 vec4; -#else +#else //defined(GLM_PRECISION_HIGHP_FLOAT) /// 2 components vector of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_vec2 vec2; + typedef highp_vec2 vec2; //! 3 components vector of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_vec3 vec3; + typedef highp_vec3 vec3; //! 4 components vector of floating-point numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_vec4 vec4; + typedef highp_vec4 vec4; +#endif//GLM_PRECISION + + ////////////////////////// + // Default double definition + +#if(defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef lowp_dvec2 dvec2; + typedef lowp_dvec3 dvec3; + typedef lowp_dvec4 dvec4; +#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE)) + typedef mediump_dvec2 dvec2; + typedef mediump_dvec3 dvec3; + typedef mediump_dvec4 dvec4; +#else //defined(GLM_PRECISION_HIGHP_DOUBLE) + /// 2 components vector of double-precision floating-point numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + typedef highp_dvec2 dvec2; + + //! 3 components vector of double-precision floating-point numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + typedef highp_dvec3 dvec3; + + //! 4 components vector of double-precision floating-point numbers. + /// + /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors + typedef highp_dvec4 dvec4; #endif//GLM_PRECISION ////////////////////////// // Signed integer definition -#if(defined(GLM_PRECISION_HIGHP_INT)) - typedef highp_ivec2 ivec2; - typedef highp_ivec3 ivec3; - typedef highp_ivec4 ivec4; +#if(defined(GLM_PRECISION_LOWP_INT)) + typedef lowp_ivec2 ivec2; + typedef lowp_ivec3 ivec3; + typedef lowp_ivec4 ivec4; #elif(defined(GLM_PRECISION_MEDIUMP_INT)) typedef mediump_ivec2 ivec2; typedef mediump_ivec3 ivec3; typedef mediump_ivec4 ivec4; -#elif(defined(GLM_PRECISION_LOWP_INT)) - typedef lowp_ivec2 ivec2; - typedef lowp_ivec3 ivec3; - typedef lowp_ivec4 ivec4; -#else +#else //defined(GLM_PRECISION_HIGHP_INT) //! 2 components vector of signed integer numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_ivec2 ivec2; + typedef highp_ivec2 ivec2; //! 3 components vector of signed integer numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_ivec3 ivec3; + typedef highp_ivec3 ivec3; //! 4 components vector of signed integer numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_ivec4 ivec4; + typedef highp_ivec4 ivec4; #endif//GLM_PRECISION ////////////////////////// // Unsigned integer definition -#if(defined(GLM_PRECISION_HIGHP_UINT)) - typedef highp_uvec2 uvec2; - typedef highp_uvec3 uvec3; - typedef highp_uvec4 uvec4; +#if(defined(GLM_PRECISION_LOWP_UINT)) + typedef lowp_uvec2 uvec2; + typedef lowp_uvec3 uvec3; + typedef lowp_uvec4 uvec4; #elif(defined(GLM_PRECISION_MEDIUMP_UINT)) typedef mediump_uvec2 uvec2; typedef mediump_uvec3 uvec3; typedef mediump_uvec4 uvec4; -#elif(defined(GLM_PRECISION_LOWP_UINT)) - typedef lowp_uvec2 uvec2; - typedef lowp_uvec3 uvec3; - typedef lowp_uvec4 uvec4; -#else +#else //defined(GLM_PRECISION_HIGHP_UINT) /// 2 components vector of unsigned integer numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_uvec2 uvec2; + typedef highp_uvec2 uvec2; /// 3 components vector of unsigned integer numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_uvec3 uvec3; + typedef highp_uvec3 uvec3; /// 4 components vector of unsigned integer numbers. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef mediump_uvec4 uvec4; + typedef highp_uvec4 uvec4; #endif//GLM_PRECISION ////////////////////////// // Boolean definition - + +#if(defined(GLM_PRECISION_LOWP_BOOL)) + typedef lowp_bvec2 bvec2; + typedef lowp_bvec3 bvec3; + typedef lowp_bvec4 bvec4; +#elif(defined(GLM_PRECISION_MEDIUMP_BOOL)) + typedef mediump_bvec2 bvec2; + typedef mediump_bvec3 bvec3; + typedef mediump_bvec4 bvec4; +#else //defined(GLM_PRECISION_HIGHP_BOOL) //! 2 components vector of boolean. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef detail::tvec2 bvec2; + typedef highp_bvec2 bvec2; //! 3 components vector of boolean. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef detail::tvec3 bvec3; + typedef highp_bvec3 bvec3; //! 4 components vector of boolean. /// /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef detail::tvec4 bvec4; - - ////////////////////////// - // Double definition - - //! Vector of 2 double-precision floating-point numbers. - /// - /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef detail::tvec2 dvec2; - - //! Vector of 3 double-precision floating-point numbers. - /// - /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef detail::tvec3 dvec3; - - //! Vector of 4 double-precision floating-point numbers. - /// - /// @see GLSL 4.20.8 specification, section 4.1.5 Vectors - typedef detail::tvec4 dvec4; + typedef highp_bvec4 bvec4; +#endif//GLM_PRECISION /// @} }//namespace glm diff --git a/glm/fwd.hpp b/glm/fwd.hpp index 6793e2b0..d4fba7a1 100644 --- a/glm/fwd.hpp +++ b/glm/fwd.hpp @@ -47,40 +47,107 @@ namespace detail template struct tquat; }//namespace detail - /// Quaternion of floating-point numbers. + /// Quaternion of low half-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat quat; + typedef detail::tquat lowp_hquat; - /// Quaternion of half-precision floating-point numbers. + /// Quaternion of medium half-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat hquat; + typedef detail::tquat mediump_hquat; + + /// Quaternion of high half-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat highp_hquat; + +#if(defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) + typedef highp_hquat hquat; +#elif(!defined(GLM_PRECISION_HIGHP_HALF) && defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) + typedef mediump_hquat hquat; +#elif(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && defined(GLM_PRECISION_LOWP_HALF)) + typedef lowp_hquat hquat; +#elif(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) + /// Default half-precision floating-point numbers. + typedef highp_hquat hquat; +#endif + + + /// Quaternion of low single-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat lowp_quat; + + /// Quaternion of medium single-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat mediump_quat; + + /// Quaternion of high single-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat highp_quat; + +#if(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) + typedef highp_quat quat; +#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) + typedef mediump_quat quat; +#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT)) + typedef lowp_quat quat; +#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) + /// Quaternion of default single-precision floating-point numbers. + typedef highp_quat quat; +#endif + + /// Quaternion of low single-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef lowp_quat lowp_fquat; + + /// Quaternion of medium single-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef mediump_quat mediump_fquat; - /// Quaternion of single-precision floating-point numbers. + /// Quaternion of high single-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat fquat; + typedef highp_quat highp_fquat; - /// Quaternion of double-precision floating-point numbers. + /// Quaternion of default single-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat dquat; + typedef quat fquat; - /// Quaternion of low precision floating-point numbers. + + /// Quaternion of low double-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat lowp_quat; + typedef detail::tquat lowp_dquat; - /// Quaternion of medium precision floating-point numbers. + /// Quaternion of medium double-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat mediump_quat; + typedef detail::tquat mediump_dquat; - /// Quaternion of high precision floating-point numbers. + /// Quaternion of high double-precision floating-point numbers. + /// + /// @see gtc_quaternion + typedef detail::tquat highp_dquat; + +#if(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef highp_dquat dquat; +#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef mediump_dquat dquat; +#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef lowp_dquat dquat; +#elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) + /// Quaternion of default double-precision floating-point numbers. /// /// @see gtc_quaternion - typedef detail::tquat highp_quat; + typedef highp_dquat dquat; +#endif }//namespace glm diff --git a/glm/gtc/half_float.hpp b/glm/gtc/half_float.hpp index 1280aa68..c89a5c68 100644 --- a/glm/gtc/half_float.hpp +++ b/glm/gtc/half_float.hpp @@ -48,8 +48,8 @@ namespace glm{ namespace detail { #if(GLM_COMPONENT == GLM_COMPONENT_CXX98) - template <> - struct tvec2 + template + struct tvec2 { enum ctor{null}; typedef half value_type; @@ -58,8 +58,8 @@ namespace detail GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type value_size(); - typedef tvec2 type; - typedef tvec2 bool_type; + typedef tvec2 type; + typedef tvec2 bool_type; ////////////////////////////////////// // Data @@ -76,7 +76,7 @@ namespace detail // Implicit basic constructors tvec2(); - tvec2(tvec2 const & v); + tvec2(tvec2 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -91,7 +91,7 @@ namespace detail ////////////////////////////////////// // Swizzle constructors - tvec2(tref2 const & r); + tvec2(tref2 const & r); ////////////////////////////////////// // Convertion scalar constructors @@ -108,42 +108,42 @@ namespace detail //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec2(tvec2 const & v); + explicit tvec2(tvec2 const & v); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec2(tvec3 const & v); + explicit tvec2(tvec3 const & v); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec2(tvec4 const & v); + explicit tvec2(tvec4 const & v); ////////////////////////////////////// // Unary arithmetic operators - tvec2& operator= (tvec2 const & v); + tvec2& operator= (tvec2 const & v); - tvec2& operator+=(half const & s); - tvec2& operator+=(tvec2 const & v); - tvec2& operator-=(half const & s); - tvec2& operator-=(tvec2 const & v); - tvec2& operator*=(half const & s); - tvec2& operator*=(tvec2 const & v); - tvec2& operator/=(half const & s); - tvec2& operator/=(tvec2 const & v); - tvec2& operator++(); - tvec2& operator--(); + tvec2& operator+=(half const & s); + tvec2& operator+=(tvec2 const & v); + tvec2& operator-=(half const & s); + tvec2& operator-=(tvec2 const & v); + tvec2& operator*=(half const & s); + tvec2& operator*=(tvec2 const & v); + tvec2& operator/=(half const & s); + tvec2& operator/=(tvec2 const & v); + tvec2& operator++(); + tvec2& operator--(); ////////////////////////////////////// // Swizzle operators half swizzle(comp X) const; - tvec2 swizzle(comp X, comp Y) const; - tvec3 swizzle(comp X, comp Y, comp Z) const; - tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; - tref2 swizzle(comp X, comp Y); + tvec2 swizzle(comp X, comp Y) const; + tvec3 swizzle(comp X, comp Y, comp Z) const; + tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; + tref2 swizzle(comp X, comp Y); }; - template <> - struct tvec3 + template + struct tvec3 { enum ctor{null}; typedef half value_type; @@ -151,8 +151,8 @@ namespace detail GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type value_size(); - typedef tvec3 type; - typedef tvec3 bool_type; + typedef tvec3 type; + typedef tvec3 bool_type; ////////////////////////////////////// // Data @@ -169,7 +169,7 @@ namespace detail // Implicit basic constructors tvec3(); - tvec3(tvec3 const & v); + tvec3(tvec3 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -185,7 +185,7 @@ namespace detail ////////////////////////////////////// // Swizzle constructors - tvec3(tref3 const & r); + tvec3(tref3 const & r); ////////////////////////////////////// // Convertion scalar constructors @@ -202,45 +202,45 @@ namespace detail //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec3(tvec2 const & v, B const & s); + explicit tvec3(tvec2 const & v, B const & s); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec3(A const & s, tvec2 const & v); + explicit tvec3(A const & s, tvec2 const & v); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec3(tvec3 const & v); + explicit tvec3(tvec3 const & v); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec3(tvec4 const & v); + explicit tvec3(tvec4 const & v); ////////////////////////////////////// // Unary arithmetic operators - tvec3& operator= (tvec3 const & v); + tvec3& operator= (tvec3 const & v); - tvec3& operator+=(half const & s); - tvec3& operator+=(tvec3 const & v); - tvec3& operator-=(half const & s); - tvec3& operator-=(tvec3 const & v); - tvec3& operator*=(half const & s); - tvec3& operator*=(tvec3 const & v); - tvec3& operator/=(half const & s); - tvec3& operator/=(tvec3 const & v); - tvec3& operator++(); - tvec3& operator--(); + tvec3& operator+=(half const & s); + tvec3& operator+=(tvec3 const & v); + tvec3& operator-=(half const & s); + tvec3& operator-=(tvec3 const & v); + tvec3& operator*=(half const & s); + tvec3& operator*=(tvec3 const & v); + tvec3& operator/=(half const & s); + tvec3& operator/=(tvec3 const & v); + tvec3& operator++(); + tvec3& operator--(); ////////////////////////////////////// // Swizzle operators half swizzle(comp X) const; - tvec2 swizzle(comp X, comp Y) const; - tvec3 swizzle(comp X, comp Y, comp Z) const; - tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; - tref3 swizzle(comp X, comp Y, comp Z); + tvec2 swizzle(comp X, comp Y) const; + tvec3 swizzle(comp X, comp Y, comp Z) const; + tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; + tref3 swizzle(comp X, comp Y, comp Z); }; - template <> - struct tvec4 + template + struct tvec4 { enum ctor{null}; typedef half value_type; @@ -248,8 +248,8 @@ namespace detail GLM_FUNC_DECL size_type length() const; static GLM_FUNC_DECL size_type value_size(); - typedef tvec4 type; - typedef tvec4 bool_type; + typedef tvec4 type; + typedef tvec4 bool_type; ////////////////////////////////////// // Data @@ -266,7 +266,7 @@ namespace detail // Implicit basic constructors tvec4(); - tvec4(tvec4 const & v); + tvec4(tvec4 const & v); ////////////////////////////////////// // Explicit basic constructors @@ -283,7 +283,7 @@ namespace detail ////////////////////////////////////// // Swizzle constructors - tvec4(tref4 const & r); + tvec4(tref4 const & r); ////////////////////////////////////// // Convertion scalar constructors @@ -300,50 +300,50 @@ namespace detail //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec4(tvec2 const & v, B const & s1, C const & s2); + explicit tvec4(tvec2 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 - explicit tvec4(A const & s1, tvec2 const & v, C const & s2); + explicit tvec4(A const & s1, tvec2 const & v, C const & s2); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec4(A const & s1, B const & s2, tvec2 const & v); + explicit tvec4(A const & s1, B const & s2, tvec2 const & v); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec4(tvec3 const & v, B const & s); + explicit tvec4(tvec3 const & v, B const & s); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec4(A const & s, tvec3 const & v); + explicit tvec4(A const & s, tvec3 const & v); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec4(tvec2 const & v1, tvec2 const & v2); + explicit tvec4(tvec2 const & v1, tvec2 const & v2); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - explicit tvec4(tvec4 const & v); + explicit tvec4(tvec4 const & v); ////////////////////////////////////// // Unary arithmetic operators - tvec4& operator= (tvec4 const & v); + tvec4& operator= (tvec4 const & v); - tvec4& operator+=(half const & s); - tvec4& operator+=(tvec4 const & v); - tvec4& operator-=(half const & s); - tvec4& operator-=(tvec4 const & v); - tvec4& operator*=(half const & s); - tvec4& operator*=(tvec4 const & v); - tvec4& operator/=(half const & s); - tvec4& operator/=(tvec4 const & v); - tvec4& operator++(); - tvec4& operator--(); + tvec4& operator+=(half const & s); + tvec4& operator+=(tvec4 const & v); + tvec4& operator-=(half const & s); + tvec4& operator-=(tvec4 const & v); + tvec4& operator*=(half const & s); + tvec4& operator*=(tvec4 const & v); + tvec4& operator/=(half const & s); + tvec4& operator/=(tvec4 const & v); + tvec4& operator++(); + tvec4& operator--(); ////////////////////////////////////// // Swizzle operators half swizzle(comp X) const; - tvec2 swizzle(comp X, comp Y) const; - tvec3 swizzle(comp X, comp Y, comp Z) const; - tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; - tref4 swizzle(comp X, comp Y, comp Z, comp W); + tvec2 swizzle(comp X, comp Y) const; + tvec3 swizzle(comp X, comp Y, comp Z) const; + tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; + tref4 swizzle(comp X, comp Y, comp Z, comp W); }; #endif//(GLM_COMPONENT == GLM_COMPONENT_CXX98) } @@ -548,123 +548,105 @@ namespace detail /// 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 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 mediump_hvec2 hvec2; + typedef highp_hvec2 hvec2; /// Vector of 3 default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hvec3 hvec3; + typedef highp_hvec3 hvec3; /// Vector of 4 default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hvec4 hvec4; + typedef highp_hvec4 hvec4; /// 2 * 2 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat2x2 hmat2; + typedef highp_hmat2x2 hmat2; /// 3 * 3 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat3x3 hmat3; + typedef highp_hmat3x3 hmat3; /// 4 * 4 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat4x4 hmat4; + typedef highp_hmat4x4 hmat4; /// 2 * 2 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat2x2 hmat2x2; + typedef highp_hmat2x2 hmat2x2; /// 2 * 3 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat2x3 hmat2x3; + typedef highp_hmat2x3 hmat2x3; /// 2 * 4 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat2x4 hmat2x4; + typedef highp_hmat2x4 hmat2x4; /// 3 * 2 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat3x2 hmat3x2; + typedef highp_hmat3x2 hmat3x2; /// 3 * 3 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat3x3 hmat3x3; + typedef highp_hmat3x3 hmat3x3; /// 3 * 4 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat3x4 hmat3x4; + typedef highp_hmat3x4 hmat3x4; /// 4 * 2 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat4x2 hmat4x2; + typedef highp_hmat4x2 hmat4x2; /// 4 * 3 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat4x3 hmat4x3; + typedef highp_hmat4x3 hmat4x3; /// 4 * 4 matrix of default half-precision floating-point numbers. /// @see gtc_half_float - typedef mediump_hmat4x4 hmat4x4; - -#elif(defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) - typedef detail::tvec2 hvec2; - typedef detail::tvec3 hvec3; - typedef detail::tvec4 hvec4; - typedef detail::tmat2x2 hmat2; - typedef detail::tmat3x3 hmat3; - typedef detail::tmat4x4 hmat4; - typedef detail::tmat2x2 hmat2x2; - typedef detail::tmat2x3 hmat2x3; - typedef detail::tmat2x4 hmat2x4; - typedef detail::tmat3x2 hmat3x2; - typedef detail::tmat3x3 hmat3x3; - typedef detail::tmat3x4 hmat3x4; - typedef detail::tmat4x2 hmat4x2; - typedef detail::tmat4x3 hmat4x3; - typedef detail::tmat4x4 hmat4x4; - -#elif(!defined(GLM_PRECISION_HIGHP_HALF) && defined(GLM_PRECISION_MEDIUMP_HALF) && !defined(GLM_PRECISION_LOWP_HALF)) - typedef detail::tvec2 hvec2; - typedef detail::tvec3 hvec3; - typedef detail::tvec4 hvec4; - typedef detail::tmat2x2 hmat2; - typedef detail::tmat3x3 hmat3; - typedef detail::tmat4x4 hmat4; - typedef detail::tmat2x2 hmat2x2; - typedef detail::tmat2x3 hmat2x3; - typedef detail::tmat2x4 hmat2x4; - typedef detail::tmat3x2 hmat3x2; - typedef detail::tmat3x3 hmat3x3; - typedef detail::tmat3x4 hmat3x4; - typedef detail::tmat4x2 hmat4x2; - typedef detail::tmat4x3 hmat4x3; - typedef detail::tmat4x4 hmat4x4; - -#elif(!defined(GLM_PRECISION_HIGHP_HALF) && !defined(GLM_PRECISION_MEDIUMP_HALF) && defined(GLM_PRECISION_LOWP_HALF)) - typedef detail::tvec2 hvec2; - typedef detail::tvec3 hvec3; - typedef detail::tvec4 hvec4; - typedef detail::tmat2x2 hmat2; - typedef detail::tmat3x3 hmat3; - typedef detail::tmat4x4 hmat4; - typedef detail::tmat2x2 hmat2x2; - typedef detail::tmat2x3 hmat2x3; - typedef detail::tmat2x4 hmat2x4; - typedef detail::tmat3x2 hmat3x2; - typedef detail::tmat3x3 hmat3x3; - typedef detail::tmat3x4 hmat3x4; - typedef detail::tmat4x2 hmat4x2; - typedef detail::tmat4x3 hmat4x3; - typedef detail::tmat4x4 hmat4x4; -#endif + typedef highp_hmat4x4 hmat4x4; +#endif//GLM_PRECISION /// Returns the absolute value of a half-precision floating-point value /// @see gtc_half_float diff --git a/glm/gtc/half_float.inl b/glm/gtc/half_float.inl index 0a417f42..437dc60e 100644 --- a/glm/gtc/half_float.inl +++ b/glm/gtc/half_float.inl @@ -30,30 +30,27 @@ namespace glm{ namespace detail { #if(GLM_COMPONENT == GLM_COMPONENT_CXX98) - ////////////////////////////////////// // hvec2 - GLM_FUNC_QUALIFIER tvec2::size_type tvec2::length() const - { - return 2; - } + template + GLM_FUNC_QUALIFIER typename tvec2::size_type tvec2::length() const{return 2;} - GLM_FUNC_QUALIFIER tvec2::size_type tvec2::value_size() - { - return 2; - } + template + GLM_FUNC_QUALIFIER typename tvec2::size_type tvec2::value_size(){return 2;} ////////////////////////////////////// // Accesses - GLM_FUNC_QUALIFIER half & tvec2::operator[](tvec2::size_type i) + template + GLM_FUNC_QUALIFIER half & tvec2::operator[](typename tvec2::size_type i) { assert(i < this->length()); return (&x)[i]; } - GLM_FUNC_QUALIFIER half const & tvec2::operator[](tvec2::size_type i) const + template + GLM_FUNC_QUALIFIER half const & tvec2::operator[](typename tvec2::size_type i) const { assert(i < this->length()); return (&x)[i]; @@ -62,14 +59,16 @@ namespace detail ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_QUALIFIER tvec2::tvec2() : + template + GLM_FUNC_QUALIFIER tvec2::tvec2() : x(half(0.f)), y(half(0.f)) {} - GLM_FUNC_QUALIFIER tvec2::tvec2 + template + GLM_FUNC_QUALIFIER tvec2::tvec2 ( - tvec2 const & v + tvec2 const & v ) : x(v.x), y(v.y) @@ -78,7 +77,8 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors - GLM_FUNC_QUALIFIER tvec2::tvec2 + template + GLM_FUNC_QUALIFIER tvec2::tvec2 ( half const & s ) : @@ -86,7 +86,8 @@ namespace detail y(s) {} - GLM_FUNC_QUALIFIER tvec2::tvec2 + template + GLM_FUNC_QUALIFIER tvec2::tvec2 ( half const & s1, half const & s2 @@ -98,9 +99,10 @@ namespace detail ////////////////////////////////////// // Swizzle constructors - GLM_FUNC_QUALIFIER tvec2::tvec2 + template + GLM_FUNC_QUALIFIER tvec2::tvec2 ( - tref2 const & r + tref2 const & r ) : x(r.x), y(r.y) @@ -109,8 +111,9 @@ namespace detail ////////////////////////////////////// // Convertion scalar constructors + template template - GLM_FUNC_QUALIFIER tvec2::tvec2 + GLM_FUNC_QUALIFIER tvec2::tvec2 ( U const & x ) : @@ -118,8 +121,9 @@ namespace detail y(half(x)) {} + template template - GLM_FUNC_QUALIFIER tvec2::tvec2 + GLM_FUNC_QUALIFIER tvec2::tvec2 ( U const & x, V const & y @@ -131,28 +135,31 @@ namespace detail ////////////////////////////////////// // Convertion vector constructors + template template - GLM_FUNC_QUALIFIER tvec2::tvec2 + GLM_FUNC_QUALIFIER tvec2::tvec2 ( - tvec2 const & v + tvec2 const & v ) : x(half(v.x)), y(half(v.y)) {} + template template - GLM_FUNC_QUALIFIER tvec2::tvec2 + GLM_FUNC_QUALIFIER tvec2::tvec2 ( - tvec3 const & v + tvec3 const & v ) : x(half(v.x)), y(half(v.y)) {} + template template - GLM_FUNC_QUALIFIER tvec2::tvec2 + GLM_FUNC_QUALIFIER tvec2::tvec2 ( - tvec4 const & v + tvec4 const & v ) : x(half(v.x)), y(half(v.y)) @@ -161,9 +168,10 @@ namespace detail ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator= ( - tvec2 const & v + tvec2 const & v ) { this->x = v.x; @@ -171,7 +179,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+= ( half const & s ) @@ -181,9 +190,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator+= ( - tvec2 const & v + tvec2 const & v ) { this->x += v.x; @@ -191,7 +201,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-= ( half const & s ) @@ -201,9 +212,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator-= ( - tvec2 const & v + tvec2 const & v ) { this->x -= v.x; @@ -211,7 +223,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2& tvec2::operator*= + template + GLM_FUNC_QUALIFIER tvec2& tvec2::operator*= ( half const & s ) @@ -221,9 +234,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator*= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator*= ( - tvec2 const & v + tvec2 const & v ) { this->x *= v.x; @@ -231,7 +245,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/= ( half const & s ) @@ -241,9 +256,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/= + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator/= ( - tvec2 const & v + tvec2 const & v ) { this->x /= v.x; @@ -251,14 +267,16 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec2 & tvec2::operator++() + template + GLM_FUNC_QUALIFIER tvec2 & tvec2::operator++() { ++this->x; ++this->y; return *this; } - GLM_FUNC_QUALIFIER tvec2& tvec2::operator--() + template + GLM_FUNC_QUALIFIER tvec2& tvec2::operator--() { --this->x; --this->y; @@ -268,38 +286,43 @@ namespace detail ////////////////////////////////////// // Swizzle operators - GLM_FUNC_QUALIFIER half tvec2::swizzle(comp x) const + template + GLM_FUNC_QUALIFIER half tvec2::swizzle(comp x) const { return (*this)[x]; } - GLM_FUNC_QUALIFIER tvec2 tvec2::swizzle(comp x, comp y) const + template + GLM_FUNC_QUALIFIER tvec2 tvec2::swizzle(comp x, comp y) const { - return tvec2( + return tvec2( (*this)[x], (*this)[y]); } - GLM_FUNC_QUALIFIER tvec3 tvec2::swizzle(comp x, comp y, comp z) const + template + GLM_FUNC_QUALIFIER tvec3 tvec2::swizzle(comp x, comp y, comp z) const { - return tvec3( + return tvec3( (*this)[x], (*this)[y], (*this)[z]); } - GLM_FUNC_QUALIFIER tvec4 tvec2::swizzle(comp x, comp y, comp z, comp w) const + template + GLM_FUNC_QUALIFIER tvec4 tvec2::swizzle(comp x, comp y, comp z, comp w) const { - return tvec4( + return tvec4( (*this)[x], (*this)[y], (*this)[z], (*this)[w]); } - GLM_FUNC_QUALIFIER tref2 tvec2::swizzle(comp x, comp y) + template + GLM_FUNC_QUALIFIER tref2 tvec2::swizzle(comp x, comp y) { - return tref2( + return tref2( (*this)[x], (*this)[y]); } @@ -307,12 +330,14 @@ namespace detail ////////////////////////////////////// // hvec3 - GLM_FUNC_QUALIFIER tvec3::size_type tvec3::length() const + template + GLM_FUNC_QUALIFIER typename tvec3::size_type tvec3::length() const { return 3; } - GLM_FUNC_QUALIFIER tvec3::size_type tvec3::value_size() + template + GLM_FUNC_QUALIFIER typename tvec3::size_type tvec3::value_size() { return 3; } @@ -320,9 +345,10 @@ namespace detail ////////////////////////////////////// // Accesses - GLM_FUNC_QUALIFIER half & tvec3::operator[] + template + GLM_FUNC_QUALIFIER half & tvec3::operator[] ( - tvec3::size_type i + tvec3::size_type i ) { assert(i < this->length()); @@ -330,9 +356,10 @@ namespace detail return (&x)[i]; } - GLM_FUNC_QUALIFIER half const & tvec3::operator[] + template + GLM_FUNC_QUALIFIER half const & tvec3::operator[] ( - tvec3::size_type i + tvec3::size_type i ) const { assert(i < this->length()); @@ -343,15 +370,17 @@ namespace detail ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_QUALIFIER tvec3::tvec3() : + template + GLM_FUNC_QUALIFIER tvec3::tvec3() : x(half(0)), y(half(0)), z(half(0)) {} - GLM_FUNC_QUALIFIER tvec3::tvec3 + template + GLM_FUNC_QUALIFIER tvec3::tvec3 ( - tvec3 const & v + tvec3 const & v ) : x(v.x), y(v.y), @@ -361,7 +390,8 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors - GLM_FUNC_QUALIFIER tvec3::tvec3 + template + GLM_FUNC_QUALIFIER tvec3::tvec3 ( half const & s ) : @@ -370,7 +400,8 @@ namespace detail z(s) {} - GLM_FUNC_QUALIFIER tvec3::tvec3 + template + GLM_FUNC_QUALIFIER tvec3::tvec3 ( half const & s0, half const & s1, @@ -384,9 +415,10 @@ namespace detail ////////////////////////////////////// // Swizzle constructors - GLM_FUNC_QUALIFIER tvec3::tvec3 + template + GLM_FUNC_QUALIFIER tvec3::tvec3 ( - tref3 const & r + tref3 const & r ) : x(r.x), y(r.y), @@ -396,8 +428,9 @@ namespace detail ////////////////////////////////////// // Convertion scalar constructors + template template - GLM_FUNC_QUALIFIER tvec3::tvec3 + GLM_FUNC_QUALIFIER tvec3::tvec3 ( U const & x ) : @@ -406,8 +439,9 @@ namespace detail z(half(x)) {} + template template - GLM_FUNC_QUALIFIER tvec3::tvec3 + GLM_FUNC_QUALIFIER tvec3::tvec3 ( A const & x, B const & y, @@ -421,10 +455,11 @@ namespace detail ////////////////////////////////////// // Convertion vector constructors + template template - GLM_FUNC_QUALIFIER tvec3::tvec3 + GLM_FUNC_QUALIFIER tvec3::tvec3 ( - tvec2 const & v, + tvec2 const & v, B const & s ) : x(half(v.x)), @@ -432,31 +467,34 @@ namespace detail z(half(s)) {} + template template - GLM_FUNC_QUALIFIER tvec3::tvec3 + GLM_FUNC_QUALIFIER tvec3::tvec3 ( A const & s, - tvec2 const & v + tvec2 const & v ) : x(half(s)), y(half(v.x)), z(half(v.y)) {} + template template - GLM_FUNC_QUALIFIER tvec3::tvec3 + GLM_FUNC_QUALIFIER tvec3::tvec3 ( - tvec3 const & v + tvec3 const & v ) : x(half(v.x)), y(half(v.y)), z(half(v.z)) {} + template template - GLM_FUNC_QUALIFIER tvec3::tvec3 + GLM_FUNC_QUALIFIER tvec3::tvec3 ( - tvec4 const & v + tvec4 const & v ) : x(half(v.x)), y(half(v.y)), @@ -466,9 +504,10 @@ namespace detail ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator= ( - tvec3 const & v + tvec3 const & v ) { this->x = v.x; @@ -477,7 +516,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= ( half const & s ) @@ -488,9 +528,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= ( - tvec3 const & v + tvec3 const & v ) { this->x += v.x; @@ -499,7 +540,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= ( half const & s ) @@ -510,9 +552,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= ( - tvec3 const & v + tvec3 const & v ) { this->x -= v.x; @@ -521,7 +564,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= ( half const & s ) @@ -532,9 +576,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= ( - tvec3 const & v + tvec3 const & v ) { this->x *= v.x; @@ -543,7 +588,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= ( half const & s ) @@ -554,9 +600,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= ( - tvec3 const & v + tvec3 const & v ) { this->x /= v.x; @@ -565,7 +612,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator++() + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator++() { ++this->x; ++this->y; @@ -573,7 +621,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator--() + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator--() { --this->x; --this->y; @@ -584,38 +633,43 @@ namespace detail ////////////////////////////////////// // Swizzle operators - GLM_FUNC_QUALIFIER half tvec3::swizzle(comp x) const + template + GLM_FUNC_QUALIFIER half tvec3::swizzle(comp x) const { return (*this)[x]; } - GLM_FUNC_QUALIFIER tvec2 tvec3::swizzle(comp x, comp y) const + template + GLM_FUNC_QUALIFIER tvec2 tvec3::swizzle(comp x, comp y) const { - return tvec2( + return tvec2( (*this)[x], (*this)[y]); } - GLM_FUNC_QUALIFIER tvec3 tvec3::swizzle(comp x, comp y, comp z) const + template + GLM_FUNC_QUALIFIER tvec3 tvec3::swizzle(comp x, comp y, comp z) const { - return tvec3( + return tvec3( (*this)[x], (*this)[y], (*this)[z]); } - GLM_FUNC_QUALIFIER tvec4 tvec3::swizzle(comp x, comp y, comp z, comp w) const + template + GLM_FUNC_QUALIFIER tvec4 tvec3::swizzle(comp x, comp y, comp z, comp w) const { - return tvec4( + return tvec4( (*this)[x], (*this)[y], (*this)[z], (*this)[w]); } - GLM_FUNC_QUALIFIER tref3 tvec3::swizzle(comp x, comp y, comp z) + template + GLM_FUNC_QUALIFIER tref3 tvec3::swizzle(comp x, comp y, comp z) { - return tref3( + return tref3( (*this)[x], (*this)[y], (*this)[z]); @@ -624,12 +678,14 @@ namespace detail ////////////////////////////////////// // hvec4 - GLM_FUNC_QUALIFIER tvec4::size_type tvec4::length() const + template + GLM_FUNC_QUALIFIER typename tvec4::size_type tvec4::length() const { return 4; } - GLM_FUNC_QUALIFIER tvec4::size_type tvec4::value_size() + template + GLM_FUNC_QUALIFIER typename tvec4::size_type tvec4::value_size() { return 4; } @@ -637,9 +693,10 @@ namespace detail ////////////////////////////////////// // Accesses - GLM_FUNC_QUALIFIER half & tvec4::operator[] + template + GLM_FUNC_QUALIFIER half & tvec4::operator[] ( - tvec4::size_type i + tvec4::size_type i ) { assert(i < this->length()); @@ -647,9 +704,10 @@ namespace detail return (&x)[i]; } - GLM_FUNC_QUALIFIER half const & tvec4::operator[] + template + GLM_FUNC_QUALIFIER half const & tvec4::operator[] ( - tvec4::size_type i + tvec4::size_type i ) const { assert(i < this->length()); @@ -660,16 +718,18 @@ namespace detail ////////////////////////////////////// // Implicit basic constructors - GLM_FUNC_QUALIFIER tvec4::tvec4() : + template + GLM_FUNC_QUALIFIER tvec4::tvec4() : x(half(0)), y(half(0)), z(half(0)), w(half(0)) {} - GLM_FUNC_QUALIFIER tvec4::tvec4 + template + GLM_FUNC_QUALIFIER tvec4::tvec4 ( - tvec4 const & v + tvec4 const & v ) : x(v.x), y(v.y), @@ -680,7 +740,8 @@ namespace detail ////////////////////////////////////// // Explicit basic constructors - GLM_FUNC_QUALIFIER tvec4::tvec4 + template + GLM_FUNC_QUALIFIER tvec4::tvec4 ( half const & s ) : @@ -690,7 +751,8 @@ namespace detail w(s) {} - GLM_FUNC_QUALIFIER tvec4::tvec4 + template + GLM_FUNC_QUALIFIER tvec4::tvec4 ( half const & s1, half const & s2, @@ -706,9 +768,10 @@ namespace detail ////////////////////////////////////// // Swizzle constructors - GLM_FUNC_QUALIFIER tvec4::tvec4 + template + GLM_FUNC_QUALIFIER tvec4::tvec4 ( - tref4 const & r + tref4 const & r ) : x(r.x), y(r.y), @@ -719,8 +782,9 @@ namespace detail ////////////////////////////////////// // Convertion scalar constructors + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( U const & x ) : @@ -730,8 +794,9 @@ namespace detail w(half(x)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & x, B const & y, @@ -747,10 +812,11 @@ namespace detail ////////////////////////////////////// // Convertion vector constructors + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( - tvec2 const & v, + tvec2 const & v, B const & s1, C const & s2 ) : @@ -760,11 +826,12 @@ namespace detail w(half(s2)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & s1, - tvec2 const & v, + tvec2 const & v, C const & s2 ) : x(half(s1)), @@ -773,12 +840,13 @@ namespace detail w(half(s2)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & s1, B const & s2, - tvec2 const & v + tvec2 const & v ) : x(half(s1)), y(half(s2)), @@ -786,10 +854,11 @@ namespace detail w(half(v.y)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( - tvec3 const & v, + tvec3 const & v, B const & s ) : x(half(v.x)), @@ -798,11 +867,12 @@ namespace detail w(half(s)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & s, - tvec3 const & v + tvec3 const & v ) : x(half(s)), y(half(v.x)), @@ -810,11 +880,12 @@ namespace detail w(half(v.z)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( - tvec2 const & v1, - tvec2 const & v2 + tvec2 const & v1, + tvec2 const & v2 ) : x(half(v1.x)), y(half(v1.y)), @@ -822,10 +893,11 @@ namespace detail w(half(v2.y)) {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 + GLM_FUNC_QUALIFIER tvec4::tvec4 ( - tvec4 const & v + tvec4 const & v ) : x(half(v.x)), y(half(v.y)), @@ -836,9 +908,10 @@ namespace detail ////////////////////////////////////// // Unary arithmetic operators - GLM_FUNC_QUALIFIER tvec4& tvec4::operator= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator= ( - tvec4 const & v + tvec4 const & v ) { this->x = v.x; @@ -848,7 +921,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator+= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator+= ( half const & s ) @@ -860,9 +934,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator+= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator+= ( - tvec4 const & v + tvec4 const & v ) { this->x += v.x; @@ -872,7 +947,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator-= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator-= ( half const & s ) @@ -884,9 +960,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator-= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator-= ( - tvec4 const & v + tvec4 const & v ) { this->x -= v.x; @@ -896,7 +973,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator*= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator*= ( half const & s ) @@ -908,9 +986,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator*= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator*= ( - tvec4 const & v + tvec4 const & v ) { this->x *= v.x; @@ -920,7 +999,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator/= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator/= ( half const & s ) @@ -932,9 +1012,10 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator/= + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator/= ( - tvec4 const & v + tvec4 const & v ) { this->x /= v.x; @@ -944,7 +1025,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator++() + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator++() { ++this->x; ++this->y; @@ -953,7 +1035,8 @@ namespace detail return *this; } - GLM_FUNC_QUALIFIER tvec4& tvec4::operator--() + template + GLM_FUNC_QUALIFIER tvec4& tvec4::operator--() { --this->x; --this->y; @@ -965,38 +1048,43 @@ namespace detail ////////////////////////////////////// // Swizzle operators - GLM_FUNC_QUALIFIER half tvec4::swizzle(comp x) const + template + GLM_FUNC_QUALIFIER half tvec4::swizzle(comp x) const { return (*this)[x]; } - GLM_FUNC_QUALIFIER tvec2 tvec4::swizzle(comp x, comp y) const + template + GLM_FUNC_QUALIFIER tvec2 tvec4::swizzle(comp x, comp y) const { - return tvec2( + return tvec2( (*this)[x], (*this)[y]); } - GLM_FUNC_QUALIFIER tvec3 tvec4::swizzle(comp x, comp y, comp z) const + template + GLM_FUNC_QUALIFIER tvec3 tvec4::swizzle(comp x, comp y, comp z) const { - return tvec3( + return tvec3( (*this)[x], (*this)[y], (*this)[z]); } - GLM_FUNC_QUALIFIER tvec4 tvec4::swizzle(comp x, comp y, comp z, comp w) const + template + GLM_FUNC_QUALIFIER tvec4 tvec4::swizzle(comp x, comp y, comp z, comp w) const { - return tvec4( + return tvec4( (*this)[x], (*this)[y], (*this)[z], (*this)[w]); } - GLM_FUNC_QUALIFIER tref4 tvec4::swizzle(comp x, comp y, comp z, comp w) + template + GLM_FUNC_QUALIFIER tref4 tvec4::swizzle(comp x, comp y, comp z, comp w) { - return tref4( + return tref4( (*this)[x], (*this)[y], (*this)[z], diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 5f8395bc..25a57dc3 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -308,21 +308,6 @@ namespace detail detail::tvec3 axis( detail::tquat const & x); - /// Build a quaternion from an angle and a normalized axis. - /// - /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. - /// @param x x component of the x-axis, x, y, z must be a normalized axis - /// @param y y component of the y-axis, x, y, z must be a normalized axis - /// @param z z component of the z-axis, x, y, z must be a normalized axis - /// - /// @see gtc_quaternion - template - detail::tquat angleAxis( - T const & angle, - T const & x, - T const & y, - T const & z); - /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise. diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 61617572..94d71031 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -754,18 +754,6 @@ namespace detail return detail::tvec3(x.x * tmp2, x.y * tmp2, x.z * tmp2); } - template - GLM_FUNC_QUALIFIER detail::tquat angleAxis - ( - T const & angle, - T const & x, - T const & y, - T const & z - ) - { - return angleAxis(angle, detail::tvec3(x, y, z)); - } - template GLM_FUNC_QUALIFIER detail::tquat angleAxis ( diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index 2e352734..46f6b2cd 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -271,12 +271,12 @@ namespace detail /// Dual-quaternion of floating-point numbers. /// /// @see gtc_dual_quaternion - typedef mediump_fdualquat dualquat; + typedef highp_fdualquat dualquat; /// Dual-quaternion of single-precision floating-point numbers. /// /// @see gtc_dual_quaternion - typedef mediump_fdualquat fdualquat; + typedef highp_fdualquat fdualquat; #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) typedef highp_fdualquat dualquat; typedef highp_fdualquat fdualquat; diff --git a/test/core/core_setup_precision.cpp b/test/core/core_setup_precision.cpp index 8fd009ca..718745cc 100644 --- a/test/core/core_setup_precision.cpp +++ b/test/core/core_setup_precision.cpp @@ -42,12 +42,24 @@ static int test_vec() return Error; } +static int test_dvec() +{ + int Error = 0; + + Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1; + Error += sizeof(glm::dvec3) == sizeof(glm::highp_dvec3) ? 0 : 1; + Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1; + + return Error; +} + int main() { int Error = 0; Error += test_mat(); Error += test_vec(); + Error += test_dvec(); return Error; } diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 662c0b2a..37cc8aba 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -210,8 +210,8 @@ int test_vec2_size() Error += sizeof(glm::vec2) == sizeof(glm::mediump_vec2) ? 0 : 1; Error += 8 == sizeof(glm::mediump_vec2) ? 0 : 1; - Error += sizeof(glm::dvec2) == sizeof(glm::highp_vec2) ? 0 : 1; - Error += 16 == sizeof(glm::highp_vec2) ? 0 : 1; + Error += sizeof(glm::dvec2) == sizeof(glm::highp_dvec2) ? 0 : 1; + Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1; Error += glm::vec2().length() == 2 ? 0 : 1; Error += glm::dvec2().length() == 2 ? 0 : 1; @@ -223,7 +223,7 @@ int main() int Error = 0; Error += test_vec2_size(); - Error += test_vec2_ctor(); + Error += test_vec2_ctor(); Error += test_vec2_operators(); return Error; diff --git a/test/gtc/gtc_half_float.cpp b/test/gtc/gtc_half_float.cpp index 24ac3d2c..04b7dca9 100644 --- a/test/gtc/gtc_half_float.cpp +++ b/test/gtc/gtc_half_float.cpp @@ -46,8 +46,8 @@ int test_half_precision_vec() Error += sizeof(glm::hvec2) == 4 ? 0 : 1; Error += sizeof(glm::hvec3) == 6 ? 0 : 1; Error += sizeof(glm::hvec4) == 8 ? 0 : 1; - - return Error; + + return Error; } int test_half_precision_mat() @@ -68,7 +68,7 @@ int test_half_precision_mat() Error += sizeof(glm::hmat4x3) == 24 ? 0 : 1; Error += sizeof(glm::hmat4x4) == 32 ? 0 : 1; - return Error; + return Error; } int test_half_ctor_mat2x2() @@ -103,7 +103,7 @@ int test_half_ctor_mat2x2() Error += A == C ? 0 : 1; } - return Error; + return Error; } int test_half_ctor_mat2x3() @@ -208,7 +208,7 @@ int test_half_ctor_mat3x2() Error += A == C ? 0 : 1; } - return Error; + return Error; } int test_half_ctor_mat3x3() @@ -243,7 +243,7 @@ int test_half_ctor_mat3x3() Error += A == C ? 0 : 1; } - return Error; + return Error; } int test_half_ctor_mat3x4() @@ -278,7 +278,7 @@ int test_half_ctor_mat3x4() Error += A == C ? 0 : 1; } - return Error; + return Error; } int test_half_ctor_mat4x2() @@ -527,10 +527,69 @@ int test_hvec4_size() 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; +} + int main() { int Error = 0; + Error += test_hvec_precision(); Error += test_hvec2_size(); Error += test_hvec3_size(); Error += test_hvec4_size(); diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index b51e1b4a..9a57f542 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -200,7 +200,7 @@ int test_quat_slerp() // Testing almost equal quaternions (this test should pass through the linear interpolation) // Must be 0 0.00X 0 0.99999 - glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, 0.0f, 1.0f, 0.0f), 0.5f); + glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f); return Error; } diff --git a/test/gtx/gtx_bit.cpp b/test/gtx/gtx_bit.cpp index 1c06b1c1..a6bcffd1 100644 --- a/test/gtx/gtx_bit.cpp +++ b/test/gtx/gtx_bit.cpp @@ -602,7 +602,5 @@ int main() Error += ::extractField::test(); Error += ::bitRevert::test(); - while(true); - return Error; }