From 180788150919da3e9c664002ba5d63147be3fee1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 21 Aug 2013 00:14:02 +0200 Subject: [PATCH] Added packXNorm documentation --- glm/gtc/packing.hpp | 96 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 12 deletions(-) diff --git a/glm/gtc/packing.hpp b/glm/gtc/packing.hpp index 4e5f815c..39f526b9 100644 --- a/glm/gtc/packing.hpp +++ b/glm/gtc/packing.hpp @@ -51,33 +51,105 @@ namespace glm /// @addtogroup gtc_packing /// @{ + /// First, converts the normalized floating-point value v into a 8-bit integer value. + /// Then, the results are packed into the returned 8-bit unsigned integer. + /// + /// The conversion for component c of v to fixed point is done as follows: + /// packUnorm1x8: round(clamp(c, 0, +1) * 255.0) + /// + /// @see GLSL packUnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint8 packUnorm1x8(float const & v); GLM_FUNC_DECL float unpackUnorm1x8(uint8 v); - + + /// First, converts each component of the normalized floating-point value v into 8-bit integer values. + /// Then, the results are packed into the returned 16-bit unsigned integer. + /// + /// The conversion for component c of v to fixed point is done as follows: + /// packUnorm2x8: round(clamp(c, 0, +1) * 255.0) + /// + /// The first component of the vector will be written to the least significant bits of the output; + /// the last component will be written to the most significant bits. + /// + /// @see GLSL packUnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint16 packUnorm2x8(vec2 const & v); GLM_FUNC_DECL vec2 unpackUnorm2x8(uint16 v); - - GLM_FUNC_DECL uint8 packSnorm1x8(float const & v); - GLM_FUNC_DECL float unpackSnorm1x8(uint8 v); + /// First, converts the normalized floating-point value v into 8-bit integer value. + /// Then, the results are packed into the returned 8-bit unsigned integer. + /// + /// The conversion to fixed point is done as follows: + /// packSnorm1x8: round(clamp(s, -1, +1) * 127.0) + /// + /// @see GLSL packSnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions + GLM_FUNC_DECL uint8 packSnorm1x8(float const & s); + GLM_FUNC_DECL float unpackSnorm1x8(uint8 p); + /// First, converts each component of the normalized floating-point value v into 8-bit integer values. + /// Then, the results are packed into the returned 16-bit unsigned integer. + /// + /// The conversion for component c of v to fixed point is done as follows: + /// packSnorm2x8: round(clamp(c, -1, +1) * 127.0) + /// + /// The first component of the vector will be written to the least significant bits of the output; + /// the last component will be written to the most significant bits. + /// + /// @see GLSL packSnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint16 packSnorm2x8(vec2 const & v); - GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 v); - + GLM_FUNC_DECL vec2 unpackSnorm2x8(uint16 p); + /// First, converts the normalized floating-point value v into a 16-bit integer value. + /// Then, the results are packed into the returned 16-bit unsigned integer. + /// + /// The conversion for component c of v to fixed point is done as follows: + /// packUnorm1x16: round(clamp(c, 0, +1) * 65535.0) + /// + /// @see GLSL packUnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint16 packUnorm1x16(float v); - GLM_FUNC_DECL float unpackUnorm1x16(uint16 v); + GLM_FUNC_DECL float unpackUnorm1x16(uint16 p); + /// First, converts each component of the normalized floating-point value v into 16-bit integer values. + /// Then, the results are packed into the returned 64-bit unsigned integer. + /// + /// The conversion for component c of v to fixed point is done as follows: + /// packUnorm4x16: round(clamp(c, 0, +1) * 65535.0) + /// + /// The first component of the vector will be written to the least significant bits of the output; + /// the last component will be written to the most significant bits. + /// + /// @see GLSL packUnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint64 packUnorm4x16(vec4 const & v); - GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 const & v); + GLM_FUNC_DECL vec4 unpackUnorm4x16(uint64 const & p); - + /// First, converts the normalized floating-point value v into 16-bit integer value. + /// Then, the results are packed into the returned 16-bit unsigned integer. + /// + /// The conversion to fixed point is done as follows: + /// packSnorm1x8: round(clamp(s, -1, +1) * 32767.0) + /// + /// @see GLSL packSnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint16 packSnorm1x16(float v); - GLM_FUNC_DECL float unpackSnorm1x16(uint16 v); + GLM_FUNC_DECL float unpackSnorm1x16(uint16 p); + /// First, converts each component of the normalized floating-point value v into 16-bit integer values. + /// Then, the results are packed into the returned 64-bit unsigned integer. + /// + /// The conversion for component c of v to fixed point is done as follows: + /// packSnorm2x8: round(clamp(c, -1, +1) * 32767.0) + /// + /// The first component of the vector will be written to the least significant bits of the output; + /// the last component will be written to the most significant bits. + /// + /// @see GLSL packSnorm4x8 man page + /// @see GLSL 4.20.8 specification, section 8.4 Floating-Point Pack and Unpack Functions GLM_FUNC_DECL uint64 packSnorm4x16(vec4 const & v); - GLM_FUNC_DECL vec4 unpackSnorm4x16(uint64 const & v); - + GLM_FUNC_DECL vec4 unpackSnorm4x16(uint64 const & p); /// Returns an unsigned integer obtained by converting the components of a floating-point scalar /// to the 16-bit floating-point representation found in the OpenGL Specification,