Merge branch '0.9.3' of ssh://g-truc.git.sourceforge.net/gitroot/ogl-math/ogl-math into 0.9.3

This commit is contained in:
Christophe Riccio 2011-07-11 01:52:24 +01:00
commit daeada071c
55 changed files with 5003 additions and 284 deletions

View file

@ -22,6 +22,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
include_directories(".")
include_directories("./test/external")
add_subdirectory(glm)
add_subdirectory(test)

View file

@ -24,48 +24,51 @@
/// @file glm/core/func_common.hpp
/// @date 2008-03-08 / 2010-01-26
/// @author Christophe Riccio
///
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
/// @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/abs.xml">GLSL abs man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genFIType>
genFIType abs(genFIType const & x);
/// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
///
/// @see
/// @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
/// @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genFIType>
genFIType sign(genFIType const & x);
//! Returns a value equal to the nearest integer that is less then or equal to x.
//!
/// @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floor.xml">GLSL floor man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floor.xml">GLSL floor man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/trunc.xml">GLSL trunc man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/trunc.xml">GLSL trunc man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/roundEven.xml">GLSL roundEven man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/roundEven.xml">GLSL roundEven man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
genType roundEven(genType const & x);
//! Returns a value equal to the nearest integer
//! that is greater than or equal to x.
//!
/// @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ceil.xml">GLSL ceil man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ceil.xml">GLSL ceil man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
genType ceil(genType const & x);
//! Return x - floor(x).
//!
/// @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml">GLSL fract man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml">GLSL modf man page</a>
/// @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml">GLSL modf man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
genType modf(
genType const & x,
@ -145,9 +141,8 @@ namespace glm
/// Returns y if y < x; otherwise, it returns x.
///
/// @see
/// @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
/// @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/min.xml">GLSL min man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
genType min(
genType const & x,
@ -160,9 +155,8 @@ namespace glm
/// Returns y if x < y; otherwise, it returns x.
///
/// @see
/// @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
/// @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/max.xml">GLSL max man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/clamp.xml">GLSL clamp man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mix.xml">GLSL mix man page</a>
//! @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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mix.xml">GLSL mix man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
///
/// @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 <glm/glm.hpp>
/// ...
/// 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 <typename genTypeT, typename genTypeU>
genTypeT mix(genTypeT const & x, genTypeT const & y, genTypeU const & a);
//! Returns 0.0 if x < edge, otherwise it returns 1.0.
//!
//! @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
//!
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/step.xml">GLSL step man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/smoothstep.xml">GLSL smoothstep man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/smoothstep.xml">GLSL smoothstep man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
genType smoothstep(
genType const & edge0,
@ -266,9 +273,8 @@ namespace glm
//! including for implementations with no NaN
//! representations.
//!
//! @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isnan.xml">GLSL isnan man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isnan.xml">GLSL isnan man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
typename genType::bool_type isnan(genType const & x);
@ -278,9 +284,8 @@ namespace glm
//! otherwise, including for implementations with no infinity
//! representations.
//!
//! @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isinf.xml">GLSL isinf man page</a>
//! @li GLSL 1.30.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/isinf.xml">GLSL isinf man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToInt.xml">GLSL floatBitsToInt man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType, typename genIType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floatBitsToUint.xml">GLSL floatBitsToUint man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType, typename genUType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/intBitsToFloat.xml">GLSL intBitsToFloat man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType, typename genIType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uintBitsToFloat.xml">GLSL uintBitsToFloat man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType, typename genUType>
genType uintBitsToFloat(genUType const & value);
//! Computes and returns a * b + c.
//!
//! @see
//! @li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fma.xml">GLSL fma man page</a>
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/fma.xml">GLSL fma man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType, typename genIType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
//! @li GLSL 4.00.08 specification, section 8.3
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
/// @see - <a href="http://www.opengl.org/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.3</a>
template <typename genType, typename genIType>
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

View file

@ -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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/pow.xml">GLSL pow man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>
@ -51,7 +50,6 @@ namespace glm
/// Returns the natural exponentiation of x, i.e., e^x.
///
/// @see
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/exp.xml">GLSL exp man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>
@ -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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/log.xml">GLSL log man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>
@ -69,7 +66,6 @@ namespace glm
/// Returns 2 raised to the x power.
///
/// @see
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/exp2.xml">GLSL exp2 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>
@ -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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/log2.xml">GLSL log2 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>
@ -86,7 +81,6 @@ namespace glm
/// Returns the positive square root of x.
///
/// @see
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sqrt.xml">GLSL sqrt man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>
@ -94,7 +88,6 @@ namespace glm
/// Returns the reciprocal of the positive square root of x.
///
/// @see
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inversesqrt.xml">GLSL inversesqrt man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.2</a>
template <typename genType>

View file

@ -24,85 +24,92 @@
/// @file glm/core/func_geometric.hpp
/// @date 2008-08-03 / 2011-06-14
/// @author Christophe Riccio
///
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
//! \li GLSL 1.30.08 specification, section 8.4
/// Returns the length of x, i.e., sqrt(x * x).
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/length.xml">GLSL length man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
typename genType::value_type length(
genType const & x);
//! Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
//! \li GLSL 1.30.08 specification, section 8.4
/// Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/distance.xml">GLSL distance man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
//! \li GLSL 1.30.08 specification, section 8.4
/// Returns the dot product of x and y, i.e., result = x * y.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
typename genType::value_type dot(
genType const & x,
genType const & y);
//! Returns the cross product of x and y.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
//! \li GLSL 1.30.08 specification, section 8.4
/// Returns the cross product of x and y.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cross.xml">GLSL cross man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename T>
detail::tvec3<T> cross(
detail::tvec3<T> const & x,
detail::tvec3<T> const & y);
//! Returns a vector in the same direction as x but with length of 1.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
//! \li GLSL 1.30.08 specification, section 8.4
/// Returns a vector in the same direction as x but with length of 1.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/normalize.xml">GLSL normalize man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
genType normalize(
genType const & x);
//! If dot(Nref, I) < 0.0, return N, otherwise, return -N.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
//! \li GLSL 1.30.08 specification, section 8.4
/// If dot(Nref, I) < 0.0, return N, otherwise, return -N.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/faceforward.xml">GLSL faceforward man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
//! \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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/reflect.xml">GLSL reflect man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
//! \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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/refract.xml">GLSL refract man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.5</a>
template <typename genType>
genType refract(
genType const & I,

View file

@ -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 - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uaddCarry.xml">GLSL uaddCarry man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/uaddCarry.xml">GLSL uaddCarry man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genUType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/usubBorrow.xml">GLSL usubBorrow man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/usubBorrow.xml">GLSL usubBorrow man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genUType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/umulExtended.xml">GLSL umulExtended man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/umulExtended.xml">GLSL umulExtended man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genUType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/imulExtended.xml">GLSL imulExtended man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/imulExtended.xml">GLSL imulExtended man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genIType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldExtract.xml">GLSL bitfieldExtract man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldExtract.xml">GLSL bitfieldExtract man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genIUType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldInsert.xml">GLSL bitfieldInsert man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldInsert.xml">GLSL bitfieldInsert man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genIUType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldReverse.xml">GLSL bitfieldReverse man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitfieldReverse.xml">GLSL bitfieldReverse man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename genIUType>
genIUType bitfieldReverse(genIUType const & value);
//! Returns the number of bits set to 1 in the binary representation of value.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/bitCount.xml">GLSL bitCount man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename T, template <typename> class C>
typename C<T>::signed_type bitCount(C<T> const & Value);
@ -142,8 +151,8 @@ namespace glm
//! 1 in the binary representation of value.
//! If value is zero, -1 will be returned.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findLSB.xml">GLSL findLSB man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename T, template <typename> class C>
typename C<T>::signed_type findLSB(C<T> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
//! \li GLSL 4.00.08 specification, section 8.8
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/findMSB.xml">GLSL findMSB man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.8</a>
template <typename T, template <typename> class C>
typename C<T>::signed_type findMSB(C<T> const & Value);

View file

@ -24,89 +24,100 @@
/// @file glm/core/func_matrix.hpp
/// @date 2008-08-03 / 2011-06-15
/// @author Christophe Riccio
///
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/matrixCompMult.xml">GLSL matrixCompMult man page</a>
//! \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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/matrixCompMult.xml">GLSL matrixCompMult man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename matType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
//! \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 - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename vecType, typename matType>
matType outerProduct(
vecType const & c,
vecType const & r);
//! Returns the transposed matrix of x
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/transpose.xml">GLSL transpose man page</a>
//! \li GLSL 1.30.08 specification, section 8.5
/// Returns the transposed matrix of x
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/transpose.xml">GLSL transpose man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename matType>
typename matType::transpose_type transpose(
matType const & x);
//! Return the determinant of a mat2 matrix.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
//! \li GLSL 1.30.08 specification, section 8.5
/// Return the determinant of a mat2 matrix.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename T>
typename detail::tmat2x2<T>::value_type determinant(
detail::tmat2x2<T> const & m);
//! Return the determinant of a mat3 matrix.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
//! \li GLSL 1.30.08 specification, section 8.5
/// Return the determinant of a mat3 matrix.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename T>
typename detail::tmat3x3<T>::value_type determinant(
detail::tmat3x3<T> const & m);
//! Return the determinant of a mat4 matrix.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
//! \li GLSL 1.30.08 specification, section 8.5
/// Return the determinant of a mat4 matrix.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename T>
typename detail::tmat4x4<T>::value_type determinant(
detail::tmat4x4<T> const & m);
//! Return the inverse of a mat2 matrix.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
//! \li GLSL 1.40.07 specification, section 8.5
/// Return the inverse of a mat2 matrix.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename T>
detail::tmat2x2<T> inverse(
detail::tmat2x2<T> const & m);
//! Return the inverse of a mat3 matrix.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
//! \li GLSL 1.40.07 specification, section 8.5
/// Return the inverse of a mat3 matrix.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename T>
detail::tmat3x3<T> inverse(
detail::tmat3x3<T> const & m);
//! Return the inverse of a mat4 matrix.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
//! \li GLSL 1.40.07 specification, section 8.5
/// Return the inverse of a mat4 matrix.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.6</a>
template <typename T>
detail::tmat4x4<T> inverse(
detail::tmat4x4<T> const & m);
@ -116,4 +127,4 @@ namespace glm
#include "func_matrix.inl"
#endif//glm_core_func_matrix
#endif//GLM_CORE_func_matrix

View file

@ -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 - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.11</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise1.xml">GLSL noise1 man page</a>
//! \li GLSL 1.30.08 specification, section 8.9
/// Returns a 1D noise value based on the input value x.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise1.xml">GLSL noise1 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.11</a>
template <typename genType>
typename genType::value_type noise1(genType const & x);
//! Returns a 2D noise value based on the input value x.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise2.xml">GLSL noise2 man page</a>
//! \li GLSL 1.30.08 specification, section 8.9
/// Returns a 2D noise value based on the input value x.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise2.xml">GLSL noise2 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.11</a>
template <typename genType>
detail::tvec2<typename genType::value_type> noise2(genType const & x);
//! Returns a 3D noise value based on the input value x.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise3.xml">GLSL noise3 man page</a>
//! \li GLSL 1.30.08 specification, section 8.9
/// Returns a 3D noise value based on the input value x.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise3.xml">GLSL noise3 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.11</a>
template <typename genType>
detail::tvec3<typename genType::value_type> noise3(genType const & x);
//! Returns a 4D noise value based on the input value x.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise4.xml">GLSL noise4 man page</a>
//! \li GLSL 1.30.08 specification, section 8.9
/// Returns a 4D noise value based on the input value x.
///
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/noise4.xml">GLSL noise4 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.11</a>
template <typename genType>
detail::tvec4<typename genType::value_type> noise4(genType const & x);

View file

@ -24,14 +24,21 @@
/// @file glm/core/func_packing.hpp
/// @date 2010-03-17 / 2011-06-15
/// @author Christophe Riccio
///
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm2x16.xml">GLSL packUnorm2x16 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm2x16.xml">GLSL packUnorm2x16 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::uint32 packUnorm2x16(detail::tvec2<detail::float32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packUnorm4x8.xml">GLSL packUnorm4x8 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::uint32 packUnorm4x8(detail::tvec4<detail::float32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packSnorm4x8.xml">GLSL packSnorm4x8 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::uint32 packSnorm4x8(detail::tvec4<detail::float32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm2x16.xml">GLSL unpackUnorm2x16 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::tvec2<detail::float32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackUnorm4x8.xml">GLSL unpackUnorm4x8 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::tvec4<detail::float32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackSnorm4x8.xml">GLSL unpackSnorm4x8 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::tvec4<detail::float32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packDouble2x32.xml">GLSL packDouble2x32 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/packDouble2x32.xml">GLSL packDouble2x32 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
double packDouble2x32(detail::tvec2<detail::uint32> 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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackDouble2x32.xml">GLSL unpackDouble2x32 man page</a>
//! \li GLSL 4.00.08 specification, section 8.4
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/unpackDouble2x32.xml">GLSL unpackDouble2x32 man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.4</a>
detail::tvec2<detail::uint32> unpackDouble2x32(double const & v);
/// @}
@ -136,5 +143,5 @@ namespace glm
#include "func_packing.inl"
#endif//glm_core_func_packing
#endif//GLM_CORE_func_packing

View file

@ -24,50 +24,61 @@
/// @file glm/core/func_trigonometric.hpp
/// @date 2008-08-01 / 2011-06-15
/// @author Christophe Riccio
///
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
///
/// @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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/radians.xml">GLSL radians man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType radians(genType const & degrees);
//! Converts radians to degrees and returns the result.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/degrees.xml">GLSL degrees man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType degrees(genType const & radians);
//! The standard trigonometric sine function.
//! The values returned by this function will range from [-1, 1].
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sin.xml">GLSL sin man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sin.xml">GLSL sin man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType sin(genType const & angle);
//! The standard trigonometric cosine function.
//! The values returned by this function will range from [-1, 1].
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cos.xml">GLSL cos man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cos.xml">GLSL cos man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType cos(genType const & angle);
//! The standard trigonometric tangent function.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tan.xml">GLSL tan man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tan.xml">GLSL tan man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asin.xml">GLSL asin man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asin.xml">GLSL asin man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acos.xml">GLSL acos man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acos.xml">GLSL acos man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
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 <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atan.xml">GLSL atan man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType atan(genType const & y_over_x);
//! Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sinh.xml">GLSL sinh man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sinh.xml">GLSL sinh man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType sinh(genType const & angle);
//! Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cosh.xml">GLSL cosh man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/cosh.xml">GLSL cosh man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType cosh(genType const & angle);
//! Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tanh.xml">GLSL tanh man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/tanh.xml">GLSL tanh man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType tanh(genType const & angle);
//! Arc hyperbolic sine; returns the inverse of sinh.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asinh.xml">GLSL asinh man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/asinh.xml">GLSL asinh man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType asinh(genType const & x);
//! Arc hyperbolic cosine; returns the non-negative inverse
//! of cosh. Results are undefined if x < 1.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acosh.xml">GLSL acosh man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/acosh.xml">GLSL acosh man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
genType acosh(genType const & x);
//! Arc hyperbolic tangent; returns the inverse of tanh.
//! Results are undefined if abs(x) >= 1.
//!
//! \li <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atanh.xml">GLSL atanh man page</a>
//! \li GLSL 1.30.08 specification, section 8.1
/// @see - <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/atanh.xml">GLSL atanh man page</a>
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.1</a>
template <typename genType>
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

View file

@ -24,16 +24,28 @@
/// @file glm/core/func_vector_relational.hpp
/// @date 2008-08-03 / 2011-06-15
/// @author Christophe Riccio
///
/// @see - <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.10.6.pdf">GLSL 4.10.6 specification, section 8.7</a>
///
/// @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

View file

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

27
test/external/gli/CMakeLists.txt vendored Normal file
View file

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

4
test/external/gli/core/dummy.cpp vendored Normal file
View file

@ -0,0 +1,4 @@
int main()
{
}

View file

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

View file

@ -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<texture2D::value_type*>(DataSrc)[Index00];
glm::u32 Data01 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index01];
glm::u32 Data11 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index11];
glm::u32 Data10 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index10];
texture2D::value_type Result = (Data00 + Data01 + Data11 + Data10) >> 2;
texture2D::value_type * Data = reinterpret_cast<texture2D::value_type*>(DataDst.data());
*(Data + ((i + j * LevelDimensions.x) * Components + c)) = Result;
}
Result[Level + 1] = image2D(LevelDimensions, Format, DataDst);
}
return Result;
}
}//namespace gli

169
test/external/gli/core/image2d.hpp vendored Normal file
View file

@ -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 <vector>
#include <cassert>
#include <cmath>
#include <cstring>
// GLM
#include <glm/glm.hpp>
#include <glm/gtx/number_precision.hpp>
#include <glm/gtx/raw_data.hpp>
#include <glm/gtx/gradient_paint.hpp>
#include <glm/gtx/component_wise.hpp>
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<value_type> data_type;
public:
image2D();
image2D(
image2D const & Image);
explicit image2D(
dimensions_type const & Dimensions,
format_type const & Format);
template <typename genType>
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<value_type> const & Data);
~image2D();
template <typename genType>
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

231
test/external/gli/core/image2d.inl vendored Normal file
View file

@ -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<value_type> const & Data
) :
Data(Data),
Dimensions(Dimensions),
Format(Format)
{}
inline image2D::~image2D()
{}
template <typename genType>
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

82
test/external/gli/core/operation.hpp vendored Normal file
View file

@ -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 <typename GENTYPE, template <typename> class SURFACE>
// GENTYPE fetch(SURFACE<GENTYPE> const & Image)
// {
// return GENTYPE();
// }
// template
// <
// typename GENTYPE,
// template
// <
// typename
// >
// class SURFACE,
// template
// <
// typename,
// template
// <
// typename
// >
// class
// >
// class IMAGE
// >
// GENTYPE fetch(IMAGE<GENTYPE, SURFACE> const & Image)
// {
// return GENTYPE();
// }
//}//namespace wip
}//namespace gli
#include "operation.inl"
#endif//GLI_OPERATION_INCLUDED

233
test/external/gli/core/operation.inl vendored Normal file
View file

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

28
test/external/gli/core/operator.hpp vendored Normal file
View file

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

210
test/external/gli/core/operator.inl vendored Normal file
View file

@ -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 <typename T>
void element
(
T & DataDst,
T const & DataSrcA,
T const & DataSrcB,
std::binary_function<T, T, T> 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

48
test/external/gli/core/shared_array.hpp vendored Normal file
View file

@ -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 <typename T>
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

151
test/external/gli/core/shared_array.inl vendored Normal file
View file

@ -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 <typename T>
shared_array<T>::shared_array() :
Counter(0),
Pointer(0)
{}
template <typename T>
shared_array<T>::shared_array
(
shared_array<T> const & SharedArray
)
{
this->Counter = SharedArray.Counter;
this->Pointer = SharedArray.Pointer;
(*this->Counter)++;
}
template <typename T>
shared_array<T>::shared_array
(
T * Pointer
)
{
this->reset(Pointer);
}
template <typename T>
shared_array<T>::~shared_array()
{
this->reset();
}
template <typename T>
void shared_array<T>::reset()
{
if(this->Pointer)
{
(*this->Counter)--;
if(*this->Counter <= 0)
{
delete this->Counter;
this->Counter = 0;
delete[] this->Pointer;
this->Pointer = 0;
}
}
}
template <typename T>
void shared_array<T>::reset(T * Pointer)
{
this->Counter = new int;
this->Pointer = Pointer;
*this->Counter = 1;
}
template <typename T>
shared_array<T>& shared_array<T>::operator=
(
shared_array<T> const & SharedArray
)
{
this->reset();
this->Counter = SharedArray.Counter;
this->Pointer = SharedArray.Pointer;
(*this->Counter)++;
return *this;
}
//template <typename T>
//shared_array<T> & shared_array<T>::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 <typename T>
bool shared_array<T>::operator==(shared_array<T> const & SharedArray) const
{
return this->Pointer == SharedArray.Pointer;
}
template <typename T>
bool shared_array<T>::operator!=(shared_array<T> const & SharedArray) const
{
return this->Pointer != SharedArray.Pointer;
}
template <typename T>
T & shared_array<T>::operator*()
{
return *this->Pointer;
}
template <typename T>
T * shared_array<T>::operator->()
{
return this->Pointer;
}
template <typename T>
T const & shared_array<T>::operator*() const
{
return * this->Pointer;
}
template <typename T>
T const * const shared_array<T>::operator->() const
{
return this->Pointer;
}
template <typename T>
T * shared_array<T>::get()
{
return this->Pointer;
}
template <typename T>
T const * const shared_array<T>::get() const
{
return this->Pointer;
}
}//namespace gli

41
test/external/gli/core/shared_ptr.hpp vendored Normal file
View file

@ -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 <typename T>
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

125
test/external/gli/core/shared_ptr.inl vendored Normal file
View file

@ -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 <typename T>
util::CSmartPtr<T>::CSmartPtr()
{
m_pPointer = 0;
}
template <typename T>
util::CSmartPtr<T>::CSmartPtr(const util::CSmartPtr<T> & SmartPtr)
{
m_pReference = SmartPtr.m_pReference;
m_pPointer = SmartPtr.m_pPointer;
(*m_pReference)++;
}
template <typename T>
util::CSmartPtr<T>::CSmartPtr(T* pPointer)
{
m_pReference = new int;
m_pPointer = pPointer;
(*m_pReference) = 1;
}
template <typename T>
util::CSmartPtr<T>::~CSmartPtr()
{
if(!m_pPointer)
return;
(*m_pReference)--;
if(*m_pReference <= 0)
{
delete m_pReference;
delete m_pPointer;
}
}
template <typename T>
util::CSmartPtr<T>& util::CSmartPtr<T>::operator=(const util::CSmartPtr<T> & 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 <typename T>
util::CSmartPtr<T>& util::CSmartPtr<T>::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 <typename T>
bool util::CSmartPtr<T>::operator==(const util::CSmartPtr<T> & SmartPtr) const
{
return m_pPointer == SmartPtr.m_pPointer;
}
template <typename T>
bool util::CSmartPtr<T>::operator!=(const util::CSmartPtr<T> & SmartPtr) const
{
return m_pPointer != SmartPtr.m_pPointer;
}
template <typename T>
T& util::CSmartPtr<T>::operator*()
{
return *m_pPointer;
}
template <typename T>
T* util::CSmartPtr<T>::operator->()
{
return m_pPointer;
}
template <typename T>
const T& util::CSmartPtr<T>::operator*() const
{
return *m_pPointer;
}
template <typename T>
const T* util::CSmartPtr<T>::operator->() const
{
return m_pPointer;
}
}//namespace gli

31
test/external/gli/core/size.hpp vendored Normal file
View file

@ -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 <size_type sizeType>
image2D::size_type size(
image2D const & Image,
image2D::size_type const & SizeType);
//template <size_type sizeType>
texture2D::size_type size(
texture2D const & Texture,
texture2D::size_type const & SizeType);
}//namespace gli
#include "size.inl"
#endif//GLI_CORE_SIZE_INCLUDED

47
test/external/gli/core/size.inl vendored Normal file
View file

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

106
test/external/gli/core/texture2d.hpp vendored Normal file
View file

@ -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 <template <typename> class mem>
class texture2D
{
public:
typedef image2D::dimensions_type dimensions_type;
typedef image2D::texcoord_type texcoord_type;
typedef image2D::size_type size_type;
typedef image2D::value_type value_type;
typedef image2D::format_type format_type;
typedef image2D::data_type data_type;
typedef std::size_t level_type;
public:
texture2D();
explicit texture2D(level_type const & Levels);
//texture2D(image const & Mipmap, bool GenerateMipmaps = false);
~texture2D();
image2D & operator[] (
level_type const & Level);
image2D const & operator[] (
level_type const & Level) const;
bool empty() const;
format_type format() const;
level_type levels() const;
void resize(level_type const & Levels);
template <typename genType>
void swizzle(glm::comp X, glm::comp Y, glm::comp Z, glm::comp W);
private:
std::vector<image2D> Images;
};
//namespace wip
//{
// // plain
// template <typename genType>
// class plain
// {
// public:
//
// private:
// boost::shared_array<genType> Data;
// };
//
// // texture2D
// template
// <
// typename genType,
// template <typename> class surface = plain
// >
// class texture2D
// {
// public:
// typedef genType value_type;
//
// private:
// class image_impl
// {
// public:
// template <typename coordType>
// value_type const & operator() (coordType const & Coord) const;
//
// private:
// surface<value_type> Surface;
// };
//
// public:
// typedef image_impl image;
// typedef std::vector<image> mipmaps;
// typedef typename mipmaps::size_type level_type;
//
// level_type levels() const;
// image & operator[] (level_type Level);
// image const & operator[] (level_type Level) const;
//
// private:
// mipmaps Mipmaps;
// };
//
//}//namespace wip
}//namespace gli
#include "texture2d.inl"
#endif//GLI_CORE_TEXTURE2D_INCLUDED

304
test/external/gli/core/texture2d.inl vendored Normal file
View file

@ -0,0 +1,304 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/texture2D.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli
{
namespace detail
{
inline texture2D::size_type sizeLinear
(
texture2D const & Texture
)
{
texture2D::size_type Result = 0;
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
Result += sizeLinear(Texture[Level]);
return Result;
}
}//namespace detail
inline texture2D::texture2D()
{}
inline texture2D::texture2D
(
level_type const & Levels
)
{
this->Images.resize(Levels);
}
//inline texture2D::texture2D
//(
// image const & Mipmap,
// bool GenerateMipmaps // ToDo
//)
//{
// //std::size_t Levels = !GenerateMipmaps ? 1 : std::size_t(glm::log2(float(glm::max(Mipmap.width(), Mipmap.height()))));
// texture2D::level_type Levels = !GenerateMipmaps ? 1 : std::size_t(glm::log2(float(glm::compMax(Mipmap.dimensions()))));
// this->Mipmaps.resize(Levels);
// this->Mipmaps[0] = Mipmap;
// if(GenerateMipmaps)
// this->generateMipmaps(0);
//}
inline texture2D::~texture2D()
{}
inline image2D & texture2D::operator[] (level_type const & Level)
{
return this->Images[Level];
}
inline image2D const & texture2D::operator[] (level_type const & Level) const
{
return this->Images[Level];
}
inline bool texture2D::empty() const
{
return this->Images.size() == 0;
}
inline texture2D::format_type texture2D::format() const
{
return this->Images.empty() ? FORMAT_NULL : this->Images[0].format();
}
inline texture2D::level_type texture2D::levels() const
{
return this->Images.size();
}
inline void texture2D::resize
(
texture2D::level_type const & Levels
)
{
this->Images.resize(Levels);
}
template <typename genType>
inline void texture2D::swizzle(glm::comp X, glm::comp Y, glm::comp Z, glm::comp W)
{
for(texture2D::level_type Level = 0; Level < this->levels(); ++Level)
{
genType * Data = reinterpret_cast<genType*>(this->Images[Level].data());
texture2D::size_type Components = this->Images[Level].components();
//gli::detail::getComponents(this->Images[Level].format());
texture2D::size_type Size = (glm::compMul(this->Images[Level].dimensions()) * Components) / sizeof(genType);
for(texture2D::size_type i = 0; i < Size; ++i)
{
genType Copy = Data[i];
if(Components > 0)
Data[i][0] = Copy[X];
if(Components > 1)
Data[i][1] = Copy[Y];
if(Components > 2)
Data[i][2] = Copy[Z];
if(Components > 3)
Data[i][3] = Copy[W];
}
}
}
/*
template <typename T>
inline T texture<T>::texture(float x, float y) const
{
size_type x_below = size_type(std::floor(x * (_width - 1)));
size_type x_above = size_type(std::ceil(x * (_width - 1)));
size_type y_below = size_type(std::floor(y * (_height - 1)));
size_type y_above = size_type(std::ceil(y * (_height - 1)));
float x_step = 1.0f / float(_width);
float y_step = 1.0f / float(_height);
float x_below_normalized = float(x_below) / float(_width - 1);
float x_above_normalized = float(x_above) / float(_width - 1);
float y_below_normalized = float(y_below) / float(_height - 1);
float y_above_normalized = float(y_above) / float(_height - 1);
T value1 = _data[x_below + y_below * _width];
T value2 = _data[x_above + y_below * _width];
T value3 = _data[x_above + y_above * _width];
T value4 = _data[x_below + y_above * _width];
T valueA = glm::mix(value1, value2, x - x_below_normalized);
T valueB = glm::mix(value4, value3, x - x_below_normalized);
T valueC = glm::mix(valueA, valueB, y - y_below_normalized);
return valueC;
}
*/
/*
template <typename T>
inline T texture(const texture2D<T>& Image2D, const glm::vec2& TexCoord)
{
texture2D<T>::size_type s_below = texture2D<T>::size_type(std::floor(TexCoord.s * (Image2D.width() - 1)));
texture2D<T>::size_type s_above = texture2D<T>::size_type(std::ceil(TexCoord.s * (Image2D.width() - 1)));
texture2D<T>::size_type t_below = texture2D<T>::size_type(std::floor(TexCoord.t * (Image2D.height() - 1)));
texture2D<T>::size_type t_above = texture2D<T>::size_type(std::ceil(TexCoord.t * (Image2D.height() - 1)));
glm::vec2::value_type s_step = 1.0f / glm::vec2::value_type(Image2D.width());
glm::vec2::value_type t_step = 1.0f / glm::vec2::value_type(Image2D.height());
glm::vec2::value_type s_below_normalized = glm::vec2::value_type(s_below) / glm::vec2::value_type(Image2D.width() - 1);
glm::vec2::value_type s_above_normalized = glm::vec2::value_type(s_above) / glm::vec2::value_type(Image2D.width() - 1);
glm::vec2::value_type t_below_normalized = glm::vec2::value_type(t_below) / glm::vec2::value_type(Image2D.height() - 1);
glm::vec2::value_type t_above_normalized = glm::vec2::value_type(t_above) / glm::vec2::value_type(Image2D.height() - 1);
T value1 = Image2D[s_below + t_below * Image2D.width()];
T value2 = Image2D[s_above + t_below * Image2D.width()];
T value3 = Image2D[s_above + t_above * Image2D.width()];
T value4 = Image2D[s_below + t_above * Image2D.width()];
T valueA = glm::mix(value1, value2, TexCoord.s - s_below_normalized);
T valueB = glm::mix(value4, value3, TexCoord.s - s_below_normalized);
T valueC = glm::mix(valueA, valueB, TexCoord.t - t_below_normalized);
return valueC;
}
template <typename T>
inline T textureNearest(const texture2D<T>& Image2D, const glm::vec2& TexCoord)
{
texture2D<T>::size_type s = texture2D<T>::size_type(glm::roundGTX(TexCoord.s * (Image2D.width() - 1)));
texture2D<T>::size_type t = texture2D<T>::size_type(std::roundGTX(TexCoord.t * (Image2D.height() - 1)));
return Image2D[s + t * Image2D.width()];
}
*/
namespace wip
{
////////////////
// image
/*
//
template
<
typename coordType
>
template
<
typename genType,
template <typename> class surface
>
typename texture2D<genType, surface>::value_type &
texture2D<genType, surface>::image_impl<coordType>::operator()
(
coordType const & Coord
)
{
}
*/
/*
//
template
<
typename coordType
>
template
<
typename genType,
template <typename> class surface
>
typename texture2D<genType, surface>::value_type const &
texture2D<genType, surface>::image_impl::operator()
(
coordType const & Coord
) const
{
return value_type(0);
}
*/
/*
//
template
<
typename coordType
>
template
<
typename genType,
template <typename> class surface
>
void texture2D<genType, surface>::image_impl::operator()
(
coordType const & Coord
) const
{
}
*/
////
//template
//<
// typename genType,
// template <typename> class surface
//>
//template
//<
// typename coordType
//>
//typename texture2D<genType, surface>::value_type const &
//texture2D<genType, surface>::image_impl::operator()
//(
// coordType const & Coord
//) const
//{
// return value_type(0);
//}
//////////////////
//// texture2D
////
//template
//<
// typename genType,
// template <typename> class surface
//>
//typename texture2D<genType, surface>::level_type texture2D<genType, surface>::levels() const
//{
// return this->Mipmaps.size();
//}
////
//template
//<
// typename genType,
// template <typename> class surface
//>
//typename texture2D<genType, surface>::image & texture2D<genType, surface>::operator[]
//(
// typename texture2D<genType, surface>::level_type Level
//)
//{
// return this->Mipmaps[Level];
//}
////
//template
//<
// typename genType,
// template <typename> class surface
//>
//typename texture2D<genType, surface>::image const & texture2D<genType, surface>::operator[]
//(
// typename texture2D<genType, surface>::level_type Level
//) const
//{
// return this->Mipmaps[Level];
//}
}//namespace wip
}//namespace gli

View file

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture2d_array.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
#define GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
#include "texture2d.hpp"
namespace gli
{
class texture2DArray
{
public:
typedef texture2D::dimensions_type dimensions_type;
typedef texture2D::texcoord_type texcoord_type;
typedef texture2D::size_type size_type;
typedef texture2D::value_type value_type;
typedef texture2D::format_type format_type;
typedef texture2D::data_type data_type;
typedef texture2D::level_type level_type;
typedef std::vector<texture2D>::size_type layer_type;
public:
texture2DArray();
explicit texture2DArray(
layer_type const & Layers,
level_type const & Levels);
~texture2DArray();
texture2D & operator[] (
layer_type const & Layer);
texture2D const & operator[] (
layer_type const & Layer) const;
bool empty() const;
format_type format() const;
layer_type layers() const;
level_type levels() const;
void resize(
layer_type const & Layers,
level_type const & Levels);
private:
std::vector<texture2D> Arrays;
};
}//namespace gli
#include "texture2d_array.inl"
#endif//GLI_CORE_TEXTURE2D_ARRAY_INCLUDED

View file

@ -0,0 +1,78 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline texture2DArray::texture2DArray()
{}
inline texture2DArray::texture2DArray
(
texture2DArray::layer_type const & Layers,
texture2DArray::level_type const & Levels
)
{
this->Arrays.resize(Layers);
for(texture2DArray::size_type i = 0; i < this->Arrays.size(); ++i)
this->Arrays[i].resize(Levels);
}
inline texture2DArray::~texture2DArray()
{}
inline texture2D & texture2DArray::operator[]
(
layer_type const & Layer
)
{
return this->Arrays[Layer];
}
inline texture2D const & texture2DArray::operator[]
(
layer_type const & Layer
) const
{
return this->Arrays[Layer];
}
inline bool texture2DArray::empty() const
{
return this->Arrays.empty();
}
inline texture2DArray::format_type texture2DArray::format() const
{
return this->Arrays.empty() ? FORMAT_NULL : this->Arrays[0].format();
}
inline texture2DArray::layer_type texture2DArray::layers() const
{
return this->Arrays.size();
}
inline texture2DArray::level_type texture2DArray::levels() const
{
if(this->empty())
return 0;
return this->Arrays[0].levels();
}
inline void texture2DArray::resize
(
texture2DArray::layer_type const & Layers,
texture2DArray::level_type const & Levels
)
{
this->Arrays.resize(Layers);
for(texture2DArray::layer_type i = 0; i < this->Arrays.size(); ++i)
this->Arrays[i].resize(Levels);
}
}//namespace gli

65
test/external/gli/core/texture_cube.hpp vendored Normal file
View file

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE_CUBE_INCLUDED
#define GLI_CORE_TEXTURE_CUBE_INCLUDED
#include "texture2d.hpp"
namespace gli
{
enum face
{
POSITIVE_X,
NEGATIVE_X,
POSITIVE_Y,
NEGATIVE_Y,
POSITIVE_Z,
NEGATIVE_Z,
FACE_MAX
};
class textureCube
{
public:
typedef texture2D::dimensions_type dimensions_type;
typedef texture2D::texcoord_type texcoord_type;
typedef texture2D::size_type size_type;
typedef texture2D::value_type value_type;
typedef texture2D::format_type format_type;
typedef texture2D::data_type data_type;
typedef texture2D::level_type level_type;
typedef face face_type;
public:
textureCube();
explicit textureCube(level_type const & Levels);
~textureCube();
texture2D & operator[] (
face_type const & Face);
texture2D const & operator[] (
face_type const & Face) const;
bool empty() const;
format_type format() const;
level_type levels() const;
void resize(level_type const & Levels);
private:
std::vector<texture2D> Faces;
};
}//namespace gli
#include "texture_cube.inl"
#endif//GLI_CORE_TEXTURE_CUBE_INCLUDED

70
test/external/gli/core/texture_cube.inl vendored Normal file
View file

@ -0,0 +1,70 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline textureCube::textureCube()
{}
inline textureCube::textureCube
(
level_type const & Levels
)
{
this->Faces.resize(FACE_MAX);
for(textureCube::size_type i = 0; i < FACE_MAX; ++i)
this->Faces[i].resize(Levels);
}
inline textureCube::~textureCube()
{}
inline texture2D & textureCube::operator[]
(
face_type const & Face
)
{
return this->Faces[Face];
}
inline texture2D const & textureCube::operator[]
(
face_type const & Face
) const
{
return this->Faces[Face];
}
inline bool textureCube::empty() const
{
return this->Faces.size() == 0;
}
inline textureCube::format_type textureCube::format() const
{
return this->Faces.empty() ? FORMAT_NULL : this->Faces[0].format();
}
inline textureCube::level_type textureCube::levels() const
{
if(this->empty())
return 0;
return this->Faces[POSITIVE_X].levels();
}
inline void textureCube::resize
(
level_type const & Levels
)
{
for(textureCube::size_type i = 0; i < FACE_MAX; ++i)
this->Faces[i].resize(Levels);
}
}//namespace gli

View file

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube_array.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
#define GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
#include "texture_cube.hpp"
namespace gli
{
class textureCubeArray
{
public:
typedef textureCube::dimensions_type dimensions_type;
typedef textureCube::texcoord_type texcoord_type;
typedef textureCube::size_type size_type;
typedef textureCube::value_type value_type;
typedef textureCube::format_type format_type;
typedef std::vector<textureCube> data_type;
typedef textureCube::level_type level_type;
typedef data_type::size_type layer_type;
public:
textureCubeArray();
explicit textureCubeArray(
layer_type const & Layers,
level_type const & Levels);
~textureCubeArray();
textureCube & operator[] (
layer_type const & Layer);
textureCube const & operator[] (
layer_type const & Layer) const;
bool empty() const;
format_type format() const;
layer_type layers() const;
level_type levels() const;
void resize(
layer_type const & Layers,
level_type const & Levels);
private:
data_type Arrays;
};
}//namespace gli
#include "texture_cube_array.inl"
#endif//GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED

View file

@ -0,0 +1,72 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-04-06
// Updated : 2011-04-06
// Licence : This source is under MIT License
// File : gli/core/texture_cube_array.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli
{
inline textureCubeArray::textureCubeArray()
{}
inline textureCubeArray::textureCubeArray
(
layer_type const & Layers,
level_type const & Levels
)
{
this->Arrays.resize(Layers);
for(textureCubeArray::size_type i = 0; i < this->Arrays.size(); ++i)
this->Arrays[i].resize(Levels);
}
inline textureCubeArray::~textureCubeArray()
{}
inline textureCube & textureCubeArray::operator[]
(
layer_type const & Layer
)
{
return this->Arrays[Layer];
}
inline textureCube const & textureCubeArray::operator[]
(
layer_type const & Layer
) const
{
return this->Arrays[Layer];
}
inline bool textureCubeArray::empty() const
{
return this->Arrays.empty();
}
inline textureCubeArray::format_type textureCubeArray::format() const
{
return this->Arrays.empty() ? FORMAT_NULL : this->Arrays[0].format();
}
inline textureCubeArray::level_type textureCubeArray::levels() const
{
if(this->empty())
return 0;
return this->Arrays[0].levels();
}
inline void textureCubeArray::resize
(
layer_type const & Layers,
level_type const & Levels
)
{
for(textureCubeArray::size_type i = 0; i < this->Arrays.size(); ++i)
this->Arrays[i].resize(Levels);
}
}//namespace gli

31
test/external/gli/gli.hpp vendored Normal file
View file

@ -0,0 +1,31 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2010-09-29
// Licence : This source is under MIT License
// File : gli/gli.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
/*! \mainpage OpenGL Image
*
*/
#ifndef GLI_GLI_INCLUDED
#define GLI_GLI_INCLUDED
#define GLI_VERSION 31
#define GLI_VERSION_MAJOR 0
#define GLI_VERSION_MINOR 3
#define GLI_VERSION_PATCH 1
#define GLI_VERSION_REVISION 0
#include "./core/texture2d.hpp"
#include "./core/texture2d_array.hpp"
#include "./core/texture_cube.hpp"
#include "./core/texture_cube_array.hpp"
#include "./core/size.hpp"
#include "./core/operation.hpp"
#include "./core/generate_mipmaps.hpp"
#endif//GLI_GLI_INCLUDED

27
test/external/gli/gtx/compression.hpp vendored Normal file
View file

@ -0,0 +1,27 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gtx/compression.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_COMPRESSION_INCLUDED
#define GLI_GTX_COMPRESSION_INCLUDED
namespace gli{
namespace gtx{
namespace compression
{
}//namespace compression
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::compression;}
#include "compression.inl"
#endif//GLI_GTX_COMPRESSION_INCLUDED

8
test/external/gli/gtx/compression.inl vendored Normal file
View file

@ -0,0 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gtx/compression.inl
///////////////////////////////////////////////////////////////////////////////////////////////////

46
test/external/gli/gtx/fetch.hpp vendored Normal file
View file

@ -0,0 +1,46 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/fetch.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_FETCH_INCLUDED
#define GLI_GTX_FETCH_INCLUDED
#include "../gli.hpp"
namespace gli{
namespace gtx{
namespace fetch
{
template <typename genType>
genType texelFetch(
texture2D const & Texture,
texture2D::dimensions_type const & Texcoord,
texture2D::level_type const & Level);
template <typename genType>
genType textureLod(
texture2D const & Texture,
texture2D::texcoord_type const & Texcoord,
texture2D::level_type const & Level);
template <typename genType>
void texelWrite(
texture2D & Texture,
texture2D::dimensions_type const & Texcoord,
texture2D::level_type const & Level,
genType const & Color);
}//namespace fetch
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::fetch;}
#include "fetch.inl"
#endif//GLI_GTX_FETCH_INCLUDED

91
test/external/gli/gtx/fetch.inl vendored Normal file
View file

@ -0,0 +1,91 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-12-19
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/fetch.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace fetch
{
template <typename genType>
inline genType texelFetch
(
texture2D const & Image,
texture2D::dimensions_type const & TexCoord,
texture2D::level_type const & Level
)
{
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
texture2D::value_type const * const Data = Image[Level].data();
return reinterpret_cast<genType const * const>(Data)[TexCoord.x + TexCoord.y * Dimensions.x];
}
template <typename genType>
inline genType textureLod
(
texture2D const & Image,
texture2D::texcoord_type const & TexCoord,
texture2D::level_type const & Level
)
{
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
texture2D::value_type const * const Data = Image[Level].data();
std::size_t s_below = std::size_t(glm::floor(TexCoord.s * float(Dimensions.x - 1)));
std::size_t s_above = std::size_t(glm::ceil( TexCoord.s * float(Dimensions.x - 1)));
std::size_t t_below = std::size_t(glm::floor(TexCoord.t * float(Dimensions.y - 1)));
std::size_t t_above = std::size_t(glm::ceil( TexCoord.t * float(Dimensions.y - 1)));
float s_step = 1.0f / float(Dimensions.x);
float t_step = 1.0f / float(Dimensions.y);
float s_below_normalized = s_below / float(Dimensions.x);
float s_above_normalized = s_above / float(Dimensions.x);
float t_below_normalized = t_below / float(Dimensions.y);
float t_above_normalized = t_above / float(Dimensions.y);
genType Value1 = reinterpret_cast<genType const * const>(Data)[s_below + t_below * Dimensions.x];
genType Value2 = reinterpret_cast<genType const * const>(Data)[s_above + t_below * Dimensions.x];
genType Value3 = reinterpret_cast<genType const * const>(Data)[s_above + t_above * Dimensions.x];
genType Value4 = reinterpret_cast<genType const * const>(Data)[s_below + t_above * Dimensions.x];
float BlendA = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
float BlendB = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
float BlendC = float(TexCoord.t - t_below_normalized) * float(Dimensions.y - 1);
genType ValueA(glm::mix(Value1, Value2, BlendA));
genType ValueB(glm::mix(Value4, Value3, BlendB));
return genType(glm::mix(ValueA, ValueB, BlendC));
}
template <typename genType>
void texelWrite
(
texture2D & Image,
texture2D::dimensions_type const & Texcoord,
texture2D::level_type const & Level,
genType const & Color
)
{
genType * Data = (genType*)Image[Level].data();
std::size_t Index = Texcoord.x + Texcoord.y * Image[Level].dimensions().x;
std::size_t Capacity = Image[Level].capacity();
assert(Index < Capacity);
*(Data + Index) = Color;
}
}//namespace fetch
}//namespace gtx
}//namespace gli

33
test/external/gli/gtx/gl_texture2d.hpp vendored Normal file
View file

@ -0,0 +1,33 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-27
// Updated : 2010-10-01
// Licence : This source is under MIT License
// File : gli/gtx/gl_texture2d.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_GL_TEXTURE2D_INCLUDED
#define GLI_GTX_GL_TEXTURE2D_INCLUDED
#include "../gli.hpp"
#include "../gtx/loader.hpp"
#ifndef GL_VERSION_1_1
#error "ERROR: OpenGL must be included before GLI_GTX_gl_texture2d"
#endif//GL_VERSION_1_1
namespace gli{
namespace gtx{
namespace gl_texture2d
{
GLuint createTexture2D(std::string const & Filename);
}//namespace gl_texture2d
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::gl_texture2d;}
#include "gl_texture2d.inl"
#endif//GLI_GTX_GL_TEXTURE2D_INCLUDED

210
test/external/gli/gtx/gl_texture2d.inl vendored Normal file
View file

@ -0,0 +1,210 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-27
// Updated : 2010-10-01
// Licence : This source is under MIT License
// File : gli/gtx/gl_texture2d.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace gl_texture2d{
namespace detail
{
//GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, GL_COMPRESSED_RGBA, GL_COMPRESSED_SRGB, GL_COMPRESSED_SRGB_ALPHA,
//GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or GL_SRGB8_ALPHA8
struct texture_desc
{
GLint InternalFormat;
GLint InternalFormatCompressed;
GLint InternalFormatSRGB;
GLint InternalFormatCompressedSRGB;
GLenum ExternalFormat;
GLenum ExternalFormatRev;
GLenum Type;
};
//GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA.
//GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT,
//GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
//GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4,
//GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
//GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
//GL_UNSIGNED_INT_2_10_10_10_REV
# ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
# define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
# endif
# ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
# endif
# ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
# endif
# ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
# endif
inline texture_desc gli2ogl_cast(format const & Format)
{
texture_desc Cast[] =
{
{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE},
//// Normalized
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
// Unsigned
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
// Signed
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_BYTE},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_BYTE},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_BYTE},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_BYTE},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_SHORT},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_SHORT},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_SHORT},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_SHORT},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_INT},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_INT},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_INT},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_INT},
// Float
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_HALF_FLOAT},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_HALF_FLOAT},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_HALF_FLOAT},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_FLOAT},
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_FLOAT},
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_FLOAT},
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_FLOAT},
// Packed
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RGB9_E5, GL_RGB9_E5, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_R11F_G11F_B10F, GL_R11F_G11F_B10F, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RGBA4, GL_RGBA4, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
{GL_RGB10_A2, GL_RGB10_A2, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
// Depth
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT},
{GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
{GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
{GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT},
{GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
// Compressed formats
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_NONE, GL_NONE, GL_NONE},
};
return Cast[Format];
}
}//namespace detail
inline GLuint createTexture2D(std::string const & Filename)
{
gli::texture2D Texture = gli::load(Filename);
if(Texture.empty())
return 0;
detail::texture_desc TextureDesc = detail::gli2ogl_cast(Texture.format());
GLint Alignment = 0;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &Alignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GLuint Name = 0;
glGenTextures(1, &Name);
glBindTexture(GL_TEXTURE_2D, Name);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Texture.levels() > 1 ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if(size(Texture, BIT_PER_PIXEL) == size(Texture, BLOCK_SIZE) << 3)
{
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
{
glTexImage2D(
GL_TEXTURE_2D,
GLint(Level),
TextureDesc.InternalFormat,
GLsizei(Texture[Level].dimensions().x),
GLsizei(Texture[Level].dimensions().y),
0,
TextureDesc.ExternalFormatRev,
TextureDesc.Type,
Texture[Level].data());
}
}
else
{
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
{
glCompressedTexImage2D(
GL_TEXTURE_2D,
GLint(Level),
TextureDesc.InternalFormat,
GLsizei(Texture[Level].dimensions().x),
GLsizei(Texture[Level].dimensions().y),
0,
GLsizei(Texture[Level].capacity()),
Texture[Level].data());
}
}
glBindTexture(GL_TEXTURE_2D, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, Alignment);
return Name;
}
}//namespace gl_texture_2d
}//namespace gtx
}//namespace gli

38
test/external/gli/gtx/gradient.hpp vendored Normal file
View file

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gtx/gradient.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_GRADIENT_INCLUDED
#define GLI_GTX_GRADIENT_INCLUDED
#include "../gli.hpp"
namespace gli{
namespace gtx{
namespace gradient
{
texture2D radial(
texture2D::dimensions_type const & Size,
texture2D::texcoord_type const & Center,
float const & Radius,
texture2D::texcoord_type const & Focal);
texture2D linear(
texture2D::dimensions_type const & Size,
texture2D::texcoord_type const & Point0,
texture2D::texcoord_type const & Point1);
}//namespace gradient
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::gradient;}
#include "gradient.inl"
#endif//GLI_GTX_GRADIENT_INCLUDED

74
test/external/gli/gtx/gradient.inl vendored Normal file
View file

@ -0,0 +1,74 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gtx/gradient.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace gradient
{
inline texture2D radial
(
texture2D::dimensions_type const & Size,
texture2D::texcoord_type const & Center,
float const & Radius,
texture2D::texcoord_type const & Focal
)
{
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
{
float Value = glm::radialGradient(
Center * glm::vec2(Size),
Radius,
Focal * glm::vec2(Size),
glm::vec2(x, y));
std::size_t Index = x + y * Result.dimensions().x;
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
}
gli::texture2D Image(1);
Image[0] = Result;
return Image;
}
inline texture2D linear
(
texture2D::dimensions_type const & Size,
texture2D::texcoord_type const & Point0,
texture2D::texcoord_type const & Point1
)
{
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
{
float Value = glm::linearGradient(
Point0 * glm::vec2(Size),
Point1 * glm::vec2(Size),
texture2D::texcoord_type(x, y));
std::size_t Index = x + y * Result.dimensions().x;
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
}
gli::texture2D Image(1);
Image[0] = Result;
return Image;
}
}//namespace gradient
}//namespace gtx
}//namespace gli

37
test/external/gli/gtx/loader.hpp vendored Normal file
View file

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_INCLUDED
#define GLI_GTX_LOADER_INCLUDED
#include "../gli.hpp"
#include "../gtx/loader_dds9.hpp"
#include "../gtx/loader_dds10.hpp"
#include "../gtx/loader_tga.hpp"
namespace gli{
namespace gtx{
namespace loader
{
inline texture2D load(
std::string const & Filename);
inline void save(
texture2D const & Image,
std::string const & Filename);
}//namespace loader
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader;}
#include "loader.inl"
#endif//GLI_GTX_LOADER_INCLUDED

48
test/external/gli/gtx/loader.inl vendored Normal file
View file

@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace loader
{
inline texture2D load
(
std::string const & Filename
)
{
if(Filename.find(".dds") != std::string::npos)
return loadDDS10(Filename);
else if(Filename.find(".tga") != std::string::npos)
return loadTGA(Filename);
else
{
assert(0); // File format not supported
return texture2D();
}
}
inline void save
(
texture2D const & Image,
std::string const & Filename
)
{
char const * File = Filename.c_str();
if(Filename.find(".dds") != std::string::npos)
saveDDS10(Image, Filename);
else if(Filename.find(".tga") != std::string::npos)
saveTGA(Image, Filename);
else
assert(0); // File format not supported
}
}//namespace loader
}//namespace gtx
}//namespace gli

35
test/external/gli/gtx/loader_dds10.hpp vendored Normal file
View file

@ -0,0 +1,35 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-26
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_dds10.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_DDS10_INCLUDED
#define GLI_GTX_LOADER_DDS10_INCLUDED
#include "../gli.hpp"
#include <fstream>
namespace gli{
namespace gtx{
namespace loader_dds10
{
texture2D loadDDS10(
std::string const & Filename);
void saveDDS10(
texture2D const & Image,
std::string const & Filename);
}//namespace loader_dds10
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader_dds10;}
#include "loader_dds10.inl"
#endif//GLI_GTX_LOADER_DDS10_INCLUDED

595
test/external/gli/gtx/loader_dds10.inl vendored Normal file
View file

@ -0,0 +1,595 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-26
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_dds10.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace loader_dds10{
namespace detail
{
// DDS Documentation
/*
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
http://msdn.microsoft.com/en-us/library/bb943992.aspx
*/
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
(glm::uint32)( \
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
enum DXGI_FORMAT
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
};
enum D3D10_RESOURCE_DIMENSION
{
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4
};
enum D3D10_RESOURCE_MISC_FLAG
{
D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x1L,
D3D10_RESOURCE_MISC_SHARED = 0x2L,
D3D10_RESOURCE_MISC_TEXTURECUBE = 0x4L,
D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10L,
D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20L
};
enum dds_format
{
GLI_D3DFMT_R8G8B8 = 20,
GLI_D3DFMT_A8R8G8B8 = 21,
GLI_D3DFMT_X8R8G8B8 = 22,
GLI_D3DFMT_A8 = 28,
GLI_D3DFMT_A2B10G10R10 = 31,
GLI_D3DFMT_A8B8G8R8 = 32,
GLI_D3DFMT_X8B8G8R8 = 33,
GLI_D3DFMT_G16R16 = 34,
GLI_D3DFMT_A2R10G10B10 = 35,
GLI_D3DFMT_A16B16G16R16 = 36,
GLI_D3DFMT_L8 = 50,
GLI_D3DFMT_A8L8 = 51,
GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
GLI_D3DFMT_D32 = 71,
GLI_D3DFMT_D24S8 = 75,
GLI_D3DFMT_D24X8 = 77,
GLI_D3DFMT_D16 = 80,
GLI_D3DFMT_L16 = 81,
GLI_D3DFMT_D32F_LOCKABLE = 82,
GLI_D3DFMT_D24FS8 = 83,
GLI_D3DFMT_R16F = 111,
GLI_D3DFMT_G16R16F = 112,
GLI_D3DFMT_A16B16G16R16F = 113,
GLI_D3DFMT_R32F = 114,
GLI_D3DFMT_G32R32F = 115,
GLI_D3DFMT_A32B32G32R32F = 116
};
struct ddsHeader10
{
DXGI_FORMAT dxgiFormat;
D3D10_RESOURCE_DIMENSION resourceDimension;
glm::uint32 miscFlag; // D3D10_RESOURCE_MISC_GENERATE_MIPS
glm::uint32 arraySize;
glm::uint32 reserved;
};
inline gli::format format_fourcc2gli_cast(glm::uint32 const & FourCC)
{
switch(FourCC)
{
case loader_dds9::detail::GLI_FOURCC_DXT1:
return DXT1;
case loader_dds9::detail::GLI_FOURCC_DXT2:
case loader_dds9::detail::GLI_FOURCC_DXT3:
return DXT3;
case loader_dds9::detail::GLI_FOURCC_DXT4:
case loader_dds9::detail::GLI_FOURCC_DXT5:
return DXT5;
case loader_dds9::detail::GLI_FOURCC_R16F:
return R16F;
case loader_dds9::detail::GLI_FOURCC_G16R16F:
return RG16F;
case loader_dds9::detail::GLI_FOURCC_A16B16G16R16F:
return RGBA16F;
case loader_dds9::detail::GLI_FOURCC_R32F:
return R32F;
case loader_dds9::detail::GLI_FOURCC_G32R32F:
return RG32F;
case loader_dds9::detail::GLI_FOURCC_A32B32G32R32F:
return RGBA32F;
case loader_dds9::detail::GLI_D3DFMT_R8G8B8:
return RGB8U;
case loader_dds9::detail::GLI_D3DFMT_A8R8G8B8:
case loader_dds9::detail::GLI_D3DFMT_X8R8G8B8:
case loader_dds9::detail::GLI_D3DFMT_A8B8G8R8:
case loader_dds9::detail::GLI_D3DFMT_X8B8G8R8:
return RGBA8U;
case loader_dds9::detail::GLI_D3DFMT_R5G6B5:
return R5G6B5;
case loader_dds9::detail::GLI_D3DFMT_A4R4G4B4:
case loader_dds9::detail::GLI_D3DFMT_X4R4G4B4:
return RGBA4;
case loader_dds9::detail::GLI_D3DFMT_G16R16:
return RG16U;
case loader_dds9::detail::GLI_D3DFMT_A16B16G16R16:
return RGBA16U;
case loader_dds9::detail::GLI_D3DFMT_A2R10G10B10:
case loader_dds9::detail::GLI_D3DFMT_A2B10G10R10:
return RGB10A2;
default:
assert(0);
return FORMAT_NULL;
}
}
inline DXGI_FORMAT format_gli2dds_cast(gli::format const & Format)
{
DXGI_FORMAT Cast[] =
{
DXGI_FORMAT_UNKNOWN, //FORMAT_NULL,
// Unsigned integer formats
DXGI_FORMAT_R8_UINT, //R8U,
DXGI_FORMAT_R8G8_UINT, //RG8U,
DXGI_FORMAT_UNKNOWN, //RGB8U,
DXGI_FORMAT_R8G8B8A8_UINT, //RGBA8U,
DXGI_FORMAT_R16_UINT, //R16U,
DXGI_FORMAT_R16G16_UINT, //RG16U,
DXGI_FORMAT_UNKNOWN, //RGB16U,
DXGI_FORMAT_R16G16B16A16_UINT, //RGBA16U,
DXGI_FORMAT_R32_UINT, //R32U,
DXGI_FORMAT_R32G32_UINT, //RG32U,
DXGI_FORMAT_R32G32B32_UINT, //RGB32U,
DXGI_FORMAT_R32G32B32A32_UINT, //RGBA32U,
// Signed integer formats
DXGI_FORMAT_R8_SINT, //R8I,
DXGI_FORMAT_R8G8_SINT, //RG8I,
DXGI_FORMAT_UNKNOWN, //RGB8I,
DXGI_FORMAT_R8G8B8A8_SINT, //RGBA8I,
DXGI_FORMAT_R16_SINT, //R16I,
DXGI_FORMAT_R16G16_SINT, //RG16I,
DXGI_FORMAT_UNKNOWN, //RGB16I,
DXGI_FORMAT_R16G16B16A16_SINT, //RGBA16I,
DXGI_FORMAT_R32_SINT, //R32I,
DXGI_FORMAT_R32G32_SINT, //RG32I,
DXGI_FORMAT_R32G32B32_SINT, //RGB32I,
DXGI_FORMAT_R32G32B32A32_SINT, //RGBA32I,
// Floating formats
DXGI_FORMAT_R16_FLOAT, //R16F,
DXGI_FORMAT_R16G16_FLOAT, //RG16F,
DXGI_FORMAT_UNKNOWN, //RGB16F,
DXGI_FORMAT_R16G16B16A16_FLOAT, //RGBA16F,
DXGI_FORMAT_R32_FLOAT, //R32F,
DXGI_FORMAT_R32G32_FLOAT, //RG32F,
DXGI_FORMAT_R32G32B32_FLOAT, //RGB32F,
DXGI_FORMAT_R32G32B32A32_FLOAT, //RGBA32F,
// Packed formats
DXGI_FORMAT_UNKNOWN, //RGBE8,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP, //RGB9E5,
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_B5G6R5_UNORM, //R5G6B5,
DXGI_FORMAT_UNKNOWN, //RGBA4,
DXGI_FORMAT_R10G10B10A2_TYPELESS, //RGB10A2,
// Depth formats
DXGI_FORMAT_D16_UNORM, //D16,
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24X8,
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24S8,
DXGI_FORMAT_D32_FLOAT, //D32F,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT, //D32FS8X24,
// Compressed formats
DXGI_FORMAT_BC1_UNORM, //DXT1,
DXGI_FORMAT_BC2_UNORM, //DXT3,
DXGI_FORMAT_BC3_UNORM, //DXT5,
DXGI_FORMAT_BC4_UNORM, //ATI1N_UNORM,
DXGI_FORMAT_BC4_SNORM, //ATI1N_SNORM,
DXGI_FORMAT_BC5_UNORM, //ATI2N_UNORM,
DXGI_FORMAT_BC5_SNORM, //ATI2N_SNORM,
DXGI_FORMAT_BC6H_UF16, //BP_FLOAT,
DXGI_FORMAT_BC6H_SF16, //BP_FLOAT,
DXGI_FORMAT_BC7_UNORM //BP,
};
return Cast[Format];
}
inline gli::format format_dds2gli_cast(DXGI_FORMAT const & Format)
{
gli::format Cast[] =
{
gli::FORMAT_NULL, //DXGI_FORMAT_UNKNOWN = 0,
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
gli::RGBA32F, //DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_UINT = 3,
gli::RGBA32I, //DXGI_FORMAT_R32G32B32A32_SINT = 4,
gli::RGB32U, //DXGI_FORMAT_R32G32B32_TYPELESS = 5,
gli::RGB32F, //DXGI_FORMAT_R32G32B32_FLOAT = 6,
gli::RGB32U, //DXGI_FORMAT_R32G32B32_UINT = 7,
gli::RGB32I, //DXGI_FORMAT_R32G32B32_SINT = 8,
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
gli::RGBA16F, //DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_UNORM = 11,
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_UINT = 12,
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SNORM = 13,
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SINT = 14,
gli::RG32U, //DXGI_FORMAT_R32G32_TYPELESS = 15,
gli::RG32F, //DXGI_FORMAT_R32G32_FLOAT = 16,
gli::RG32U, //DXGI_FORMAT_R32G32_UINT = 17,
gli::RG32I, //DXGI_FORMAT_R32G32_SINT = 18,
gli::FORMAT_NULL, //DXGI_FORMAT_R32G8X24_TYPELESS = 19,
gli::D32FS8X24, //DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
gli::FORMAT_NULL, //DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
gli::FORMAT_NULL, //DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UNORM = 24,
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UINT = 25,
gli::RG11B10F, //DXGI_FORMAT_R11G11B10_FLOAT = 26,
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM = 28,
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UINT = 30,
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SNORM = 31,
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SINT = 32,
gli::RG16U, //DXGI_FORMAT_R16G16_TYPELESS = 33,
gli::RG16F, //DXGI_FORMAT_R16G16_FLOAT = 34,
gli::RG16U, //DXGI_FORMAT_R16G16_UNORM = 35,
gli::RG16U, //DXGI_FORMAT_R16G16_UINT = 36,
gli::RG16I, //DXGI_FORMAT_R16G16_SNORM = 37,
gli::RG16I, //DXGI_FORMAT_R16G16_SINT = 38,
gli::R32F, //DXGI_FORMAT_R32_TYPELESS = 39,
gli::D32F, //DXGI_FORMAT_D32_FLOAT = 40,
gli::R32F, //DXGI_FORMAT_R32_FLOAT = 41,
gli::R32U, //DXGI_FORMAT_R32_UINT = 42,
gli::R32I, //DXGI_FORMAT_R32_SINT = 43,
gli::FORMAT_NULL, //DXGI_FORMAT_R24G8_TYPELESS = 44,
gli::FORMAT_NULL, //DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
gli::FORMAT_NULL, //DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
gli::FORMAT_NULL, //DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
gli::RG8U, //DXGI_FORMAT_R8G8_TYPELESS = 48,
gli::RG8U, //DXGI_FORMAT_R8G8_UNORM = 49,
gli::RG8U, //DXGI_FORMAT_R8G8_UINT = 50,
gli::RG8I, //DXGI_FORMAT_R8G8_SNORM = 51,
gli::RG8I, //DXGI_FORMAT_R8G8_SINT = 52,
gli::R16U, //DXGI_FORMAT_R16_TYPELESS = 53,
gli::R16F, //DXGI_FORMAT_R16_FLOAT = 54,
gli::D16, //DXGI_FORMAT_D16_UNORM = 55,
gli::R16U, //DXGI_FORMAT_R16_UNORM = 56,
gli::R16U, //DXGI_FORMAT_R16_UINT = 57,
gli::R16I, //DXGI_FORMAT_R16_SNORM = 58,
gli::R16I, //DXGI_FORMAT_R16_SINT = 59,
gli::R8U, //DXGI_FORMAT_R8_TYPELESS = 60,
gli::R8U, //DXGI_FORMAT_R8_UNORM = 61,
gli::R8U, //DXGI_FORMAT_R8_UINT = 62,
gli::R8I, //DXGI_FORMAT_R8_SNORM = 63,
gli::R8I, //DXGI_FORMAT_R8_SINT = 64,
gli::R8U, //DXGI_FORMAT_A8_UNORM = 65,
gli::FORMAT_NULL, //DXGI_FORMAT_R1_UNORM = 66,
gli::RGB9E5, //DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
gli::FORMAT_NULL, //DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
gli::FORMAT_NULL, //DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
gli::DXT1, //DXGI_FORMAT_BC1_TYPELESS = 70,
gli::DXT1, //DXGI_FORMAT_BC1_UNORM = 71,
gli::DXT1, //DXGI_FORMAT_BC1_UNORM_SRGB = 72,
gli::DXT3, //DXGI_FORMAT_BC2_TYPELESS = 73,
gli::DXT3, //DXGI_FORMAT_BC2_UNORM = 74,
gli::DXT3, //DXGI_FORMAT_BC2_UNORM_SRGB = 75,
gli::DXT5, //DXGI_FORMAT_BC3_TYPELESS = 76,
gli::DXT5, //DXGI_FORMAT_BC3_UNORM = 77,
gli::DXT5, //DXGI_FORMAT_BC3_UNORM_SRGB = 78,
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_TYPELESS = 79,
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_UNORM = 80,
gli::ATI1N_SNORM, //DXGI_FORMAT_BC4_SNORM = 81,
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_TYPELESS = 82,
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_UNORM = 83,
gli::ATI2N_SNORM, //DXGI_FORMAT_BC5_SNORM = 84,
gli::FORMAT_NULL, //DXGI_FORMAT_B5G6R5_UNORM = 85,
gli::FORMAT_NULL, //DXGI_FORMAT_B5G5R5A1_UNORM = 86,
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM = 87,
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM = 88,
gli::FORMAT_NULL, //DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
gli::BP_UF16, //DXGI_FORMAT_BC6H_TYPELESS = 94,
gli::BP_UF16, //DXGI_FORMAT_BC6H_UF16 = 95,
gli::BP_SF16, //DXGI_FORMAT_BC6H_SF16 = 96,
gli::BP, //DXGI_FORMAT_BC7_TYPELESS = 97,
gli::BP, //DXGI_FORMAT_BC7_UNORM = 98,
gli::BP, //DXGI_FORMAT_BC7_UNORM_SRGB = 99,
gli::R32U //DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
};
return Cast[Format];
}
}//namespace detail
inline texture2D loadDDS10
(
std::string const & Filename
)
{
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
if(FileIn.fail())
return texture2D();
loader_dds9::detail::ddsHeader HeaderDesc;
detail::ddsHeader10 HeaderDesc10;
char Magic[4];
//* Read magic number and check if valid .dds file
FileIn.read((char*)&Magic, sizeof(Magic));
assert(strncmp(Magic, "DDS ", 4) == 0);
// Get the surface descriptor
FileIn.read((char*)&HeaderDesc, sizeof(HeaderDesc));
if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC && HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
FileIn.read((char*)&HeaderDesc10, sizeof(HeaderDesc10));
loader_dds9::detail::DDLoader Loader;
if(HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
Loader.Format = detail::format_dds2gli_cast(HeaderDesc10.dxgiFormat);
else if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC)
Loader.Format = detail::format_fourcc2gli_cast(HeaderDesc.format.fourCC);
else
{
switch(HeaderDesc.format.bpp)
{
case 8:
Loader.Format = R8U;
break;
case 16:
Loader.Format = RG8U;
break;
case 24:
Loader.Format = RGB8U;
break;
case 32:
Loader.Format = RGBA8U;
break;
}
}
Loader.BlockSize = size(image2D(texture2D::dimensions_type(0), Loader.Format), BLOCK_SIZE);
Loader.BPP = size(image2D(image2D::dimensions_type(0), Loader.Format), BIT_PER_PIXEL);
std::size_t Width = HeaderDesc.width;
std::size_t Height = HeaderDesc.height;
gli::format Format = Loader.Format;
std::streamoff Curr = FileIn.tellg();
FileIn.seekg(0, std::ios_base::end);
std::streamoff End = FileIn.tellg();
FileIn.seekg(Curr, std::ios_base::beg);
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
std::size_t Offset = 0;
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
//texture2D Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
std::size_t MipMapCount = (HeaderDesc.flags & loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT) ? HeaderDesc.mipMapLevels : 1;
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
// MipMapCount -= 2;
texture2D Image(MipMapCount);
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
{
Width = glm::max(std::size_t(Width), std::size_t(1));
Height = glm::max(std::size_t(Height), std::size_t(1));
std::size_t MipmapSize = 0;
if((Loader.BlockSize << 3) > Loader.BPP)
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
else
MipmapSize = Width * Height * Loader.BlockSize;
std::vector<glm::byte> MipmapData(MipmapSize, 0);
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
image2D::dimensions_type Dimensions(Width, Height);
Image[Level] = image2D(Dimensions, Format, MipmapData);
Offset += MipmapSize;
Width >>= 1;
Height >>= 1;
}
return Image;
}
inline void saveDDS10
(
gli::texture2D const & Image,
std::string const & Filename
)
{
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
if (!FileOut)
return;
char const * Magic = "DDS ";
FileOut.write((char*)Magic, sizeof(char) * 4);
glm::uint32 Caps = loader_dds9::detail::GLI_DDSD_CAPS | loader_dds9::detail::GLI_DDSD_HEIGHT | loader_dds9::detail::GLI_DDSD_WIDTH | loader_dds9::detail::GLI_DDSD_PIXELFORMAT;
loader_dds9::detail::ddsHeader HeaderDesc;
HeaderDesc.size = sizeof(loader_dds9::detail::ddsHeader);
HeaderDesc.flags = Caps | (loader_dds9::detail::isCompressed(Image) ? loader_dds9::detail::GLI_DDSD_LINEARSIZE : loader_dds9::detail::GLI_DDSD_PITCH) | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
HeaderDesc.width = Image[0].dimensions().x;
HeaderDesc.height = Image[0].dimensions().y;
HeaderDesc.pitch = loader_dds9::detail::isCompressed(Image) ? size(Image, LINEAR_SIZE) : 32;
HeaderDesc.depth = 0;
HeaderDesc.mipMapLevels = glm::uint32(Image.levels());
HeaderDesc.format.size = sizeof(loader_dds9::detail::ddsPixelFormat);
HeaderDesc.format.flags = loader_dds9::detail::GLI_DDPF_FOURCC;
HeaderDesc.format.fourCC = loader_dds9::detail::GLI_FOURCC_DX10;
HeaderDesc.format.bpp = size(Image, BIT_PER_PIXEL);
HeaderDesc.format.redMask = 0;
HeaderDesc.format.greenMask = 0;
HeaderDesc.format.blueMask = 0;
HeaderDesc.format.alphaMask = 0;
HeaderDesc.surfaceFlags = loader_dds9::detail::GLI_DDSCAPS_TEXTURE | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSCAPS_MIPMAP : 0);
HeaderDesc.cubemapFlags = 0;
FileOut.write((char*)&HeaderDesc, sizeof(HeaderDesc));
detail::ddsHeader10 HeaderDesc10;
HeaderDesc10.arraySize = 1;
HeaderDesc10.resourceDimension = detail::D3D10_RESOURCE_DIMENSION_TEXTURE2D;
HeaderDesc10.miscFlag = 0;//Image.levels() > 0 ? detail::D3D10_RESOURCE_MISC_GENERATE_MIPS : 0;
HeaderDesc10.dxgiFormat = detail::format_gli2dds_cast(Image.format());
HeaderDesc10.reserved = 0;
FileOut.write((char*)&HeaderDesc10, sizeof(HeaderDesc10));
for(gli::texture2D::level_type Level = 0; Level < Image.levels(); ++Level)
{
gli::texture2D::size_type ImageSize = size(Image[Level], gli::LINEAR_SIZE);
FileOut.write((char*)(Image[Level].data()), ImageSize);
}
if(FileOut.fail() || FileOut.bad())
return;
FileOut.close ();
}
}//namespace loader_dds10
}//namespace gtx
}//namespace gli

39
test/external/gli/gtx/loader_dds9.hpp vendored Normal file
View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_dds9.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_DDS9_INCLUDED
#define GLI_GTX_LOADER_DDS9_INCLUDED
#include "../gli.hpp"
#include <fstream>
namespace gli{
namespace gtx{
namespace loader_dds9
{
texture2D loadDDS9(
std::string const & Filename);
void saveDDS9(
texture2D const & Texture,
std::string const & Filename);
void saveTextureCubeDDS9(
textureCube const & Texture,
std::string const & Filename);
}//namespace loader_dds9
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader_dds9;}
#include "loader_dds9.inl"
#endif//GLI_GTX_LOADER_DDS9_INCLUDED

790
test/external/gli/gtx/loader_dds9.inl vendored Normal file
View file

@ -0,0 +1,790 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_dds9.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace loader_dds9{
namespace detail
{
// DDS Documentation
/*
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
http://msdn.microsoft.com/en-us/library/bb943992.aspx
*/
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
(glm::uint32)( \
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
//enum dds_format
//{
// GLI_D3DFMT_R8G8B8 = 20,
// GLI_D3DFMT_A8R8G8B8 = 21,
// GLI_D3DFMT_X8R8G8B8 = 22,
// GLI_D3DFMT_A8 = 28,
// GLI_D3DFMT_A2B10G10R10 = 31,
// GLI_D3DFMT_A8B8G8R8 = 32,
// GLI_D3DFMT_X8B8G8R8 = 33,
// GLI_D3DFMT_G16R16 = 34,
// GLI_D3DFMT_A2R10G10B10 = 35,
// GLI_D3DFMT_A16B16G16R16 = 36,
// GLI_D3DFMT_L8 = 50,
// GLI_D3DFMT_A8L8 = 51,
// GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
// GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
// GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
// GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
// GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
// GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
// GLI_D3DFMT_D32 = 71,
// GLI_D3DFMT_D24S8 = 75,
// GLI_D3DFMT_D24X8 = 77,
// GLI_D3DFMT_D16 = 80,
// GLI_D3DFMT_L16 = 81,
// GLI_D3DFMT_D32F_LOCKABLE = 82,
// GLI_D3DFMT_D24FS8 = 83,
// GLI_D3DFMT_R16F = 111,
// GLI_D3DFMT_G16R16F = 112,
// GLI_D3DFMT_A16B16G16R16F = 113,
// GLI_D3DFMT_R32F = 114,
// GLI_D3DFMT_G32R32F = 115,
// GLI_D3DFMT_A32B32G32R32F = 116
//};
enum ddsCubemapflag
{
GLI_DDSCAPS2_CUBEMAP = 0x00000200,
GLI_DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400,
GLI_DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800,
GLI_DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000,
GLI_DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000,
GLI_DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000,
GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000,
GLI_DDSCAPS2_VOLUME = 0x00200000
};
enum ddsSurfaceflag
{
GLI_DDSCAPS_COMPLEX = 0x00000008,
GLI_DDSCAPS_MIPMAP = 0x00400000,
GLI_DDSCAPS_TEXTURE = 0x00001000
};
struct ddsPixelFormat
{
glm::uint32 size; // 32
glm::uint32 flags;
glm::uint32 fourCC;
glm::uint32 bpp;
glm::uint32 redMask;
glm::uint32 greenMask;
glm::uint32 blueMask;
glm::uint32 alphaMask;
};
struct ddsHeader
{
glm::uint32 size;
glm::uint32 flags;
glm::uint32 height;
glm::uint32 width;
glm::uint32 pitch;
glm::uint32 depth;
glm::uint32 mipMapLevels;
glm::uint32 reserved1[11];
ddsPixelFormat format;
glm::uint32 surfaceFlags;
glm::uint32 cubemapFlags;
glm::uint32 reserved2[3];
};
glm::uint32 const GLI_D3DFMT_R8G8B8 = 20;
glm::uint32 const GLI_D3DFMT_A8R8G8B8 = 21;
glm::uint32 const GLI_D3DFMT_X8R8G8B8 = 22;
glm::uint32 const GLI_D3DFMT_R5G6B5 = 23;
glm::uint32 const GLI_D3DFMT_X1R5G5B5 = 24;
glm::uint32 const GLI_D3DFMT_A1R5G5B5 = 25;
glm::uint32 const GLI_D3DFMT_A4R4G4B4 = 26;
glm::uint32 const GLI_D3DFMT_X4R4G4B4 = 30;
glm::uint32 const GLI_D3DFMT_A2B10G10R10 = 31;
glm::uint32 const GLI_D3DFMT_A8B8G8R8 = 32;
glm::uint32 const GLI_D3DFMT_X8B8G8R8 = 33;
glm::uint32 const GLI_D3DFMT_G16R16 = 34;
glm::uint32 const GLI_D3DFMT_A2R10G10B10 = 35;
glm::uint32 const GLI_D3DFMT_A16B16G16R16 = 36;
glm::uint32 const GLI_FOURCC_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1');
glm::uint32 const GLI_FOURCC_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2');
glm::uint32 const GLI_FOURCC_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3');
glm::uint32 const GLI_FOURCC_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4');
glm::uint32 const GLI_FOURCC_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5');
glm::uint32 const GLI_FOURCC_ATI1 = GLI_MAKEFOURCC('A', 'T', 'I', '1'); // ATI1
glm::uint32 const GLI_FOURCC_ATI2 = GLI_MAKEFOURCC('A', 'T', 'I', '2'); // ATI2 (AKA 3Dc)
glm::uint32 const GLI_FOURCC_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0');
glm::uint32 const GLI_FOURCC_BC4U = GLI_MAKEFOURCC('B', 'C', '4', 'U');
glm::uint32 const GLI_FOURCC_BC4S = GLI_MAKEFOURCC('B', 'C', '4', 'S');
glm::uint32 const GLI_FOURCC_BC5U = GLI_MAKEFOURCC('B', 'C', '5', 'U');
glm::uint32 const GLI_FOURCC_BC5S = GLI_MAKEFOURCC('B', 'C', '5', 'S');
glm::uint32 const GLI_FOURCC_BC6H = GLI_MAKEFOURCC('B', 'C', '6', 'H');
glm::uint32 const GLI_FOURCC_BC7 = GLI_MAKEFOURCC('B', 'C', '7', 'U');
glm::uint32 const GLI_FOURCC_R16F = 0x0000006f; // 16-bit float Red
glm::uint32 const GLI_FOURCC_G16R16F = 0x00000070; // 16-bit float Red/Green
glm::uint32 const GLI_FOURCC_A16B16G16R16F = 0x00000071; // 16-bit float RGBA
glm::uint32 const GLI_FOURCC_R32F = 0x00000072; // 32-bit float Red
glm::uint32 const GLI_FOURCC_G32R32F = 0x00000073; // 32-bit float Red/Green
glm::uint32 const GLI_FOURCC_A32B32G32R32F = 0x00000074; // 32-bit float RGBA
glm::uint32 const GLI_DDPF_ALPHAPIXELS = 0x00000001; // The surface has alpha channel information in the pixel format.
glm::uint32 const GLI_DDPF_ALPHA = 0x00000002; // The pixel format contains alpha only information
glm::uint32 const GLI_DDPF_FOURCC = 0x00000004; // The FourCC code is valid.
glm::uint32 const GLI_DDPF_RGB = 0x00000040; // The RGB data in the pixel format structure is valid.
//glm::uint32 const GLI_DDPF_COMPRESSED = 0x00000080; // The surface will accept pixel data in the format specified and compress it during the write.
//glm::uint32 const GLI_DDPF_RGBTOYUV = 0x00000100; // The surface will accept RGB data and translate it during the write to YUV data.
glm::uint32 const GLI_DDPF_YUV = 0x00000200; // Pixel format is YUV - YUV data in pixel format struct is valid.
//glm::uint32 const GLI_DDPF_ZBUFFER = 0x00000400; // Pixel format is a z buffer only surface
//glm::uint32 const GLI_DDPF_ZPIXELS = 0x00002000; // The surface contains Z information in the pixels
//glm::uint32 const GLI_DDPF_STENCILBUFFER = 0x00004000; // The surface contains stencil information along with Z
//glm::uint32 const GLI_DDPF_ALPHAPREMULT = 0x00008000; // Premultiplied alpha format -- the color components have been premultiplied by the alpha component.
glm::uint32 const GLI_DDPF_LUMINANCE = 0x00020000; // Luminance data in the pixel format is valid.
//glm::uint32 const GLI_DDPF_BUMPLUMINANCE = 0x00040000; // Use this flag for luminance-only or luminance+alpha surfaces, the bit depth is then ddpf.dwLuminanceBitCount.
//glm::uint32 const GLI_DDPF_BUMPDUDV = 0x00080000; // Bump map dUdV data in the pixel format is valid.
glm::uint32 const GLI_DDSD_CAPS = 0x00000001;
glm::uint32 const GLI_DDSD_HEIGHT = 0x00000002;
glm::uint32 const GLI_DDSD_WIDTH = 0x00000004;
glm::uint32 const GLI_DDSD_PITCH = 0x00000008;
glm::uint32 const GLI_DDSD_PIXELFORMAT = 0x00001000;
glm::uint32 const GLI_DDSD_MIPMAPCOUNT = 0x00020000;
glm::uint32 const GLI_DDSD_LINEARSIZE = 0x00080000;
glm::uint32 const GLI_DDSD_DEPTH = 0x00800000;
struct DDLoader
{
glm::uint32 BlockSize;
glm::uint32 BPP;
gli::format Format;
};
enum format_type
{
FORMAT_TYPE_NULL,
FORMAT_RGBA,
FORMAT_FOURCC
};
inline glm::uint32 getFormatFourCC(gli::texture2D const & Image)
{
switch(Image.format())
{
default:
return 0;
case DXT1:
return GLI_FOURCC_DXT1;
case DXT3:
return GLI_FOURCC_DXT3;
case DXT5:
return GLI_FOURCC_DXT5;
case ATI1N_UNORM:
case ATI1N_SNORM:
case ATI2N_UNORM:
case ATI2N_SNORM:
case BP_UF16:
case BP_SF16:
case BP:
return GLI_FOURCC_DX10;
case R16F:
return GLI_FOURCC_R16F;
case RG16F:
return GLI_FOURCC_G16R16F;
case RGBA16F:
return GLI_FOURCC_A16B16G16R16F;
case R32F:
return GLI_FOURCC_R32F;
case RG32F:
return GLI_FOURCC_G32R32F;
case RGBA32F:
return GLI_FOURCC_A32B32G32R32F;
}
}
inline glm::uint32 getFormatBlockSize(gli::texture2D const & Image)
{
switch(Image.format())
{
default:
return 0;
case DXT1:
return 8;
case DXT3:
return 16;
case DXT5:
return 16;
case ATI1N_UNORM:
case ATI1N_SNORM:
return 16;
case ATI2N_UNORM:
case ATI2N_SNORM:
return 32;
case BP_UF16:
case BP_SF16:
return 32;
case BP:
return 32;
case R16F:
return 2;
case RG16F:
return 4;
case RGBA16F:
return 8;
case R32F:
return 4;
case RG32F:
return 8;
case RGBA32F:
return 16;
}
}
inline glm::uint32 getFormatFlags(gli::texture2D const & Image)
{
glm::uint32 Result = 0;
switch(Image.format())
{
default:
break;
case R8U:
case RG8U:
case RGB8U:
case RGBA8U:
case R16U:
case RG16U:
case RGB16U:
case RGBA16U:
case R32U:
case RG32U:
case RGB32U:
case RGBA32U:
case R8I:
case RG8I:
case RGB8I:
case RGBA8I:
case R16I:
case RG16I:
case RGB16I:
case RGBA16I:
case R32I:
case RG32I:
case RGB32I:
case RGBA32I:
Result |= GLI_DDPF_RGB;
break;
case R16F:
case RG16F:
case RGB16F:
case RGBA16F:
case R32F:
case RG32F:
case RGB32F:
case RGBA32F:
case RGBE8:
case RGB9E5:
case RG11B10F:
case R5G6B5:
case RGBA4:
case RGB10A2:
case D16:
case D24X8:
case D24S8:
case D32F:
case D32FS8X24:
case DXT1:
case DXT3:
case DXT5:
case ATI1N_UNORM:
case ATI1N_SNORM:
case ATI2N_UNORM:
case ATI2N_SNORM:
case BP_UF16:
case BP_SF16:
case BP:
Result |= GLI_DDPF_FOURCC;
break;
};
return Result;
}
inline glm::uint32 getFormatBPP(gli::texture2D const & Image)
{
switch(Image.format())
{
default:
return 0;
case R8U:
case R8I:
return 8;
case RG8U:
case RG8I:
return 16;
case RGB8U:
case RGB8I:
return 24;
case RGBA8U:
case RGBA8I:
return 32;
case DXT1:
return 4;
case DXT3:
return 8;
case DXT5:
return 8;
case ATI1N_UNORM:
case ATI1N_SNORM:
return 4;
case ATI2N_UNORM:
case ATI2N_SNORM:
return 8;
case BP_UF16:
case BP_SF16:
return 8;
case BP:
return 8;
}
}
inline bool isCompressed(gli::texture2D const & Image)
{
switch(Image.format())
{
default:
return false;
case DXT1:
case DXT3:
case DXT5:
case ATI1N_UNORM:
case ATI1N_SNORM:
case ATI2N_UNORM:
case ATI2N_SNORM:
case BP_UF16:
case BP_SF16:
case BP:
return true;
}
return false;
}
}//namespace detail
inline texture2D loadDDS9
(
std::string const & Filename
)
{
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
if(FileIn.fail())
return texture2D();
detail::ddsHeader SurfaceDesc;
char Magic[4];
//* Read magic number and check if valid .dds file
FileIn.read((char*)&Magic, sizeof(Magic));
assert(strncmp(Magic, "DDS ", 4) == 0);
// Get the surface descriptor
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
std::size_t Width = SurfaceDesc.width;
std::size_t Height = SurfaceDesc.height;
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
detail::DDLoader Loader;
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
{
switch(SurfaceDesc.format.fourCC)
{
case detail::GLI_FOURCC_DX10:
assert(0);
break;
case detail::GLI_FOURCC_DXT1:
Loader.BlockSize = 8;
Loader.Format = DXT1;
break;
case detail::GLI_FOURCC_DXT3:
Loader.BlockSize = 16;
Loader.Format = DXT3;
break;
case detail::GLI_FOURCC_DXT5:
Loader.BlockSize = 16;
Loader.Format = DXT5;
break;
case detail::GLI_FOURCC_R16F:
Loader.BlockSize = 2;
Loader.Format = R16F;
break;
case detail::GLI_FOURCC_G16R16F:
Loader.BlockSize = 4;
Loader.Format = RG16F;
break;
case detail::GLI_FOURCC_A16B16G16R16F:
Loader.BlockSize = 8;
Loader.Format = RGBA16F;
break;
case detail::GLI_FOURCC_R32F:
Loader.BlockSize = 4;
Loader.Format = R32F;
break;
case detail::GLI_FOURCC_G32R32F:
Loader.BlockSize = 8;
Loader.Format = RG32F;
break;
case detail::GLI_FOURCC_A32B32G32R32F:
Loader.BlockSize = 16;
Loader.Format = RGBA32F;
break;
default:
assert(0);
return texture2D();
}
}
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
{
switch(SurfaceDesc.format.bpp)
{
case 8:
Loader.BlockSize = 2;
Loader.Format = R8U;
break;
case 16:
Loader.BlockSize = 2;
Loader.Format = RG8U;
break;
case 24:
Loader.BlockSize = 3;
Loader.Format = RGB8U;
break;
case 32:
Loader.BlockSize = 4;
Loader.Format = RGBA8U;
break;
}
}
else
{
}
gli::format Format = Loader.Format;
std::streamoff Curr = FileIn.tellg();
FileIn.seekg(0, std::ios_base::end);
std::streamoff End = FileIn.tellg();
FileIn.seekg(Curr, std::ios_base::beg);
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
std::size_t Offset = 0;
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
// MipMapCount -= 2;
texture2D Image(MipMapCount);
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
{
Width = glm::max(std::size_t(Width), std::size_t(1));
Height = glm::max(std::size_t(Height), std::size_t(1));
std::size_t MipmapSize = 0;
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
else
MipmapSize = Width * Height * Loader.BlockSize;
std::vector<glm::byte> MipmapData(MipmapSize, 0);
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
image2D::dimensions_type Dimensions(Width, Height);
Image[Level] = image2D(Dimensions, Format, MipmapData);
Offset += MipmapSize;
Width >>= 1;
Height >>= 1;
}
return Image;
}
inline textureCube loadTextureCubeDDS9
(
std::string const & Filename
)
{
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
if(FileIn.fail())
return textureCube();
detail::ddsHeader SurfaceDesc;
char Magic[4];
//* Read magic number and check if valid .dds file
FileIn.read((char*)&Magic, sizeof(Magic));
assert(strncmp(Magic, "DDS ", 4) == 0);
// Get the surface descriptor
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
std::size_t Width = SurfaceDesc.width;
std::size_t Height = SurfaceDesc.height;
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
detail::DDLoader Loader;
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
{
switch(SurfaceDesc.format.fourCC)
{
case detail::GLI_FOURCC_DX10:
assert(0);
break;
case detail::GLI_FOURCC_DXT1:
Loader.BlockSize = 8;
Loader.Format = DXT1;
break;
case detail::GLI_FOURCC_DXT3:
Loader.BlockSize = 16;
Loader.Format = DXT3;
break;
case detail::GLI_FOURCC_DXT5:
Loader.BlockSize = 16;
Loader.Format = DXT5;
break;
case detail::GLI_FOURCC_R16F:
Loader.BlockSize = 2;
Loader.Format = R16F;
break;
case detail::GLI_FOURCC_G16R16F:
Loader.BlockSize = 4;
Loader.Format = RG16F;
break;
case detail::GLI_FOURCC_A16B16G16R16F:
Loader.BlockSize = 8;
Loader.Format = RGBA16F;
break;
case detail::GLI_FOURCC_R32F:
Loader.BlockSize = 4;
Loader.Format = R32F;
break;
case detail::GLI_FOURCC_G32R32F:
Loader.BlockSize = 8;
Loader.Format = RG32F;
break;
case detail::GLI_FOURCC_A32B32G32R32F:
Loader.BlockSize = 16;
Loader.Format = RGBA32F;
break;
default:
assert(0);
return textureCube();
}
}
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
{
switch(SurfaceDesc.format.bpp)
{
case 8:
Loader.BlockSize = 2;
Loader.Format = R8U;
break;
case 16:
Loader.BlockSize = 2;
Loader.Format = RG8U;
break;
case 24:
Loader.BlockSize = 3;
Loader.Format = RGB8U;
break;
case 32:
Loader.BlockSize = 4;
Loader.Format = RGBA8U;
break;
}
}
else
{
}
gli::format Format = Loader.Format;
std::streamoff Curr = FileIn.tellg();
FileIn.seekg(0, std::ios_base::end);
std::streamoff End = FileIn.tellg();
FileIn.seekg(Curr, std::ios_base::beg);
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
std::size_t Offset = 0;
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
// MipMapCount -= 2;
textureCube Texture(MipMapCount);
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
{
Width = SurfaceDesc.width;
Height = SurfaceDesc.height;
for(textureCube::size_type Level = 0; Level < Texture.levels() && (Width || Height); ++Level)
{
Width = glm::max(std::size_t(Width), std::size_t(1));
Height = glm::max(std::size_t(Height), std::size_t(1));
std::size_t MipmapSize = 0;
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
else
MipmapSize = Width * Height * Loader.BlockSize;
std::vector<glm::byte> MipmapData(MipmapSize, 0);
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
textureCube::dimensions_type Dimensions(Width, Height);
Texture[textureCube::face_type(Face)][Level] = image2D(Dimensions, Format, MipmapData);
Offset += MipmapSize;
Width >>= 1;
Height >>= 1;
}
}
return Texture;
}
inline void saveDDS9
(
texture2D const & Texture,
std::string const & Filename
)
{
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
if (!FileOut)
return;
char const * Magic = "DDS ";
FileOut.write((char*)Magic, sizeof(char) * 4);
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT;
detail::ddsHeader SurfaceDesc;
SurfaceDesc.size = sizeof(detail::ddsHeader);
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
SurfaceDesc.width = Texture[0].dimensions().x;
SurfaceDesc.height = Texture[0].dimensions().y;
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture) ? size(Texture, LINEAR_SIZE) : 32;
SurfaceDesc.depth = 0;
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
SurfaceDesc.format.flags = detail::getFormatFlags(Texture);
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture);
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture);
SurfaceDesc.format.redMask = 0;
SurfaceDesc.format.greenMask = 0;
SurfaceDesc.format.blueMask = 0;
SurfaceDesc.format.alphaMask = 0;
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
SurfaceDesc.cubemapFlags = 0;
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
{
texture2D::size_type ImageSize = size(Texture[Level], gli::LINEAR_SIZE);
FileOut.write((char*)(Texture[Level].data()), ImageSize);
}
if(FileOut.fail() || FileOut.bad())
return;
FileOut.close ();
}
inline void saveTextureCubeDDS9
(
textureCube const & Texture,
std::string const & Filename
)
{
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
if (!FileOut || Texture.empty())
return;
char const * Magic = "DDS ";
FileOut.write((char*)Magic, sizeof(char) * 4);
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT | detail::GLI_DDSCAPS_COMPLEX;
detail::ddsHeader SurfaceDesc;
SurfaceDesc.size = sizeof(detail::ddsHeader);
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture[POSITIVE_X]) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
SurfaceDesc.width = Texture[POSITIVE_X][0].dimensions().x;
SurfaceDesc.height = Texture[POSITIVE_X][0].dimensions().y;
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture[POSITIVE_X]) ? size(Texture[POSITIVE_X], LINEAR_SIZE) : 32;
SurfaceDesc.depth = 0;
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
SurfaceDesc.format.flags = detail::getFormatFlags(Texture[POSITIVE_X]);
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture[POSITIVE_X]);
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture[POSITIVE_X]);
SurfaceDesc.format.redMask = 0;
SurfaceDesc.format.greenMask = 0;
SurfaceDesc.format.blueMask = 0;
SurfaceDesc.format.alphaMask = 0;
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
SurfaceDesc.cubemapFlags =
detail::GLI_DDSCAPS2_CUBEMAP | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEX | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEX | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEY | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEY | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEZ | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ;
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
{
texture2D::size_type ImageSize = size(Texture[textureCube::face_type(Face)][Level], gli::LINEAR_SIZE);
FileOut.write((char*)(Texture[textureCube::face_type(Face)][Level].data()), ImageSize);
}
if(FileOut.fail() || FileOut.bad())
return;
FileOut.close ();
}
}//namespace loader_dds9
}//namespace gtx
}//namespace gli

36
test/external/gli/gtx/loader_tga.hpp vendored Normal file
View file

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_tga.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_LOADER_TGA_INCLUDED
#define GLI_GTX_LOADER_TGA_INCLUDED
#include "../gli.hpp"
#include <string>
#include <fstream>
namespace gli{
namespace gtx{
namespace loader_tga
{
texture2D loadTGA(
std::string const & Filename);
void saveTGA(
texture2D const & Image,
std::string const & Filename);
}//namespace loader_tga
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::loader_tga;}
#include "loader_tga.inl"
#endif//GLI_GTX_LOADER_TGA_INCLUDED

159
test/external/gli/gtx/loader_tga.inl vendored Normal file
View file

@ -0,0 +1,159 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-09-08
// Updated : 2010-09-27
// Licence : This source is under MIT License
// File : gli/gtx/loader_tga.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace gli{
namespace gtx{
namespace loader_tga
{
inline texture2D loadTGA
(
std::string const & Filename
)
{
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
if(!FileIn)
return texture2D();
unsigned char IdentificationFieldSize;
unsigned char ColorMapType;
unsigned char ImageType;
unsigned short ColorMapOrigin;
unsigned short ColorMapLength;
unsigned char ColorMapEntrySize;
unsigned short OriginX;
unsigned short OriginY;
unsigned short Width;
unsigned short Height;
unsigned char TexelSize;
unsigned char Descriptor;
FileIn.read((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
FileIn.read((char*)&ColorMapType, sizeof(ColorMapType));
FileIn.read((char*)&ImageType, sizeof(ImageType));
FileIn.read((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
FileIn.read((char*)&ColorMapLength, sizeof(ColorMapLength));
FileIn.read((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
FileIn.read((char*)&OriginX, sizeof(OriginX));
FileIn.read((char*)&OriginY, sizeof(OriginY));
FileIn.read((char*)&Width, sizeof(Width));
FileIn.read((char*)&Height, sizeof(Height));
FileIn.read((char*)&TexelSize, sizeof(TexelSize));
FileIn.read((char*)&Descriptor, sizeof(Descriptor));
gli::format Format = gli::FORMAT_NULL;
if(TexelSize == 24)
Format = gli::RGB8U;
else if(TexelSize == 32)
Format = gli::RGBA8U;
else
assert(0);
image2D Mipmap(texture2D::dimensions_type(Width, Height), Format);
if (FileIn.fail() || FileIn.bad())
{
assert(0);
return texture2D();
}
switch(ImageType)
{
default:
assert(0);
return texture2D();
case 2:
FileIn.seekg(18 + ColorMapLength, std::ios::beg);
char* IdentificationField = new char[IdentificationFieldSize + 1];
FileIn.read(IdentificationField, IdentificationFieldSize);
IdentificationField[IdentificationFieldSize] = '\0';
delete[] IdentificationField;
std::size_t DataSize = Width * Height * (TexelSize >> 3);
FileIn.read((char*)Mipmap.data(), std::streamsize(DataSize));
if(FileIn.fail() || FileIn.bad())
return texture2D();
break;
}
FileIn.close();
texture2D Image(1);
Image[0] = Mipmap;
// TGA images are saved in BGR or BGRA format.
if(TexelSize == 24)
Image.swizzle<glm::u8vec3>(glm::B, glm::G, glm::R, glm::A);
if(TexelSize == 32)
Image.swizzle<glm::u8vec4>(glm::B, glm::G, glm::R, glm::A);
return Image;
}
inline void saveTGA
(
gli::texture2D const & ImageIn,
std::string const & Filename
)
{
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
if (!FileOut)
return;
gli::texture2D Image = duplicate(ImageIn);
unsigned char IdentificationFieldSize = 1;
unsigned char ColorMapType = 0;
unsigned char ImageType = 2;
unsigned short ColorMapOrigin = 0;
unsigned short ColorMapLength = 0;
unsigned char ColorMapEntrySize = 0;
unsigned short OriginX = 0;
unsigned short OriginY = 0;
unsigned short Width = Image[0].dimensions().x;
unsigned short Height = Image[0].dimensions().y;
unsigned char TexelSize = (unsigned char)(Image[0].value_size());
unsigned char Descriptor = 0;
if(TexelSize == 24)
Image.swizzle<glm::u8vec3>(glm::B, glm::G, glm::R, glm::A);
if(TexelSize == 32)
Image.swizzle<glm::u8vec4>(glm::B, glm::G, glm::R, glm::A);
FileOut.write((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
FileOut.write((char*)&ColorMapType, sizeof(ColorMapType));
FileOut.write((char*)&ImageType, sizeof(ImageType));
FileOut.write((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
FileOut.write((char*)&ColorMapLength, sizeof(ColorMapLength));
FileOut.write((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
FileOut.write((char*)&OriginX, sizeof(OriginX));
FileOut.write((char*)&OriginY, sizeof(OriginY));
FileOut.write((char*)&Width, sizeof(Width));
FileOut.write((char*)&Height, sizeof(Height));
FileOut.write((char*)&TexelSize, sizeof(TexelSize));
FileOut.write((char*)&Descriptor, sizeof(Descriptor));
if (FileOut.fail () || FileOut.bad ())
return;
FileOut.seekp(18 + ColorMapLength, std::ios::beg);
char* IdentificationField = new char[IdentificationFieldSize + 1];
FileOut.write(IdentificationField, std::streamsize(IdentificationFieldSize));
delete[] IdentificationField;
FileOut.write((char*)Image[0].data(), std::streamsize(Image[0].capacity()));
if(FileOut.fail() || FileOut.bad())
return;
FileOut.close ();
}
}//namespace loader_tga
}//namespace gtx
}//namespace gli

27
test/external/gli/gtx/wavelet.hpp vendored Normal file
View file

@ -0,0 +1,27 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gtx/wavelet.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GLI_GTX_WAVELET_INCLUDED
#define GLI_GTX_WAVELET_INCLUDED
namespace gli{
namespace gtx{
namespace wavelet
{
}//namespace wavelet
}//namespace gtx
}//namespace gli
namespace gli{using namespace gtx::wavelet;}
#include "wavelet.inl"
#endif//GLI_GTX_WAVELET_INCLUDED

8
test/external/gli/gtx/wavelet.inl vendored Normal file
View file

@ -0,0 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// 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/gtx/wavelet.inl
///////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -9,6 +9,7 @@
#include <glm/glm.hpp>
#include <glm/gtx/noise.hpp>
#include <gli/gli.hpp>
#include <iostream>
int test_simplex()