diff --git a/CMakeLists.txt b/CMakeLists.txt index 3679967b..e5f3c7be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) endif() include_directories(".") +include_directories("./test/external") add_subdirectory(glm) add_subdirectory(test) diff --git a/glm/core/func_common.hpp b/glm/core/func_common.hpp index 8a1de5ad..5e06e24d 100644 --- a/glm/core/func_common.hpp +++ b/glm/core/func_common.hpp @@ -24,48 +24,51 @@ /// @file glm/core/func_common.hpp /// @date 2008-03-08 / 2010-01-26 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.2 +/// +/// @defgroup core_func_common Common functions +/// @ingroup core +/// +/// These all operate component-wise. The description is per component. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_common -#define glm_core_func_common +#ifndef GLM_CORE_func_common +#define GLM_CORE_func_common GLM_VERSION #include "_fixes.hpp" namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_common /// @{ /// Returns x if x >= 0; otherwise, it returns -x. /// - /// @see - /// @li GLSL abs man page - /// @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL abs man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genFIType abs(genFIType const & x); /// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. /// - /// @see - /// @li GLSL sign man page - /// @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL sign man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genFIType sign(genFIType const & x); //! Returns a value equal to the nearest integer that is less then or equal to x. //! - /// @see - //! @li GLSL floor man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL floor man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType floor(genType const & x); //! Returns a value equal to the nearest integer to x //! whose absolute value is not larger than the absolute value of x. //! - /// @see - //! @li GLSL trunc man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL trunc man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType trunc(genType const & x); @@ -75,9 +78,8 @@ namespace glm //! This includes the possibility that round(x) returns the //! same value as roundEven(x) for all values of x. //! - /// @see - //! @li GLSL round man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL round man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType round(genType const & x); @@ -85,35 +87,31 @@ namespace glm //! A fractional part of 0.5 will round toward the nearest even //! integer. (Both 3.5 and 4.5 for x will return 4.0.) //! - /// @see - //! @li GLSL roundEven man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL roundEven man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType roundEven(genType const & x); //! Returns a value equal to the nearest integer //! that is greater than or equal to x. //! - /// @see - //! @li GLSL ceil man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL ceil man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType ceil(genType const & x); //! Return x - floor(x). //! - /// @see - //! @li GLSL fract man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL fract man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType fract(genType const & x); //! Modulus. Returns x - y * floor(x / y) //! for each component in x using the floating point value y. //! - /// @see - //! @li GLSL mod man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL mod man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType mod( genType const & x, @@ -122,9 +120,8 @@ namespace glm //! Modulus. Returns x - y * floor(x / y) //! for each component in x using the floating point value y. //! - /// @see - //! @li GLSL mod man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL mod man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType mod( genType const & x, @@ -135,9 +132,8 @@ namespace glm //! return value and the output parameter will have the same //! sign as x. //! - /// @see - /// @li GLSL modf man page - /// @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL modf man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType modf( genType const & x, @@ -145,9 +141,8 @@ namespace glm /// Returns y if y < x; otherwise, it returns x. /// - /// @see - /// @li GLSL min man page - /// @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL min man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType min( genType const & x, @@ -160,9 +155,8 @@ namespace glm /// Returns y if x < y; otherwise, it returns x. /// - /// @see - /// @li GLSL max man page - /// @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL max man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType max( genType const & x, @@ -176,9 +170,8 @@ namespace glm //! Returns min(max(x, minVal), maxVal) for each component in x //! using the floating-point values minVal and maxVal. //! - /// @see - //! @li GLSL clamp man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL clamp man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType clamp( genType const & x, @@ -207,24 +200,39 @@ namespace glm //! provides different functionality than //! genType mix(genType x, genType y, genType(a)) //! where a is a Boolean vector. - //! - //! @see - //! @li GLSL mix man page - //! @li GLSL 1.30.08 specification, section 8.3 - //! - //! @param[in] x Floating point scalar or vector. - //! @param[in] y Floating point scalar or vector. - //! @param[in] a Floating point or boolean scalar or vector. - //! - //! @todo Test when 'a' is a boolean. + /// + /// @see - GLSL mix man page + /// @see - GLSL 4.10.6 specification, section 8.3 + /// + /// @param[in] x Value to interpolate. + /// @param[in] y Value to interpolate. + /// @param[in] a Interpolant. + /// + /// @tparam genTypeT Floating point scalar or vector. + /// @tparam genTypeU Floating point or boolean scalar or vector. It can't be a vector if it is the length of genTypeT. + /// + /// @code + /// #include + /// ... + /// float a; + /// bool b; + /// glm::dvec3 e; + /// glm::dvec3 f; + /// glm::vec4 g; + /// glm::vec4 h; + /// ... + /// glm::vec4 r = glm::mix(g, h, a); // Interpolate with a floating-point scalar two vectors. + /// glm::vec4 s = glm::mix(g, h, b); // Teturns g or h; + /// glm::dvec3 t = glm::mix(e, f, a); // Types of the third parameter is not required to match with the first and the second. + /// glm::vec4 u = glm::mix(g, h, r); // Interpolations can be perform per component with a vector for the last parameter. + /// @endcode template genTypeT mix(genTypeT const & x, genTypeT const & y, genTypeU const & a); //! Returns 0.0 if x < edge, otherwise it returns 1.0. - //! - //! @see - //! @li GLSL step man page - //! @li GLSL 1.30.08 specification, section 8.3 + //! + /// @see - GLSL step man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType step( genType const & edge, @@ -245,9 +253,8 @@ namespace glm //! return t * t * (3 – 2 * t); //! Results are undefined if edge0 >= edge1. //! - //! @see - //! @li GLSL smoothstep man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL smoothstep man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType smoothstep( genType const & edge0, @@ -266,9 +273,8 @@ namespace glm //! including for implementations with no NaN //! representations. //! - //! @see - //! @li GLSL isnan man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL isnan man page + /// @see - GLSL 4.10.6 specification, section 8.3 template typename genType::bool_type isnan(genType const & x); @@ -278,9 +284,8 @@ namespace glm //! otherwise, including for implementations with no infinity //! representations. //! - //! @see - //! @li GLSL isinf man page - //! @li GLSL 1.30.08 specification, section 8.3 + /// @see - GLSL isinf man page + /// @see - GLSL 4.10.6 specification, section 8.3 template typename genType::bool_type isinf(genType const & x); @@ -288,9 +293,8 @@ namespace glm //! the encoding of a floating-point value. The floatingpoint //! value's bit-level representation is preserved. //! - //! @see - //! @li GLSL floatBitsToInt man page - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL floatBitsToInt man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genIType floatBitsToInt(genType const & value); @@ -298,9 +302,8 @@ namespace glm //! the encoding of a floating-point value. The floatingpoint //! value's bit-level representation is preserved. //! - //! @see - //! @li GLSL floatBitsToUint man page - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL floatBitsToUint man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genUType floatBitsToUint(genType const & value); @@ -310,9 +313,8 @@ namespace glm //! resulting floating point value is unspecified. Otherwise, //! the bit-level representation is preserved. //! - //! @see - //! @li GLSL intBitsToFloat man page - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL intBitsToFloat man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType intBitsToFloat(genIType const & value); @@ -322,17 +324,15 @@ namespace glm //! resulting floating point value is unspecified. Otherwise, //! the bit-level representation is preserved. //! - //! @see - //! @li GLSL uintBitsToFloat man page - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL uintBitsToFloat man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType uintBitsToFloat(genUType const & value); //! Computes and returns a * b + c. //! - //! @see - //! @li GLSL fma man page - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL fma man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType fma(genType const & a, genType const & b, genType const & c); @@ -346,9 +346,8 @@ namespace glm //! are both zero. For a floating-point value that is an //! infinity or is not a number, the results are undefined. //! - //! @see - //! @li GLSL frexp man page - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL frexp man page + /// @see - GLSL 4.10.6 specification, section 8.3 template genType frexp(genType const & x, genIType & exp); @@ -359,9 +358,8 @@ namespace glm //! If this product is too large to be represented in the //! floating-point type, the result is undefined. //! - //! @see - //! @li GLSL ldexp man page; - //! @li GLSL 4.00.08 specification, section 8.3 + /// @see - GLSL ldexp man page; + /// @see - GLSL 4.10.6 specification, section 8.3 template genType ldexp(genType const & x, genIType const & exp); @@ -370,4 +368,4 @@ namespace glm #include "func_common.inl" -#endif//glm_core_func_common +#endif//GLM_CORE_func_common diff --git a/glm/core/func_exponential.hpp b/glm/core/func_exponential.hpp index 222c0285..37e1053e 100644 --- a/glm/core/func_exponential.hpp +++ b/glm/core/func_exponential.hpp @@ -34,7 +34,7 @@ /////////////////////////////////////////////////////////////////////////////////// #ifndef glm_core_func_exponential -#define glm_core_func_exponential +#define glm_core_func_exponential GLM_VERSION namespace glm { @@ -43,7 +43,6 @@ namespace glm /// Returns x raised to the y power. /// - /// @see /// @see - GLSL pow man page /// @see - GLSL 4.10.6 specification, section 8.2 template @@ -51,7 +50,6 @@ namespace glm /// Returns the natural exponentiation of x, i.e., e^x. /// - /// @see /// @see - GLSL exp man page /// @see - GLSL 4.10.6 specification, section 8.2 template @@ -61,7 +59,6 @@ namespace glm /// returns the value y which satisfies the equation x = e^y. /// Results are undefined if x <= 0. /// - /// @see /// @see - GLSL log man page /// @see - GLSL 4.10.6 specification, section 8.2 template @@ -69,7 +66,6 @@ namespace glm /// Returns 2 raised to the x power. /// - /// @see /// @see - GLSL exp2 man page /// @see - GLSL 4.10.6 specification, section 8.2 template @@ -78,7 +74,6 @@ namespace glm /// Returns the base 2 log of x, i.e., returns the value y, /// which satisfies the equation x = 2 ^ y. /// - /// @see /// @see - GLSL log2 man page /// @see - GLSL 4.10.6 specification, section 8.2 template @@ -86,7 +81,6 @@ namespace glm /// Returns the positive square root of x. /// - /// @see /// @see - GLSL sqrt man page /// @see - GLSL 4.10.6 specification, section 8.2 template @@ -94,7 +88,6 @@ namespace glm /// Returns the reciprocal of the positive square root of x. /// - /// @see /// @see - GLSL inversesqrt man page /// @see - GLSL 4.10.6 specification, section 8.2 template diff --git a/glm/core/func_geometric.hpp b/glm/core/func_geometric.hpp index 849bbe15..c0f03b88 100644 --- a/glm/core/func_geometric.hpp +++ b/glm/core/func_geometric.hpp @@ -24,85 +24,92 @@ /// @file glm/core/func_geometric.hpp /// @date 2008-08-03 / 2011-06-14 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.5 +/// +/// @defgroup core_func_geometric Geometric functions +/// @ingroup core +/// +/// These operate on vectors as vectors, not component-wise. /////////////////////////////////////////////////////////////////////////////////// #ifndef glm_core_func_geometric -#define glm_core_func_geometric +#define glm_core_func_geometric GLM_VERSION namespace glm { - /// \addtogroup core_funcs + /// @addtogroup core_func_geometric /// @{ - //! Returns the length of x, i.e., sqrt(x * x). - //! - //! \li GLSL length man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// Returns the length of x, i.e., sqrt(x * x). + /// + /// @see - GLSL length man page + /// @see - GLSL 4.10.6 specification, section 8.5 template typename genType::value_type length( genType const & x); - //! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). - //! - //! \li GLSL distance man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1). + /// + /// @see - GLSL distance man page + /// @see - GLSL 4.10.6 specification, section 8.5 template typename genType::value_type distance( genType const & p0, genType const & p1); - //! Returns the dot product of x and y, i.e., result = x * y. - //! - //! \li GLSL dot man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// Returns the dot product of x and y, i.e., result = x * y. + /// + /// @see - GLSL dot man page + /// @see - GLSL 4.10.6 specification, section 8.5 template typename genType::value_type dot( genType const & x, genType const & y); - //! Returns the cross product of x and y. - //! - //! \li GLSL cross man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// Returns the cross product of x and y. + /// + /// @see - GLSL cross man page + /// @see - GLSL 4.10.6 specification, section 8.5 template detail::tvec3 cross( detail::tvec3 const & x, detail::tvec3 const & y); - //! Returns a vector in the same direction as x but with length of 1. - //! - //! \li GLSL normalize man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// Returns a vector in the same direction as x but with length of 1. + /// + /// @see - GLSL normalize man page + /// @see - GLSL 4.10.6 specification, section 8.5 template genType normalize( genType const & x); - //! If dot(Nref, I) < 0.0, return N, otherwise, return -N. - //! - //! \li GLSL faceforward man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// If dot(Nref, I) < 0.0, return N, otherwise, return -N. + /// + /// @see - GLSL faceforward man page + /// @see - GLSL 4.10.6 specification, section 8.5 template genType faceforward( genType const & N, genType const & I, genType const & Nref); - //! For the incident vector I and surface orientation N, - //! returns the reflection direction : result = I - 2.0 * dot(N, I) * N. - //! - //! \li GLSL reflect man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// For the incident vector I and surface orientation N, + /// returns the reflection direction : result = I - 2.0 * dot(N, I) * N. + /// + /// @see - GLSL reflect man page + /// @see - GLSL 4.10.6 specification, section 8.5 template genType reflect( genType const & I, genType const & N); - //! For the incident vector I and surface normal N, - //! and the ratio of indices of refraction eta, - //! return the refraction vector. - //! - //! \li GLSL refract man page - //! \li GLSL 1.30.08 specification, section 8.4 + /// For the incident vector I and surface normal N, + /// and the ratio of indices of refraction eta, + /// return the refraction vector. + /// + /// @see - GLSL refract man page + /// @see - GLSL 4.10.6 specification, section 8.5 template genType refract( genType const & I, diff --git a/glm/core/func_integer.hpp b/glm/core/func_integer.hpp index a856c781..700f5ec4 100644 --- a/glm/core/func_integer.hpp +++ b/glm/core/func_integer.hpp @@ -22,24 +22,33 @@ /// /// @ref core /// @file glm/core/func_integer.hpp -/// @date 2010-03-17 / 2011-06-14 +/// @date 2010-03-17 / 2011-06-18 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.8 +/// +/// @defgroup core_func_integer Integer functions +/// @ingroup core +/// +/// These all operate component-wise. The description is per component. +/// The notation [a, b] means the set of bits from bit-number a through bit-number +/// b, inclusive. The lowest-order bit is bit 0. /////////////////////////////////////////////////////////////////////////////////// #ifndef glm_core_func_integer -#define glm_core_func_integer +#define glm_core_func_integer GLM_VERSION namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_integer /// @{ //! Adds 32-bit unsigned integer x and y, returning the sum //! modulo pow(2, 32). The value carry is set to 0 if the sum was //! less than pow(2, 32), or to 1 otherwise. //! - //! \li GLSL uaddCarry man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL uaddCarry man page + /// @see - GLSL 4.10.6 specification, section 8.8 template genUType uaddCarry( genUType const & x, @@ -50,8 +59,8 @@ namespace glm //! the difference if non-negative, or pow(2, 32) plus the difference //! otherwise. The value borrow is set to 0 if x >= y, or to 1 otherwise. //! - //! \li GLSL usubBorrow man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL usubBorrow man page + /// @see - GLSL 4.10.6 specification, section 8.8 template genUType usubBorrow( genUType const & x, @@ -62,8 +71,8 @@ namespace glm //! result. The 32 least-significant bits are returned in lsb. //! The 32 most-significant bits are returned in msb. //! - //! \li GLSL umulExtended man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL umulExtended man page + /// @see - GLSL 4.10.6 specification, section 8.8 template void umulExtended( genUType const & x, @@ -75,8 +84,8 @@ namespace glm //! result. The 32 least-significant bits are returned in lsb. //! The 32 most-significant bits are returned in msb. //! - //! \li GLSL imulExtended man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL imulExtended man page + /// @see - GLSL 4.10.6 specification, section 8.8 template void imulExtended( genIType const & x, @@ -95,8 +104,8 @@ namespace glm //! offset and bits is greater than the number of bits used //! to store the operand. //! - //! \li GLSL bitfieldExtract man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL bitfieldExtract man page + /// @see - GLSL 4.10.6 specification, section 8.8 template genIUType bitfieldExtract( genIUType const & Value, @@ -113,8 +122,8 @@ namespace glm //! offset and bits is greater than the number of bits used to //! store the operand. //! - //! \li GLSL bitfieldInsert man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL bitfieldInsert man page + /// @see - GLSL 4.10.6 specification, section 8.8 template genIUType bitfieldInsert( genIUType const & Base, @@ -126,15 +135,15 @@ namespace glm //! The bit numbered n of the result will be taken from bit (bits - 1) - n of value, //! where bits is the total number of bits used to represent value. //! - //! \li GLSL bitfieldReverse man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL bitfieldReverse man page + /// @see - GLSL 4.10.6 specification, section 8.8 template genIUType bitfieldReverse(genIUType const & value); //! Returns the number of bits set to 1 in the binary representation of value. //! - //! \li GLSL bitCount man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL bitCount man page + /// @see - GLSL 4.10.6 specification, section 8.8 template class C> typename C::signed_type bitCount(C const & Value); @@ -142,8 +151,8 @@ namespace glm //! 1 in the binary representation of value. //! If value is zero, -1 will be returned. //! - //! \li GLSL findLSB man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL findLSB man page + /// @see - GLSL 4.10.6 specification, section 8.8 template class C> typename C::signed_type findLSB(C const & Value); @@ -152,8 +161,8 @@ namespace glm //! For negative integers, the result will be the bit number of the most significant //! bit set to 0. For a value of zero or negative one, -1 will be returned. //! - //! \li GLSL findMSB man page - //! \li GLSL 4.00.08 specification, section 8.8 + /// @see - GLSL findMSB man page + /// @see - GLSL 4.10.6 specification, section 8.8 template class C> typename C::signed_type findMSB(C const & Value); diff --git a/glm/core/func_matrix.hpp b/glm/core/func_matrix.hpp index c40a4e82..01aa08ad 100644 --- a/glm/core/func_matrix.hpp +++ b/glm/core/func_matrix.hpp @@ -24,89 +24,100 @@ /// @file glm/core/func_matrix.hpp /// @date 2008-08-03 / 2011-06-15 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.6 +/// +/// @defgroup core_func_matrix Matrix functions +/// @ingroup core +/// +/// For each of the following built-in matrix functions, there is both a +/// single-precision floating point version, where all arguments and return values +/// are single precision, and a double-precision floating version, where all +/// arguments and return values are double precision. Only the single-precision +/// floating point version is shown. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_matrix -#define glm_core_func_matrix +#ifndef GLM_CORE_func_matrix +#define GLM_CORE_func_matrix GLM_VERSION namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_matrix /// @{ - //! Multiply matrix x by matrix y component-wise, i.e., - //! result[i][j] is the scalar product of x[i][j] and y[i][j]. - //! - //! \li GLSL matrixCompMult man page - //! \li GLSL 1.30.08 specification, section 8.5 + /// Multiply matrix x by matrix y component-wise, i.e., + /// result[i][j] is the scalar product of x[i][j] and y[i][j]. + /// + /// @see - GLSL matrixCompMult man page + /// @see - GLSL 4.10.6 specification, section 8.6 template matType matrixCompMult( matType const & x, matType const & y); - //! Treats the first parameter c as a column vector - //! and the second parameter r as a row vector - //! and does a linear algebraic matrix multiply c * r. - //! - //! \li GLSL outerProduct man page - //! \li GLSL 1.30.08 specification, section 8.5 + /// Treats the first parameter c as a column vector + /// and the second parameter r as a row vector + /// and does a linear algebraic matrix multiply c * r. + /// + /// @see - GLSL outerProduct man page + /// @see - GLSL 4.10.6 specification, section 8.6 template matType outerProduct( vecType const & c, vecType const & r); - //! Returns the transposed matrix of x - //! - //! \li GLSL transpose man page - //! \li GLSL 1.30.08 specification, section 8.5 + /// Returns the transposed matrix of x + /// + /// @see - GLSL transpose man page + /// @see - GLSL 4.10.6 specification, section 8.6 template typename matType::transpose_type transpose( matType const & x); - //! Return the determinant of a mat2 matrix. - //! - //! \li GLSL determinant man page - //! \li GLSL 1.30.08 specification, section 8.5 + /// Return the determinant of a mat2 matrix. + /// + /// @see - GLSL determinant man page + /// @see - GLSL 4.10.6 specification, section 8.6 template typename detail::tmat2x2::value_type determinant( detail::tmat2x2 const & m); - //! Return the determinant of a mat3 matrix. - //! - //! \li GLSL determinant man page - //! \li GLSL 1.30.08 specification, section 8.5 + /// Return the determinant of a mat3 matrix. + /// + /// @see - GLSL determinant man page + /// @see - GLSL 4.10.6 specification, section 8.6 template typename detail::tmat3x3::value_type determinant( detail::tmat3x3 const & m); - //! Return the determinant of a mat4 matrix. - //! - //! \li GLSL determinant man page - //! \li GLSL 1.30.08 specification, section 8.5 + /// Return the determinant of a mat4 matrix. + /// + /// @see - GLSL determinant man page + /// @see - GLSL 4.10.6 specification, section 8.6 template typename detail::tmat4x4::value_type determinant( detail::tmat4x4 const & m); - //! Return the inverse of a mat2 matrix. - //! - //! \li GLSL inverse man page - //! \li GLSL 1.40.07 specification, section 8.5 + /// Return the inverse of a mat2 matrix. + /// + /// @see - GLSL inverse man page + /// @see - GLSL 4.10.6 specification, section 8.6 template detail::tmat2x2 inverse( detail::tmat2x2 const & m); - //! Return the inverse of a mat3 matrix. - //! - //! \li GLSL inverse man page - //! \li GLSL 1.40.07 specification, section 8.5 + /// Return the inverse of a mat3 matrix. + /// + /// @see - GLSL inverse man page + /// @see - GLSL 4.10.6 specification, section 8.6 template detail::tmat3x3 inverse( detail::tmat3x3 const & m); - //! Return the inverse of a mat4 matrix. - //! - //! \li GLSL inverse man page - //! \li GLSL 1.40.07 specification, section 8.5 + /// Return the inverse of a mat4 matrix. + /// + /// @see - GLSL inverse man page + /// @see - GLSL 4.10.6 specification, section 8.6 template detail::tmat4x4 inverse( detail::tmat4x4 const & m); @@ -116,4 +127,4 @@ namespace glm #include "func_matrix.inl" -#endif//glm_core_func_matrix +#endif//GLM_CORE_func_matrix diff --git a/glm/core/func_noise.hpp b/glm/core/func_noise.hpp index 3b818151..1ed23442 100644 --- a/glm/core/func_noise.hpp +++ b/glm/core/func_noise.hpp @@ -22,43 +22,52 @@ /// /// @ref core /// @file glm/core/func_noise.hpp -/// @date 2008-08-01 / 2011-06-15 +/// @date 2008-08-01 / 2011-06-18 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.11 +/// +/// @defgroup core_func_noise Noise functions +/// @ingroup core +/// +/// Noise functions are stochastic functions that can be used to increase visual +/// complexity. Values returned by the following noise functions give the +/// appearance of randomness, but are not truly random. /////////////////////////////////////////////////////////////////////////////////// #ifndef glm_core_func_noise -#define glm_core_func_noise +#define glm_core_func_noise GLM_VERSION namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_noise /// @{ - //! Returns a 1D noise value based on the input value x. - //! - //! \li GLSL noise1 man page - //! \li GLSL 1.30.08 specification, section 8.9 + /// Returns a 1D noise value based on the input value x. + /// + /// @see - GLSL noise1 man page + /// @see - GLSL 4.10.6 specification, section 8.11 template typename genType::value_type noise1(genType const & x); - //! Returns a 2D noise value based on the input value x. - //! - //! \li GLSL noise2 man page - //! \li GLSL 1.30.08 specification, section 8.9 + /// Returns a 2D noise value based on the input value x. + /// + /// @see - GLSL noise2 man page + /// @see - GLSL 4.10.6 specification, section 8.11 template detail::tvec2 noise2(genType const & x); - //! Returns a 3D noise value based on the input value x. - //! - //! \li GLSL noise3 man page - //! \li GLSL 1.30.08 specification, section 8.9 + /// Returns a 3D noise value based on the input value x. + /// + /// @see - GLSL noise3 man page + /// @see - GLSL 4.10.6 specification, section 8.11 template detail::tvec3 noise3(genType const & x); - //! Returns a 4D noise value based on the input value x. - //! - //! \li GLSL noise4 man page - //! \li GLSL 1.30.08 specification, section 8.9 + /// Returns a 4D noise value based on the input value x. + /// + /// @see - GLSL noise4 man page + /// @see - GLSL 4.10.6 specification, section 8.11 template detail::tvec4 noise4(genType const & x); diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp index 759e649f..7907eadc 100644 --- a/glm/core/func_packing.hpp +++ b/glm/core/func_packing.hpp @@ -24,14 +24,21 @@ /// @file glm/core/func_packing.hpp /// @date 2010-03-17 / 2011-06-15 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.4 +/// +/// @defgroup core_func_packing Floating-Point Pack and Unpack Functions +/// @ingroup core +/// +/// These functions do not operate component-wise, rather as described in each case. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_packing -#define glm_core_func_packing +#ifndef GLM_CORE_func_packing +#define GLM_CORE_func_packing GLM_VERSION namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_packing /// @{ //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. @@ -43,8 +50,8 @@ namespace glm //! 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. //! - //! \li GLSL packUnorm2x16 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL packUnorm2x16 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::uint32 packUnorm2x16(detail::tvec2 const & v); //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. @@ -56,8 +63,8 @@ namespace glm //! 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. //! - //! \li GLSL packUnorm4x8 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL packUnorm4x8 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::uint32 packUnorm4x8(detail::tvec4 const & v); //! First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values. @@ -69,8 +76,8 @@ namespace glm //! 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. //! - //! \li GLSL packSnorm4x8 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL packSnorm4x8 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::uint32 packSnorm4x8(detail::tvec4 const & v); //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. @@ -82,8 +89,8 @@ namespace glm //! The first component of the returned vector will be extracted from the least significant bits of the input; //! the last component will be extracted from the most significant bits. //! - //! \li GLSL unpackUnorm2x16 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL unpackUnorm2x16 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::tvec2 unpackUnorm2x16(detail::uint32 const & p); //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. @@ -95,8 +102,8 @@ namespace glm //! The first component of the returned vector will be extracted from the least significant bits of the input; //! the last component will be extracted from the most significant bits. //! - //! \li GLSL unpackUnorm4x8 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL unpackUnorm4x8 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::tvec4 unpackUnorm4x8(detail::uint32 const & p); //! First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers. @@ -108,8 +115,8 @@ namespace glm //! The first component of the returned vector will be extracted from the least significant bits of the input; //! the last component will be extracted from the most significant bits. //! - //! \li GLSL unpackSnorm4x8 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL unpackSnorm4x8 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::tvec4 unpackSnorm4x8(detail::uint32 const & p); //! Returns a double-precision value obtained by packing the components of v into a 64-bit value. @@ -118,8 +125,8 @@ namespace glm //! The first vector component specifies the 32 least significant bits; //! the second component specifies the 32 most significant bits. //! - //! \li GLSL packDouble2x32 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL packDouble2x32 man page + /// @see - GLSL 4.10.6 specification, section 8.4 double packDouble2x32(detail::tvec2 const & v); //! Returns a two-component unsigned integer vector representation of v. @@ -127,8 +134,8 @@ namespace glm //! The first component of the vector contains the 32 least significant bits of the double; //! the second component consists the 32 most significant bits. //! - //! \li GLSL unpackDouble2x32 man page - //! \li GLSL 4.00.08 specification, section 8.4 + /// @see - GLSL unpackDouble2x32 man page + /// @see - GLSL 4.10.6 specification, section 8.4 detail::tvec2 unpackDouble2x32(double const & v); /// @} @@ -136,5 +143,5 @@ namespace glm #include "func_packing.inl" -#endif//glm_core_func_packing +#endif//GLM_CORE_func_packing diff --git a/glm/core/func_trigonometric.hpp b/glm/core/func_trigonometric.hpp index 64af71a4..36613aa0 100644 --- a/glm/core/func_trigonometric.hpp +++ b/glm/core/func_trigonometric.hpp @@ -24,50 +24,61 @@ /// @file glm/core/func_trigonometric.hpp /// @date 2008-08-01 / 2011-06-15 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.1 +/// +/// @defgroup core_func_trigonometric Angle and Trigonometry Functions +/// @ingroup core +/// +/// Function parameters specified as angle are assumed to be in units of radians. +/// In no case will any of these functions result in a divide by zero error. If +/// the divisor of a ratio is 0, then results will be undefined. +/// +/// These all operate component-wise. The description is per component. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_trigonometric -#define glm_core_func_trigonometric +#ifndef GLM_CORE_func_trigonometric +#define GLM_CORE_func_trigonometric GLM_VERSION namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_trigonometric /// @{ //! Converts degrees to radians and returns the result. //! - //! \li GLSL radians man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL radians man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType radians(genType const & degrees); //! Converts radians to degrees and returns the result. //! - //! \li GLSL degrees man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL degrees man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType degrees(genType const & radians); //! The standard trigonometric sine function. //! The values returned by this function will range from [-1, 1]. //! - //! \li GLSL sin man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL sin man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType sin(genType const & angle); //! The standard trigonometric cosine function. //! The values returned by this function will range from [-1, 1]. //! - //! \li GLSL cos man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL cos man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType cos(genType const & angle); //! The standard trigonometric tangent function. //! - //! \li GLSL tan man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL tan man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType tan(genType const & angle); @@ -75,8 +86,8 @@ namespace glm //! The range of values returned by this function is [-PI/2, PI/2]. //! Results are undefined if |x| > 1. //! - //! \li GLSL asin man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL asin man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType asin(genType const & x); @@ -84,8 +95,8 @@ namespace glm //! The range of values returned by this function is [0, PI]. //! Results are undefined if |x| > 1. //! - //! \li GLSL acos man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL acos man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType acos(genType const & x); @@ -95,60 +106,60 @@ namespace glm //! by this function is [-PI, PI]. Results are undefined //! if x and y are both 0. //! - //! \li GLSL atan man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL atan man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType atan(genType const & y, genType const & x); //! Arc tangent. Returns an angle whose tangent is y_over_x. //! The range of values returned by this function is [-PI/2, PI/2]. //! - //! \li GLSL atan man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL atan man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType atan(genType const & y_over_x); //! Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2 //! - //! \li GLSL sinh man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL sinh man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType sinh(genType const & angle); //! Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2 //! - //! \li GLSL cosh man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL cosh man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType cosh(genType const & angle); //! Returns the hyperbolic tangent function, sinh(angle) / cosh(angle) //! - //! \li GLSL tanh man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL tanh man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType tanh(genType const & angle); //! Arc hyperbolic sine; returns the inverse of sinh. //! - //! \li GLSL asinh man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL asinh man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType asinh(genType const & x); //! Arc hyperbolic cosine; returns the non-negative inverse //! of cosh. Results are undefined if x < 1. //! - //! \li GLSL acosh man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL acosh man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType acosh(genType const & x); //! Arc hyperbolic tangent; returns the inverse of tanh. //! Results are undefined if abs(x) >= 1. //! - //! \li GLSL atanh man page - //! \li GLSL 1.30.08 specification, section 8.1 + /// @see - GLSL atanh man page + /// @see - GLSL 4.10.6 specification, section 8.1 template genType atanh(genType const & x); @@ -157,6 +168,6 @@ namespace glm #include "func_trigonometric.inl" -#endif//glm_core_func_trigonometric +#endif//GLM_CORE_func_trigonometric diff --git a/glm/core/func_vector_relational.hpp b/glm/core/func_vector_relational.hpp index b5434e5c..df80aba0 100644 --- a/glm/core/func_vector_relational.hpp +++ b/glm/core/func_vector_relational.hpp @@ -24,16 +24,28 @@ /// @file glm/core/func_vector_relational.hpp /// @date 2008-08-03 / 2011-06-15 /// @author Christophe Riccio +/// +/// @see - GLSL 4.10.6 specification, section 8.7 +/// +/// @defgroup core_func_vector_relational Vector Relational Functions +/// @ingroup core +/// +/// Relational and equality operators (<, <=, >, >=, ==, !=) are defined to +/// operate on scalars and produce scalar Boolean results. For vector results, +/// use the following built-in functions. +/// +/// In all cases, the sizes of all the input and return vectors for any particular +/// call must match. /////////////////////////////////////////////////////////////////////////////////// -#ifndef glm_core_func_vector_relational -#define glm_core_func_vector_relational +#ifndef GLM_CORE_func_vector_relational +#define GLM_CORE_func_vector_relational GLM_VERSION #include "_detail.hpp" namespace glm { - /// @addtogroup core_funcs + /// @addtogroup core_func_vector_relational /// @{ //! Returns the component-wise comparison result of x < y. @@ -219,4 +231,4 @@ namespace glm #include "func_vector_relational.inl" -#endif//glm_core_func_vector_relational +#endif//GLM_CORE_func_vector_relational diff --git a/glm/glm.hpp b/glm/glm.hpp index c6add60f..7380a718 100644 --- a/glm/glm.hpp +++ b/glm/glm.hpp @@ -73,12 +73,6 @@ /// These templetes are implementation details of GLM types and should not be used explicitly. /// /// @ingroup core -/// -/// @defgroup core_funcs Functions -/// -/// @brief The functions defined by the specification. -/// -/// @ingroup core /////////////////////////////////////////////////////////////////////////////////// #include "core/_fixes.hpp" diff --git a/test/external/gli/CMakeLists.txt b/test/external/gli/CMakeLists.txt new file mode 100644 index 00000000..6b91c288 --- /dev/null +++ b/test/external/gli/CMakeLists.txt @@ -0,0 +1,27 @@ +set(NAME gli) + +file(GLOB ROOT_SOURCE *.cpp) +file(GLOB ROOT_INLINE *.inl) +file(GLOB ROOT_HEADER *.hpp) + +file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp) +file(GLOB_RECURSE CORE_INLINE ./core/*.inl) +file(GLOB_RECURSE CORE_HEADER ./core/*.hpp) + +file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) +file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) +file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) + +source_group("Core Files" FILES ${CORE_SOURCE}) +source_group("Core Files" FILES ${CORE_INLINE}) +source_group("Core Files" FILES ${CORE_HEADER}) +source_group("GTX Files" FILES ${GTX_SOURCE}) +source_group("GTX Files" FILES ${GTX_INLINE}) +source_group("GTX Files" FILES ${GTX_HEADER}) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_executable(${NAME} + ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} + ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} + ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER} ) diff --git a/test/external/gli/core/dummy.cpp b/test/external/gli/core/dummy.cpp new file mode 100644 index 00000000..0395e23b --- /dev/null +++ b/test/external/gli/core/dummy.cpp @@ -0,0 +1,4 @@ +int main() +{ + +} diff --git a/test/external/gli/core/generate_mipmaps.hpp b/test/external/gli/core/generate_mipmaps.hpp new file mode 100644 index 00000000..43409360 --- /dev/null +++ b/test/external/gli/core/generate_mipmaps.hpp @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-09-27 +// Updated : 2010-09-27 +// Licence : This source is under MIT License +// File : gli/core/generate_mipmaps.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_GENERATE_MIPMAPS_INCLUDED +#define GLI_GENERATE_MIPMAPS_INCLUDED + +#include "texture2d.hpp" + +namespace gli +{ + texture2D generateMipmaps( + texture2D const & Texture, + texture2D::level_type const & BaseLevel); + +}//namespace gli + +#include "generate_mipmaps.inl" + +#endif//GLI_GENERATE_MIPMAPS_INCLUDED diff --git a/test/external/gli/core/generate_mipmaps.inl b/test/external/gli/core/generate_mipmaps.inl new file mode 100644 index 00000000..93e535b6 --- /dev/null +++ b/test/external/gli/core/generate_mipmaps.inl @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-09-27 +// Updated : 2010-09-27 +// Licence : This source is under MIT License +// File : gli/core/generate_mipmaps.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace gli +{ + inline texture2D generateMipmaps + ( + texture2D const & Image, + texture2D::level_type const & BaseLevel + ) + { + assert(BaseLevel < Image.levels()); + texture2D::format_type Format = Image[BaseLevel].format(); + + assert(Format == R8U || Format == RG8U || Format == RGB8U || Format == RGBA8U); + texture2D::level_type Levels = std::size_t(glm::log2(float(glm::compMax(Image[0].dimensions())))) + 1; + + texture2D Result(Levels); + for(texture2D::level_type Level = 0; Level <= BaseLevel; ++Level) + Result[Level] = detail::duplicate(Image[Level]); + + for(texture2D::level_type Level = BaseLevel; Level < Levels - 1; ++Level) + { + std::size_t BaseWidth = Result[Level + 0].dimensions().x; + texture2D::value_type * DataSrc = Result[Level + 0].data(); + + texture2D::dimensions_type LevelDimensions = Result[Level + 0].dimensions() >> texture2D::dimensions_type(1); + LevelDimensions = glm::max(LevelDimensions, texture2D::dimensions_type(1)); + texture2D::size_type ValueSize = Result[Level + 0].value_size(); + texture2D::size_type Components = Result[Level + 0].components(); + + texture2D::data_type DataDst(glm::compMul(LevelDimensions) * Components); + + for(std::size_t j = 0; j < LevelDimensions.y; ++j) + for(std::size_t i = 0; i < LevelDimensions.x; ++i) + for(std::size_t c = 0; c < Components; ++c) + { + std::size_t x = (i << 1); + std::size_t y = (j << 1); + + std::size_t Index00 = ((x + 0) + (y + 0) * BaseWidth) * Components + c; + std::size_t Index01 = ((x + 0) + (y + 1) * BaseWidth) * Components + c; + std::size_t Index11 = ((x + 1) + (y + 1) * BaseWidth) * Components + c; + std::size_t Index10 = ((x + 1) + (y + 0) * BaseWidth) * Components + c; + + glm::u32 Data00 = reinterpret_cast(DataSrc)[Index00]; + glm::u32 Data01 = reinterpret_cast(DataSrc)[Index01]; + glm::u32 Data11 = reinterpret_cast(DataSrc)[Index11]; + glm::u32 Data10 = reinterpret_cast(DataSrc)[Index10]; + + texture2D::value_type Result = (Data00 + Data01 + Data11 + Data10) >> 2; + texture2D::value_type * Data = reinterpret_cast(DataDst.data()); + + *(Data + ((i + j * LevelDimensions.x) * Components + c)) = Result; + } + + Result[Level + 1] = image2D(LevelDimensions, Format, DataDst); + } + + return Result; + } + +}//namespace gli diff --git a/test/external/gli/core/image2d.hpp b/test/external/gli/core/image2d.hpp new file mode 100644 index 00000000..918514d5 --- /dev/null +++ b/test/external/gli/core/image2d.hpp @@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-04-05 +// Updated : 2011-04-05 +// Licence : This source is under MIT License +// File : gli/core/image2d.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_CORE_IMAGE2D_INCLUDED +#define GLI_CORE_IMAGE2D_INCLUDED + +// STD +#include +#include +#include +#include + +// GLM +#include +#include +#include +#include +#include + +namespace gli +{ + enum format + { + FORMAT_NULL, + + // Unsigned integer formats + R8U, + RG8U, + RGB8U, + RGBA8U, + + R16U, + RG16U, + RGB16U, + RGBA16U, + + R32U, + RG32U, + RGB32U, + RGBA32U, + + // Signed integer formats + R8I, + RG8I, + RGB8I, + RGBA8I, + + R16I, + RG16I, + RGB16I, + RGBA16I, + + R32I, + RG32I, + RGB32I, + RGBA32I, + + // Floating formats + R16F, + RG16F, + RGB16F, + RGBA16F, + + R32F, + RG32F, + RGB32F, + RGBA32F, + + // Packed formats + RGBE8, + RGB9E5, + RG11B10F, + R5G6B5, + RGBA4, + RGB10A2, + + // Depth formats + D16, + D24X8, + D24S8, + D32F, + D32FS8X24, + + // Compressed formats + DXT1, + DXT3, + DXT5, + ATI1N_UNORM, + ATI1N_SNORM, + ATI2N_UNORM, + ATI2N_SNORM, + BP_UF16, + BP_SF16, + BP, + + FORMAT_MAX + }; + + enum size_type + { + LINEAR_SIZE, + BLOCK_SIZE, + BIT_PER_PIXEL, + COMPONENT + }; + + class image2D + { + public: + typedef glm::uvec2 dimensions_type; + typedef glm::vec2 texcoord_type; + typedef glm::uint32 size_type; + typedef glm::byte value_type; + typedef gli::format format_type; + typedef std::vector data_type; + + public: + image2D(); + image2D( + image2D const & Image); + + explicit image2D( + dimensions_type const & Dimensions, + format_type const & Format); + + template + explicit image2D( + dimensions_type const & Dimensions, + format_type const & Format, + genType const & Value); + + explicit image2D( + dimensions_type const & Dimensions, + format_type const & Format, + std::vector const & Data); + + ~image2D(); + + template + void setPixel( + dimensions_type const & TexelCoord, + genType const & TexelData); + + size_type value_size() const; + size_type capacity() const; + dimensions_type dimensions() const; + size_type components() const; + format_type format() const; + + value_type * data(); + value_type const * const data() const; + + private: + data_type Data; + dimensions_type Dimensions; + format_type Format; + }; + +}//namespace gli + +#include "image2d.inl" + +#endif//GLI_CORE_IMAGE2D_INCLUDED diff --git a/test/external/gli/core/image2d.inl b/test/external/gli/core/image2d.inl new file mode 100644 index 00000000..f363e022 --- /dev/null +++ b/test/external/gli/core/image2d.inl @@ -0,0 +1,231 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-04-05 +// Updated : 2011-04-05 +// Licence : This source is under MIT License +// File : gli/core/image2d.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace gli +{ + namespace detail + { + struct format_desc + { + image2D::size_type BlockSize; + image2D::size_type BBP; + image2D::size_type Component; + }; + + inline format_desc getFormatInfo(format const & Format) + { + format_desc Desc[FORMAT_MAX] = + { + { 0, 0, 0}, //FORMAT_NULL + + // Unsigned integer formats + { 1, 8, 1}, //R8U, + { 2, 16, 2}, //RG8U, + { 3, 24, 3}, //RGB8U, + { 4, 32, 4}, //RGBA8U, + + { 2, 16, 1}, //R16U, + { 4, 32, 2}, //RG16U, + { 6, 48, 3}, //RGB16U, + { 8, 64, 4}, //RGBA16U, + + { 4, 32, 1}, //R32U, + { 8, 64, 2}, //RG32U, + { 12, 96, 3}, //RGB32U, + { 16, 128, 4}, //RGBA32U, + + //// Signed integer formats + { 4, 32, 1}, //R8I, + { 8, 64, 2}, //RG8I, + { 12, 96, 3}, //RGB8I, + { 16, 128, 4}, //RGBA8I, + + { 2, 16, 1}, //R16I, + { 4, 32, 2}, //RG16I, + { 6, 48, 3}, //RGB16I, + { 8, 64, 4}, //RGBA16I, + + { 4, 32, 1}, //R32I, + { 8, 64, 2}, //RG32I, + { 12, 96, 3}, //RGB32I, + { 16, 128, 4}, //RGBA32I, + + //// Floating formats + { 2, 16, 1}, //R16F, + { 4, 32, 2}, //RG16F, + { 6, 48, 3}, //RGB16F, + { 8, 64, 4}, //RGBA16F, + + { 4, 32, 1}, //R32F, + { 8, 64, 2}, //RG32F, + { 12, 96, 3}, //RGB32F, + { 16, 128, 4}, //RGBA32F, + + //// Packed formats + { 4, 32, 3}, //RGBE8, + { 4, 32, 3}, //RGB9E5, + { 4, 32, 3}, //RG11B10F, + { 2, 16, 3}, //R5G6B5, + { 2, 16, 4}, //RGBA4, + { 4, 32, 3}, //RGB10A2, + + //// Depth formats + { 2, 16, 1}, //D16, + { 4, 32, 1}, //D24X8, + { 4, 32, 2}, //D24S8, + { 4, 32, 1}, //D32F, + { 8, 64, 2}, //D32FS8X24, + + //// Compressed formats + { 8, 4, 4}, //DXT1, + { 16, 8, 4}, //DXT3, + { 16, 8, 4}, //DXT5, + { 8, 4, 1}, //ATI1N_UNORM, + { 8, 4, 1}, //ATI1N_SNORM, + { 16, 8, 2}, //ATI2N_UNORM, + { 16, 8, 2}, //ATI2N_SNORM, + { 16, 8, 3}, //BP_UF16, + { 16, 8, 3}, //BP_SF16, + { 16, 8, 4}, //BP, + }; + + return Desc[Format]; + }; + + inline image2D::size_type sizeBlock + ( + format const & Format + ) + { + return getFormatInfo(Format).BlockSize; + } + + inline image2D::size_type sizeBitPerPixel + ( + format const & Format + ) + { + return getFormatInfo(Format).BBP; + } + + inline image2D::size_type sizeComponent + ( + format const & Format + ) + { + return getFormatInfo(Format).Component; + } + + inline image2D::size_type sizeLinear + ( + image2D const & Image + ) + { + image2D::dimensions_type Dimension = Image.dimensions(); + Dimension = glm::max(Dimension, image2D::dimensions_type(1)); + + image2D::size_type BlockSize = sizeBlock(Image.format()); + image2D::size_type BPP = sizeBitPerPixel(Image.format()); + image2D::size_type BlockCount = 0; + if((BlockSize << 3) == BPP) + BlockCount = Dimension.x * Dimension.y; + else + BlockCount = ((Dimension.x + 3) >> 2) * ((Dimension.y + 3) >> 2); + + return BlockCount * BlockSize; + } + }//namespace detail + + inline image2D::image2D() : + Data(0), + Dimensions(0), + Format(FORMAT_NULL) + {} + + inline image2D::image2D + ( + image2D const & Image + ) : + Data(Image.Data), + Dimensions(Image.Dimensions), + Format(Image.Format) + {} + + inline image2D::image2D + ( + dimensions_type const & Dimensions, + format_type const & Format + ) : + Data((glm::compMul(Dimensions) * detail::sizeBitPerPixel(Format)) >> 3), + Dimensions(Dimensions), + Format(Format) + { + std::size_t Size = (glm::compMul(Dimensions) * detail::sizeBitPerPixel(Format)) >> 3; + } + + inline image2D::image2D + ( + dimensions_type const & Dimensions, + format_type const & Format, + std::vector const & Data + ) : + Data(Data), + Dimensions(Dimensions), + Format(Format) + {} + + inline image2D::~image2D() + {} + + template + inline void image2D::setPixel + ( + dimensions_type const & TexelCoord, + genType const & TexelData + ) + { + size_type Index = this->dimensions().x * sizeof(genType) * TexelCoord.y + sizeof(genType) * TexelCoord.x; + memcpy(this->data() + Index, &TexelData[0], sizeof(genType)); + } + + inline image2D::size_type image2D::value_size() const + { + return detail::sizeBitPerPixel(this->format()); + } + + inline image2D::size_type image2D::capacity() const + { + return detail::sizeLinear(*this); + } + + inline image2D::dimensions_type image2D::dimensions() const + { + return this->Dimensions; + } + + inline image2D::size_type image2D::components() const + { + return detail::sizeComponent(this->format()); + } + + inline image2D::format_type image2D::format() const + { + return this->Format; + } + + inline image2D::value_type * image2D::data() + { + return &this->Data[0]; + } + + inline image2D::value_type const * const image2D::data() const + { + return &this->Data[0]; + } +}//namespace gli diff --git a/test/external/gli/core/operation.hpp b/test/external/gli/core/operation.hpp new file mode 100644 index 00000000..c23c29d7 --- /dev/null +++ b/test/external/gli/core/operation.hpp @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-12-19 +// Updated : 2010-01-09 +// Licence : This source is under MIT License +// File : gli/operation.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_OPERATION_INCLUDED +#define GLI_OPERATION_INCLUDED + +#include "texture2d.hpp" + +namespace gli +{ + texture2D duplicate(texture2D const & Texture); + texture2D flip(texture2D const & Texture); + texture2D mirror(texture2D const & Texture); + texture2D swizzle( + texture2D const & Texture, + glm::uvec4 const & Channel); + texture2D crop( + texture2D const & Texture, + texture2D::dimensions_type const & Position, + texture2D::dimensions_type const & Size); + + image2D crop( + image2D const & Image, + texture2D::dimensions_type const & Position, + texture2D::dimensions_type const & Size); + + image2D copy( + image2D const & SrcImage, + image2D::dimensions_type const & SrcPosition, + image2D::dimensions_type const & SrcSize, + image2D & DstImage, + image2D::dimensions_type const & DstPosition); + + //image operator+(image const & MipmapA, image const & MipmapB); + //image operator-(image const & MipmapA, image const & MipmapB); + //image operator*(image const & MipmapA, image const & MipmapB); + //image operator/(image const & MipmapA, image const & MipmapB); + + //namespace wip + //{ + // template class SURFACE> + // GENTYPE fetch(SURFACE const & Image) + // { + // return GENTYPE(); + // } + + // template + // < + // typename GENTYPE, + // template + // < + // typename + // > + // class SURFACE, + // template + // < + // typename, + // template + // < + // typename + // > + // class + // > + // class IMAGE + // > + // GENTYPE fetch(IMAGE const & Image) + // { + // return GENTYPE(); + // } + //}//namespace wip + +}//namespace gli + +#include "operation.inl" + +#endif//GLI_OPERATION_INCLUDED diff --git a/test/external/gli/core/operation.inl b/test/external/gli/core/operation.inl new file mode 100644 index 00000000..87999a81 --- /dev/null +++ b/test/external/gli/core/operation.inl @@ -0,0 +1,233 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-12-19 +// Updated : 2010-09-08 +// Licence : This source is under MIT License +// File : gli/core/operation.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include + +namespace gli +{ + namespace detail + { + inline image2D duplicate(image2D const & Mipmap2D) + { + image2D Result(Mipmap2D.dimensions(), Mipmap2D.format()); + memcpy(Result.data(), Mipmap2D.data(), Mipmap2D.capacity()); + return Result; + } + + inline image2D flip(image2D const & Mipmap2D) + { + image2D Result(Mipmap2D.dimensions(), Mipmap2D.format()); + + std::size_t ValueSize = Result.value_size(); + glm::byte * DstPtr = Result.data(); + glm::byte const * const SrcPtr = Mipmap2D.data(); + + for(std::size_t j = 0; j < Result.dimensions().y; ++j) + for(std::size_t i = 0; i < Result.dimensions().x; ++i) + { + std::size_t DstIndex = (i + j * Result.dimensions().y) * ValueSize; + std::size_t SrcIndex = (i + (Result.dimensions().y - j) * Result.dimensions().x) * ValueSize; + memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize); + } + + return Result; + } + + inline image2D mirror(image2D const & Mipmap2D) + { + image2D Result(Mipmap2D.dimensions(), Mipmap2D.format()); + + std::size_t ValueSize = Mipmap2D.value_size(); + glm::byte * DstPtr = Result.data(); + glm::byte const * const SrcPtr = Mipmap2D.data(); + + for(std::size_t j = 0; j < Result.dimensions().y; ++j) + for(std::size_t i = 0; i < Result.dimensions().x; ++i) + { + std::size_t DstIndex = (i + j * Result.dimensions().x) * ValueSize; + std::size_t SrcIndex = ((Result.dimensions().x - i) + j * Result.dimensions().x) * ValueSize; + memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize); + } + + return Result; + } + + inline image2D swizzle + ( + image2D const & Mipmap, + glm::uvec4 const & Channel + ) + { + image2D Result = detail::duplicate(Mipmap); + + glm::byte * DataDst = Result.data(); + glm::byte const * const DataSrc = Mipmap.data(); + + gli::texture2D::size_type CompSize = Mipmap.value_size() / Mipmap.components(); + gli::texture2D::size_type TexelCount = Mipmap.capacity() / Mipmap.value_size(); + + for(gli::texture2D::size_type t = 0; t < TexelCount; ++t) + for(gli::texture2D::size_type c = 0; c < Mipmap.components(); ++c) + { + gli::texture2D::size_type IndexSrc = t * Mipmap.components() + Channel[glm::uvec4::size_type(c)]; + gli::texture2D::size_type IndexDst = t * Mipmap.components() + c; + + memcpy(DataDst + IndexDst, DataSrc + IndexSrc, CompSize); + } + + return Result; + } + + inline image2D crop + ( + image2D const & Image, + image2D::dimensions_type const & Position, + image2D::dimensions_type const & Size + ) + { + assert((Position.x + Size.x) <= Image.dimensions().x && (Position.y + Size.y) <= Image.dimensions().y); + + image2D Result(Size, Image.format()); + + glm::byte* DstData = Result.data(); + glm::byte const * const SrcData = Image.data(); + + for(std::size_t j = 0; j < Size.y; ++j) + { + std::size_t DstIndex = 0 + (0 + j) * Size.x * Image.value_size(); + std::size_t SrcIndex = Position.x * Image.value_size() + (Position.y + j) * Image.dimensions().x * Image.value_size(); + memcpy(DstData + DstIndex, SrcData + SrcIndex, Image.value_size() * Size.x); + } + + return Result; + } + + inline image2D copy + ( + image2D const & SrcMipmap, + image2D::dimensions_type const & SrcPosition, + image2D::dimensions_type const & SrcSize, + image2D & DstMipmap, + image2D::dimensions_type const & DstPosition + ) + { + assert((SrcPosition.x + SrcSize.x) <= SrcMipmap.dimensions().x && (SrcPosition.y + SrcSize.y) <= SrcMipmap.dimensions().y); + assert(SrcMipmap.format() == DstMipmap.format()); + + glm::byte * DstData = DstMipmap.data(); + glm::byte const * const SrcData = SrcMipmap.data(); + + std::size_t SizeX = std::min(std::size_t(SrcSize.x + SrcPosition.x), std::size_t(DstMipmap.dimensions().x + DstPosition.x)); + std::size_t SizeY = std::min(std::size_t(SrcSize.y + SrcPosition.y), std::size_t(DstMipmap.dimensions().y + DstPosition.y)); + + for(std::size_t j = 0; j < SizeY; ++j) + { + std::size_t DstIndex = DstPosition.x * DstMipmap.value_size() + (DstPosition.y + j) * DstMipmap.dimensions().x * DstMipmap.value_size(); + std::size_t SrcIndex = SrcPosition.x * SrcMipmap.value_size() + (SrcPosition.y + j) * SrcMipmap.dimensions().x * SrcMipmap.value_size(); + memcpy(DstData + DstIndex, SrcData + SrcIndex, SrcMipmap.value_size() * SizeX); + } + + return DstMipmap; + } + + }//namespace detail + + inline texture2D duplicate(texture2D const & Texture2D) + { + texture2D Result(Texture2D.levels()); + for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) + Result[Level] = detail::duplicate(Texture2D[Level]); + return Result; + } + + inline texture2D flip(texture2D const & Texture2D) + { + texture2D Result(Texture2D.levels()); + for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) + Result[Level] = detail::flip(Texture2D[Level]); + return Result; + } + + inline texture2D mirror(texture2D const & Texture2D) + { + texture2D Result(Texture2D.levels()); + for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) + Result[Level] = detail::mirror(Texture2D[Level]); + return Result; + } + + inline texture2D crop + ( + texture2D const & Texture2D, + texture2D::dimensions_type const & Position, + texture2D::dimensions_type const & Size + ) + { + texture2D Result(Texture2D.levels()); + for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) + Result[Level] = detail::crop( + Texture2D[Level], + Position >> texture2D::dimensions_type(Level), + Size >> texture2D::dimensions_type(Level)); + return Result; + } + + inline texture2D swizzle + ( + texture2D const & Texture2D, + glm::uvec4 const & Channel + ) + { + texture2D Result(Texture2D.levels()); + for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) + Result[Level] = detail::swizzle(Texture2D[Level], Channel); + return Result; + } + + inline texture2D copy + ( + texture2D const & SrcImage, + texture2D::level_type const & SrcLevel, + texture2D::dimensions_type const & SrcPosition, + texture2D::dimensions_type const & SrcDimensions, + texture2D & DstMipmap, + texture2D::level_type const & DstLevel, + texture2D::dimensions_type const & DstDimensions + ) + { + detail::copy( + SrcImage[SrcLevel], + SrcPosition, + SrcDimensions, + DstMipmap[DstLevel], + DstDimensions); + return DstMipmap; + } + + //inline image operator+(image const & MipmapA, image const & MipmapB) + //{ + // + //} + + //inline image operator-(image const & MipmapA, image const & MipmapB) + //{ + // + //} + + //inline image operator*(image const & MipmapA, image const & MipmapB) + //{ + // + //} + + //inline image operator/(image const & MipmapA, image const & MipmapB) + //{ + // + //} + +}//namespace gli diff --git a/test/external/gli/core/operator.hpp b/test/external/gli/core/operator.hpp new file mode 100644 index 00000000..46f27321 --- /dev/null +++ b/test/external/gli/core/operator.hpp @@ -0,0 +1,28 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-01-19 +// Updated : 2010-01-19 +// Licence : This source is under MIT License +// File : gli/core/operator.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_OPERATOR_INCLUDED +#define GLI_OPERATOR_INCLUDED + +#include "texture2d.hpp" + +namespace gli{ +namespace detail +{ + +}//namespace detail + + texture2D operator+(texture2D const & TextureA, texture2D const & TextureB); + texture2D operator-(texture2D const & TextureA, texture2D const & TextureB); + +}//namespace gli + +#include "operator.inl" + +#endif//GLI_OPERATOR_INCLUDED diff --git a/test/external/gli/core/operator.inl b/test/external/gli/core/operator.inl new file mode 100644 index 00000000..1ac83281 --- /dev/null +++ b/test/external/gli/core/operator.inl @@ -0,0 +1,210 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-01-19 +// Updated : 2010-01-19 +// Licence : This source is under MIT License +// File : gli/core/operator.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace gli +{ + namespace detail + { + template + void element + ( + T & DataDst, + T const & DataSrcA, + T const & DataSrcB, + std::binary_function const & Func + ) + { + *DataDst = Func(DataSrcA, DataSrcB); + } + + void op + ( + texture2D::value_type * DataDst, + texture2D::value_type const * const DataSrcA, + texture2D::value_type const * const DataSrcB, + format Format + ) + { + std::plus<>() + switch(Format) + { + case R8U: + *((glm::u8*)DataDst) = *((glm::u8*)DataSrcA) + *((glm::u8*)DataSrcB); + break; + case RG8U: + *((glm::u8vec2*)DataDst) = *((glm::u8vec2*)DataSrcA) + *((glm::u8vec2*)DataSrcB); + break; + case RGB8U: + *((glm::u8vec3*)DataDst) = *((glm::u8vec3*)DataSrcA) + *((glm::u8vec3*)DataSrcB); + break; + case RGBA8U: + *((glm::u8vec4*)DataDst) = *((glm::u8vec4*)DataSrcA) + *((glm::u8vec4*)DataSrcB); + break; + + case R16U: + *((glm::u16*)DataDst) = *((glm::u16*)DataSrcA) + *((glm::u16*)DataSrcB); + break; + case RG16U: + *((glm::u16vec2*)DataDst) = *((glm::u16vec2*)DataSrcA) + *((glm::u16vec2*)DataSrcB); + break; + case RGB16U: + *((glm::u16vec3*)DataDst) = *((glm::u16vec3*)DataSrcA) + *((glm::u16vec3*)DataSrcB); + break; + case RGBA16U: + *((glm::u16vec4*)DataDst) = *((glm::u16vec4*)DataSrcA) + *((glm::u16vec4*)DataSrcB); + break; + + case R32U: + *((glm::u32*)DataDst) = *((glm::u32*)DataSrcA) + *((glm::u32*)DataSrcB); + break; + case RG32U: + *((glm::u32vec2*)DataDst) = *((glm::u32vec2*)DataSrcA) + *((glm::u32vec2*)DataSrcB); + break; + case RGB32U: + *((glm::u32vec3*)DataDst) = *((glm::u32vec3*)DataSrcA) + *((glm::u32vec3*)DataSrcB); + break; + case RGBA32U: + *((glm::u32vec4*)DataDst) = *((glm::u32vec4*)DataSrcA) + *((glm::u32vec4*)DataSrcB); + break; + + case R8I: + *((glm::i8*)DataDst) = *((glm::i8*)DataSrcA) + *((glm::i8*)DataSrcB); + break; + case RG8I: + *((glm::i8vec2*)DataDst) = *((glm::i8vec2*)DataSrcA) + *((glm::i8vec2*)DataSrcB); + break; + case RGB8I: + *((glm::i8vec3*)DataDst) = *((glm::i8vec3*)DataSrcA) + *((glm::i8vec3*)DataSrcB); + break; + case RGBA8I: + *((glm::i8vec4*)DataDst) = *((glm::i8vec4*)DataSrcA) + *((glm::i8vec4*)DataSrcB); + break; + + case R16I: + *((glm::i16*)DataDst) = *((glm::i16*)DataSrcA) + *((glm::i16*)DataSrcB); + break; + case RG16I: + *((glm::i16vec2*)DataDst) = *((glm::i16vec2*)DataSrcA) + *((glm::i16vec2*)DataSrcB); + break; + case RGB16I: + *((glm::i16vec3*)DataDst) = *((glm::i16vec3*)DataSrcA) + *((glm::i16vec3*)DataSrcB); + break; + case RGBA16I: + *((glm::i16vec4*)DataDst) = *((glm::i16vec4*)DataSrcA) + *((glm::i16vec4*)DataSrcB); + break; + + case R32I: + *((glm::i32*)DataDst) = *((glm::i32*)DataSrcA) + *((glm::i32*)DataSrcB); + break; + case RG32I: + *((glm::i32vec2*)DataDst) = *((glm::i32vec2*)DataSrcA) + *((glm::i32vec2*)DataSrcB); + break; + case RGB32I: + *((glm::i32vec3*)DataDst) = *((glm::i32vec3*)DataSrcA) + *((glm::i32vec3*)DataSrcB); + break; + case RGBA32I: + *((glm::i32vec4*)DataDst) = *((glm::i32vec4*)DataSrcA) + *((glm::i32vec4*)DataSrcB); + break; + + case R16F: + *((glm::f16*)DataDst) = *((glm::f16*)DataSrcA) + *((glm::f16*)DataSrcB); + break; + case RG16F: + *((glm::f16vec2*)DataDst) = *((glm::f16vec2*)DataSrcA) + *((glm::f16vec2*)DataSrcB); + break; + case RGB16F: + *((glm::f16vec3*)DataDst) = *((glm::f16vec3*)DataSrcA) + *((glm::f16vec3*)DataSrcB); + break; + case RGBA16F: + *((glm::f16vec4*)DataDst) = *((glm::f16vec4*)DataSrcA) + *((glm::f16vec4*)DataSrcB); + break; + + case R32F: + *((glm::f32*)DataDst) = *((glm::f32*)DataSrcA) + *((glm::f32*)DataSrcB); + break; + case RG32F: + *((glm::f32vec2*)DataDst) = *((glm::f32vec2*)DataSrcA) + *((glm::f32vec2*)DataSrcB); + break; + case RGB32F: + *((glm::f32vec3*)DataDst) = *((glm::f32vec3*)DataSrcA) + *((glm::f32vec3*)DataSrcB); + break; + case RGBA32F: + *((glm::f32vec4*)DataDst) = *((glm::f32vec4*)DataSrcA) + *((glm::f32vec4*)DataSrcB); + break; + default: + assert(0); + } + } + + void add + ( + texture2D::image & Result, + texture2D::image const & ImageA, + texture2D::image const & ImageB, + ) + { + + } + + }//namespace detail + + texture2D operator+ + ( + texture2D const & ImageA, + texture2D const & ImageB + ) + { + assert(ImageA.levels() == ImageB.levels()); + texture2D Result[ImageA.levels()]; + + for(texture2D::level_type Level = 0; Level < Result.levels(); ++Level) + { + assert(ImageA.capacity() == ImageB.capacity()); + assert(ImageA.format() == ImageB.format()); + + Result[Level] = texture2D::image(ImageA[Level].dimensions(), ImageA[Level].format()); + + add(Result[Level], ImageA[Level], ImageB[Level]); + + texture2D::size_type ValueSize = Result.value_size(); + texture2D::size_type TexelCount = this->capacity() / ValueSize; + for(texture2D::size_type Texel = 0; Texel < TexelCount; ++Texel) + { + texture2D::value_type * DataDst = Result[Level].data() + Texel * ValueSize; + texture2D::value_type const * const DataSrcA = ImageA[Level].data() + Texel * ValueSize; + texture2D::value_type const * const DataSrcB = ImageB[Level].data() + Texel * ValueSize; + + detail::op(DataDst, DataSrcA, DataSrcB, Result.format(), std::plus); + } + } + + return Result; + } + + texture2D operator- + ( + texture2D const & ImageA, + texture2D const & ImageB + ) + { + assert(ImageA.levels() == ImageB.levels()); + texture2D Result[ImageA.levels()]; + + + for(texture2D::level_type Level = 0; Level < ImageA.levels(); ++Level) + { + assert(ImageA.capacity() == ImageB.capacity()); + + + } + + return Result; + } + +}//namespace gli diff --git a/test/external/gli/core/shared_array.hpp b/test/external/gli/core/shared_array.hpp new file mode 100644 index 00000000..326a54af --- /dev/null +++ b/test/external/gli/core/shared_array.hpp @@ -0,0 +1,48 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-12-19 +// Updated : 2005-06-13 +// Licence : This source is under MIT License +// File : gli/shared_array.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_SHARED_ARRAY_INCLUDED +#define GLI_SHARED_ARRAY_INCLUDED + +namespace gli +{ + template + class shared_array + { + public: + + shared_array(); + shared_array(shared_array const & SharedArray); + shared_array(T * Pointer); + virtual ~shared_array(); + + void reset(); + void reset(T * Pointer); + + T & operator*(); + T * operator->(); + T const & operator*() const; + T const * const operator->() const; + + T * get(); + T const * const get() const; + + shared_array & operator=(shared_array const & SharedArray); + bool operator==(shared_array const & SharedArray) const; + bool operator!=(shared_array const & SharedArray) const; + + private: + int * Counter; + T * Pointer; + }; +}//namespace gli + +#include "shared_array.inl" + +#endif //GLI_SHARED_ARRAY_INCLUDED diff --git a/test/external/gli/core/shared_array.inl b/test/external/gli/core/shared_array.inl new file mode 100644 index 00000000..74edbb4a --- /dev/null +++ b/test/external/gli/core/shared_array.inl @@ -0,0 +1,151 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-12-19 +// Updated : 2005-06-13 +// Licence : This source is under MIT License +// File : gli/shared_array.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace gli +{ + template + shared_array::shared_array() : + Counter(0), + Pointer(0) + {} + + template + shared_array::shared_array + ( + shared_array const & SharedArray + ) + { + this->Counter = SharedArray.Counter; + this->Pointer = SharedArray.Pointer; + (*this->Counter)++; + } + + template + shared_array::shared_array + ( + T * Pointer + ) + { + this->reset(Pointer); + } + + template + shared_array::~shared_array() + { + this->reset(); + } + + template + void shared_array::reset() + { + if(this->Pointer) + { + (*this->Counter)--; + if(*this->Counter <= 0) + { + delete this->Counter; + this->Counter = 0; + delete[] this->Pointer; + this->Pointer = 0; + } + } + } + + template + void shared_array::reset(T * Pointer) + { + this->Counter = new int; + this->Pointer = Pointer; + *this->Counter = 1; + } + + template + shared_array& shared_array::operator= + ( + shared_array const & SharedArray + ) + { + this->reset(); + + this->Counter = SharedArray.Counter; + this->Pointer = SharedArray.Pointer; + (*this->Counter)++; + + return *this; + } + + //template + //shared_array & shared_array::operator=(T * Pointer) + //{ + // if(this->Pointer) + // { + // (*this->Counter)--; + // if(*this->Counter <= 0) + // { + // delete this->Counter; + // delete[] this->Pointer; + // } + // } + + // this->Counter = new int; + // this->Pointer = this->Pointer; + // (*this->Counter) = 1; + + // return *this; + //} + + template + bool shared_array::operator==(shared_array const & SharedArray) const + { + return this->Pointer == SharedArray.Pointer; + } + + template + bool shared_array::operator!=(shared_array const & SharedArray) const + { + return this->Pointer != SharedArray.Pointer; + } + + template + T & shared_array::operator*() + { + return *this->Pointer; + } + + template + T * shared_array::operator->() + { + return this->Pointer; + } + + template + T const & shared_array::operator*() const + { + return * this->Pointer; + } + + template + T const * const shared_array::operator->() const + { + return this->Pointer; + } + + template + T * shared_array::get() + { + return this->Pointer; + } + + template + T const * const shared_array::get() const + { + return this->Pointer; + } + +}//namespace gli diff --git a/test/external/gli/core/shared_ptr.hpp b/test/external/gli/core/shared_ptr.hpp new file mode 100644 index 00000000..533e33f5 --- /dev/null +++ b/test/external/gli/core/shared_ptr.hpp @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-12-19 +// Updated : 2005-06-13 +// Licence : This source is under MIT License +// File : gli/fetch.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_SHARED_PTR_INCLUDED +#define GLI_SHARED_PTR_INCLUDED + +namespace gli +{ + template + class shared_ptr + { + public: + shared_ptr(); + shared_ptr(shared_ptr const & SmartPtr); + shared_ptr(T* pPointer); + ~shared_ptr(); + + T& operator*(); + T* operator->(); + const T& operator*() const; + const T* operator->() const; + shared_ptr& operator=(shared_ptr const & SmartPtr); + shared_ptr& operator=(T* pPointer); + bool operator==(shared_ptr const & SmartPtr) const; + bool operator!=(shared_ptr const & SmartPtr) const; + + private: + int* m_pReference; + T* m_pPointer; + }; +}//namespace gli + +#include "shared_ptr.inl" + +#endif //GLI_SHARED_PTR_INCLUDED diff --git a/test/external/gli/core/shared_ptr.inl b/test/external/gli/core/shared_ptr.inl new file mode 100644 index 00000000..43974110 --- /dev/null +++ b/test/external/gli/core/shared_ptr.inl @@ -0,0 +1,125 @@ +/////////////////////////////////////////////////////////////////////////// +// Interstate Gangs : smart_ptr.inl +/////////////////////////////////////////////////////////////////////////// +// This file is under GPL licence +/////////////////////////////////////////////////////////////////////////// +// CHANGELOG +// Groove - 13/06/2005 : +// - Create file +/////////////////////////////////////////////////////////////////////////// + +namespace gli +{ + template + util::CSmartPtr::CSmartPtr() + { + m_pPointer = 0; + } + + template + util::CSmartPtr::CSmartPtr(const util::CSmartPtr & SmartPtr) + { + m_pReference = SmartPtr.m_pReference; + m_pPointer = SmartPtr.m_pPointer; + (*m_pReference)++; + } + + template + util::CSmartPtr::CSmartPtr(T* pPointer) + { + m_pReference = new int; + m_pPointer = pPointer; + (*m_pReference) = 1; + } + + template + util::CSmartPtr::~CSmartPtr() + { + if(!m_pPointer) + return; + + (*m_pReference)--; + if(*m_pReference <= 0) + { + delete m_pReference; + delete m_pPointer; + } + } + + template + util::CSmartPtr& util::CSmartPtr::operator=(const util::CSmartPtr & SmartPtr) + { + if(m_pPointer) + { + (*m_pReference)--; + if(*m_pReference <= 0) + { + delete m_pReference; + delete m_pPointer; + } + } + + m_pReference = SmartPtr.m_pReference; + m_pPointer = SmartPtr.m_pPointer; + (*m_pReference)++; + + return *this; + } + + template + util::CSmartPtr& util::CSmartPtr::operator=(T* pPointer) + { + if(m_pPointer) + { + (*m_pReference)--; + if(*m_pReference <= 0) + { + delete m_pReference; + delete m_pPointer; + } + } + + m_pReference = new int; + m_pPointer = pPointer; + (*m_pReference) = 1; + + return *this; + } + + template + bool util::CSmartPtr::operator==(const util::CSmartPtr & SmartPtr) const + { + return m_pPointer == SmartPtr.m_pPointer; + } + + template + bool util::CSmartPtr::operator!=(const util::CSmartPtr & SmartPtr) const + { + return m_pPointer != SmartPtr.m_pPointer; + } + + template + T& util::CSmartPtr::operator*() + { + return *m_pPointer; + } + + template + T* util::CSmartPtr::operator->() + { + return m_pPointer; + } + + template + const T& util::CSmartPtr::operator*() const + { + return *m_pPointer; + } + + template + const T* util::CSmartPtr::operator->() const + { + return m_pPointer; + } + +}//namespace gli diff --git a/test/external/gli/core/size.hpp b/test/external/gli/core/size.hpp new file mode 100644 index 00000000..3fe461ba --- /dev/null +++ b/test/external/gli/core/size.hpp @@ -0,0 +1,31 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-09-08 +// Updated : 2010-09-08 +// Licence : This source is under MIT License +// File : gli/core/size.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_CORE_SIZE_INCLUDED +#define GLI_CORE_SIZE_INCLUDED + +#include "texture2d.hpp" + +namespace gli +{ + //template + image2D::size_type size( + image2D const & Image, + image2D::size_type const & SizeType); + + //template + texture2D::size_type size( + texture2D const & Texture, + texture2D::size_type const & SizeType); + +}//namespace gli + +#include "size.inl" + +#endif//GLI_CORE_SIZE_INCLUDED diff --git a/test/external/gli/core/size.inl b/test/external/gli/core/size.inl new file mode 100644 index 00000000..dfb61238 --- /dev/null +++ b/test/external/gli/core/size.inl @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-12-19 +// Updated : 2010-09-08 +// Licence : This source is under MIT License +// File : gli/core/size.inl +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace gli +{ + inline image2D::size_type size + ( + image2D const & Image, + image2D::size_type const & SizeType + ) + { + switch(SizeType) + { + case LINEAR_SIZE: + return detail::sizeLinear(Image); + case BLOCK_SIZE: + return detail::sizeBlock(Image.format()); + case BIT_PER_PIXEL: + return detail::sizeBitPerPixel(Image.format()); + case COMPONENT: + return detail::sizeComponent(Image.format()); + default: + assert(0); + return 0; + }; + } + + inline texture2D::size_type size + ( + texture2D const & Texture, + texture2D::size_type const & SizeType + ) + { + texture2D::size_type Size = 0; + for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level) + Size += size(Texture[Level], SizeType); + + return Size; + } + +}//namespace diff --git a/test/external/gli/core/texture2d.hpp b/test/external/gli/core/texture2d.hpp new file mode 100644 index 00000000..af2983e8 --- /dev/null +++ b/test/external/gli/core/texture2d.hpp @@ -0,0 +1,106 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2010-01-09 +// Updated : 2010-01-09 +// Licence : This source is under MIT License +// File : gli/core/texture2d.hpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef GLI_CORE_TEXTURE2D_INCLUDED +#define GLI_CORE_TEXTURE2D_INCLUDED + +#include "image2d.hpp" + +namespace gli +{ + //template