glm/0000755000000000000000000000000012642261104010331 5ustar rootrootglm/util/0000755000000000000000000000000012642261104011306 5ustar rootrootglm/util/usertype.dat0000644000000000000000000000571112451741412013667 0ustar rootrootattribute const uniform varying break continue do for while if else in out inout float int void bool true false discard return mat2 mat3 mat4 mat2x2 mat3x3 mat4x4 mat2x3 mat3x2 mat2x4 mat4x2 mat3x4 mat4x3 vec2 vec3 vec4 ivec2 ivec3 ivec4 uvec2 uvec3 uvec4 bvec2 bvec3 bvec4 sampler1D sampler2D sampler3D samplerCube sampler1DShadow sampler2DShadow struct asm class union enum typedef template this packed goto switch default inline noinline volatile public static extern external interface long short double half fixed unsigned input output sampler2DRect sampler3DRect sampler2DRectShadow sizeof cast namespace using layout location smooth flat noperspective centroid invariant lowp mediump highp precision patch sample subroutine hvec2 hvec3 hvec4 fvec2 fvec3 fvec4 dvec2 dvec3 dvec4 on final abstract limited access self uchar schar uint sint int8 int16 int32 int64 sint8 sint16 sint32 sint64 uint8 uint16 uint32 uint64 float16 float32 float64 quat hquat fquat dquat handle handle8 handle16 handle32 handle64 flag flag8 flag16 flag32 flag64 import export hmat2 hmat3 hmat4 fmat2 fmat3 fmat4 dmat2 dmat3 dmat4 hmat2x3 hmat3x2 hmat2x4 hmat4x2 hmat3x4 hmat4x3 fmat2x3 fmat3x2 fmat2x4 fmat4x2 fmat3x4 fmat4x3 dmat2x3 dmat3x2 dmat2x4 dmat4x2 dmat3x4 dmat4x3 null pi epsilon infinite self byte word dword qword new_object new_array delete_object delete_array int8 int16 int32 int64 i8 i16 i32 i64 i8vec2 i8vec3 i8vec4 i16vec2 i16vec3 i16vec4 i32vec2 i32vec3 i32vec4 i64vec2 i64vec3 i64vec4 uint8 uint16 uint32 uint64 u8 u16 u32 u64 u8vec2 u8vec3 u8vec4 u16vec2 u16vec3 u16vec4 u32vec2 u32vec3 u32vec4 u64vec2 u64vec3 u64vec4 float16 float32 float64 f16 f32 f64 f16vec2 f16vec3 f16vec4 f32vec2 f32vec3 f32vec4 f64vec2 f64vec3 f64vec4 f16mat2 f16mat3 f16mat4 f16mat2x3 f16mat2x4 f16mat3x2 f16mat3x4 f16mat4x2 f16mat4x3 f32mat2 f32mat3 f32mat4 f32mat2x3 f32mat2x4 f32mat3x2 f32mat3x4 f32mat4x2 f32mat4x3 f64mat2 f64mat3 f64mat4 f64mat2x3 f64mat2x4 f64mat3x2 f64mat3x4 f64mat4x2 f64mat4x3 f16quat f32quat f64quat bool1 bool2 bool3 bool4 bool1x1 bool2x2 bool3x3 bool4x4 bool2x3 bool2x4 bool3x2 bool3x4 bool4x2 bool4x3 int1 int2 int3 int4 int1x1 int2x2 int3x3 int4x4 int2x3 int2x4 int3x2 int3x4 int4x2 int4x3 half1 half2 half3 half4 half2x2 half3x3 half4x4 half2x3 half2x4 half3x2 half3x4 half4x2 half4x3 float1 float2 float3 float4 float1x1 float2x2 float3x3 float4x4 float2x3 float2x4 float3x2 float3x4 float4x2 float4x3 double1 double2 double3 double4 double1x1 double2x2 double3x3 double4x4 double2x3 double2x4 double3x2 double3x4 double4x2 double4x3 glm/util/glm.natvis0000644000000000000000000000345012470135714013323 0ustar rootroot {x} x {x}, {y} x y {x}, {y}, {z} x y z {x}, {y}, {z}, {w} x y z w ({x}, {y}, {z}), {w} x y z w (({real.x}, {real.y}, {real.z}), {real.w}), (({dual.x}, {dual.y}, {dual.z}), {dual.w}) real dual glm/util/autoexp.vc2010.dat0000644000000000000000000040432012451741412014405 0ustar rootroot; AutoExp.Dat - templates for automatically expanding data ; Copyright(c) Microsoft Corporation. All Rights Reserved. ;--------------------------------------------------------------- ; ; While debugging, Data Tips and items in the Watch and Variable ; windows are automatically expanded to show their most important ; elements. The expansion follows the format given by the rules ; in this file. You can add rules for your types or change the ; predefined rules. ; ; For good examples, read the rules in this file. ; ; To find what the debugger considers the type of a variable to ; be, add it to the Watch window and look at the Type column. ; ; An AutoExpand rule is a line with the name of a type, an equals ; sign, and text with replaceable parts in angle brackets. The ; part in angle brackets names a member of the type and an ; optional Watch format specifier. ; ; AutoExpand rules use the following syntax. The equals sign (=), ; angle brackets (<>), and comma are taken literally. Square ; brackets ([]) indicate optional items. ; ; type=[text]... ; ; type Name of the type (may be followed by <*> for template ; types such as the ATL types listed below). ; ; text Any text.Usually the name of the member to display, ; or a shorthand name for the member. ; ; member Name of a member to display. ; ; format Watch format specifier. One of the following: ; ; Letter Description Sample Display ; ------ -------------------------- ------------ ------------- ; d,i Signed decimal integer 0xF000F065,d -268373915 ; u Unsigned decimal integer 0x0065,u 101 ; o Unsigned octal integer 0xF065,o 0170145 ; x,X Hexadecimal integer 61541,X 0X0000F065 ; l,h long or short prefix for 00406042,hx 0x0c22 ; d, i, u, o, x, X ; f Signed floating-point 3./2.,f 1.500000 ; e Signed scientific-notation 3./2.,e 1.500000e+000 ; g Shorter of e and f 3./2.,g 1.5 ; c Single character 0x0065,c 'e' ; s Zero-terminated string pVar,s "Hello world" ; su Unicode string pVar,su "Hello world" ; ; For details of other format specifiers see Help under: ; "format specifiers/watch variable" ; ; The special format <,t> specifies the name of the most-derived ; type of the object. This is especially useful with pointers or ; references to a base class. ; ; If there is no rule for a class, the base classes are checked for ; a matching rule. ; ; There are some special entries allowed in the AutoExpand section: ; $BUILTIN is used to display more complex types that need to do more ; than just show a member variable or two. ; $ADDIN allows external DLLs to be added to display even more complex ; types via the EE Add-in API. The first argument is the DLL name, the ; second argument is the name of the export from the DLL to use. For ; further information on this API see the sample called EEAddIn. ; ; WARNING: if hexadecimal mode is on in the watch window, all numbers here are ; evaluated in hex, e.g. 42 becomes 0x42 [AutoExpand] ; from windef.h tagPOINT =x= y= tagRECT =top= bottom= left= right= ; from winuser.h tagMSG =msg= wp= lp= ; intrinsics __m64 = __m128=$BUILTIN(M128) __m128i=$BUILTIN(M128I) __m128d=$BUILTIN(M128D) ; from afxwin.h CDC =hDC= attrib= CPaintDC =<,t> hWnd= CPoint =x= y= CRect =top= bottom= left= right= CSize =cx= cy= CWnd =<,t> hWnd= CWinApp =<,t> CWinThread =<,t> h= proc= ; from afxcoll.h CPtrList =cnt= ; from afxstat_.h CProcessLocalObject =<,t> CThreadLocalObject =<,t> ; from afx.h CArchiveException =cause= CFile =hFile= name= CFileException =cause= OS Error=m_lOsError CMemFile =pos= size= CObject =<,t> CRuntimeClass = CStdioFile =FILE*= name= CTimeSpan =time= CTime =time= ; from afxcoll.h CByteArray =count= CStringList =count= ; same for all CXXXArray classes ; same for CXXXList ; same for CMapXXToXX ; various string classes from MFC & ATL _com_error= _bstr_t=m_wstr,su> (m_RefCount,u>) _com_ptr_t<*>= _LARGE_INTEGER= _ULARGE_INTEGER= ATL::CComPtr<*>=

ATL::CComQIPtr<*>=

tagVARIANT=$BUILTIN(VARIANT) VARIANT=$BUILTIN(VARIANT) _GUID=$BUILTIN(GUID) ; see EEAddIn sample for how to use these ;_SYSTEMTIME=$ADDIN(EEAddIn.dll,AddIn_SystemTime) ;_FILETIME=$ADDIN(EEAddIn.dll,AddIn_FileTime) [Visualizer] ; This section contains visualizers for STL and ATL containers ; DO NOT MODIFY ATL::CStringT|CSimpleStringT|ATL::CSimpleStringT{ preview ([$e.m_pszData,s]) stringview ([$e.m_pszData,sb]) } ATL::CStringT|CSimpleStringT|ATL::CSimpleStringT|ATL::CStringT|CSimpleStringT|ATL::CSimpleStringT{ preview ([$e.m_pszData,su]) stringview ([$e.m_pszData,sub]) } ATL::CComBSTR{ preview ([$e.m_str,su]) stringview ([$e.m_str,sub]) } ; Many visualizers use nested #()s. ; Why not use #(foo, bar) instead of #(#(foo), #(bar))? ; The former alphabetically sorts its fields, while the latter does not. ;------------------------------------------------------------------------------ ; std::pair from ;------------------------------------------------------------------------------ std::pair<*>{ ; pair is previewed with "(, )". preview ( #( "(", $e.first, ", ", $e.second, ")" ) ) ; We gloss over the fact that first and second are actually stored in _Pair_base. children ( #( #(first : $e.first), #(second : $e.second) ) ) } ;------------------------------------------------------------------------------ ; std::plus, etc. from ;------------------------------------------------------------------------------ ; STL functors are previewed with their names. ; They have no state, so they have no children. std::plus<*>{ preview ( "plus" ) children ( #array(expr: 0, size: 0) ) } std::minus<*>{ preview ( "minus" ) children ( #array(expr: 0, size: 0) ) } std::multiplies<*>{ preview ( "multiplies" ) children ( #array(expr: 0, size: 0) ) } std::divides<*>{ preview ( "divides" ) children ( #array(expr: 0, size: 0) ) } std::modulus<*>{ preview ( "modulus" ) children ( #array(expr: 0, size: 0) ) } std::negate<*>{ preview ( "negate" ) children ( #array(expr: 0, size: 0) ) } std::equal_to<*>{ preview ( "equal_to" ) children ( #array(expr: 0, size: 0) ) } std::not_equal_to<*>{ preview ( "not_equal_to" ) children ( #array(expr: 0, size: 0) ) } std::greater<*>{ preview ( "greater" ) children ( #array(expr: 0, size: 0) ) } std::less<*>{ preview ( "less" ) children ( #array(expr: 0, size: 0) ) } std::greater_equal<*>{ preview ( "greater_equal" ) children ( #array(expr: 0, size: 0) ) } std::less_equal<*>{ preview ( "less_equal" ) children ( #array(expr: 0, size: 0) ) } std::logical_and<*>{ preview ( "logical_and" ) children ( #array(expr: 0, size: 0) ) } std::logical_or<*>{ preview ( "logical_or" ) children ( #array(expr: 0, size: 0) ) } std::logical_not<*>{ preview ( "logical_not" ) children ( #array(expr: 0, size: 0) ) } ;------------------------------------------------------------------------------ ; std::not1() from ; std::not2() from ;------------------------------------------------------------------------------ ; STL negators are previewed with "not[12]()". ; They have a child with the fake name of [pred], so that the ; stored functor can be inspected. std::unary_negate<*>{ preview ( #( "not1(", $e._Functor, ")" ) ) children ( #([pred] : $e._Functor) ) } std::binary_negate<*>{ preview ( #( "not2(", $e._Functor, ")" ) ) children ( #([pred] : $e._Functor) ) } ;------------------------------------------------------------------------------ ; std::bind1st() from ; std::bind2nd() from ;------------------------------------------------------------------------------ ; STL binders are previewed with "bind1st(, )" or "bind2nd(, )". ; We gloss over the fact that they derive from unary_function. std::binder1st<*>{ preview ( #( "bind1st(", $e.op, ", ", $e.value, ")" ) ) children ( #( #(op : $e.op), #(value : $e.value) ) ) } std::binder2nd<*>{ preview ( #( "bind2nd(", $e.op, ", ", $e.value, ")" ) ) children ( #( #(op : $e.op), #(value : $e.value) ) ) } ;------------------------------------------------------------------------------ ; std::ptr_fun() from ;------------------------------------------------------------------------------ ; STL function pointer adaptors are previewed with "ptr_fun()". ; Function pointers have no children, so the adaptors have no children. std::pointer_to_unary_function<*>|std::pointer_to_binary_function<*>{ preview ( #( "ptr_fun(", $e._Pfun, ")" ) ) children ( #array(expr: 0, size: 0) ) } ;------------------------------------------------------------------------------ ; std::mem_fun() from ; std::mem_fun_ref() from ;------------------------------------------------------------------------------ ; See ptr_fun(). std::mem_fun_t<*>|std::mem_fun1_t<*>|std::const_mem_fun_t<*>|std::const_mem_fun1_t<*>{ preview ( #( "mem_fun(", $e._Pmemfun, ")" ) ) children ( #array(expr: 0, size: 0) ) } std::mem_fun_ref_t<*>|std::mem_fun1_ref_t<*>|std::const_mem_fun_ref_t<*>|std::const_mem_fun1_ref_t<*>{ preview ( #( "mem_fun_ref(", $e._Pmemfun, ")" ) ) children ( #array(expr: 0, size: 0) ) } ;------------------------------------------------------------------------------ ; std::auto_ptr from ;------------------------------------------------------------------------------ std::auto_ptr<*>{ ; An empty auto_ptr is previewed with "empty". ; Otherwise, it is previewed with "auto_ptr ". preview ( #if ($e._Myptr == 0) ( "empty" ) #else ( #( "auto_ptr ", *$e._Myptr ) ) ) ; An empty auto_ptr has no children. ; Otherwise, it has a single child, its stored pointer, with a fake name of [ptr]. children ( #if ($e._Myptr == 0) ( #array(expr: 0, size: 0) ) #else ( #([ptr] : $e._Myptr) ) ) } ;------------------------------------------------------------------------------ ; std::basic_string from ;------------------------------------------------------------------------------ ; basic_string is previewed with its stored string. ; It has [size] and [capacity] children, followed by [0], [1], [2], etc. children ; displaying its stored characters. ; The ($e._Myres) < ($e._BUF_SIZE) test determines whether the Small String Optimization ; is in effect. ; NOTE: The parentheses in ($e._Myres) < ($e._BUF_SIZE) are necessary. std::basic_string{ preview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,s] ) #else ( [$e._Bx._Ptr,s] )) stringview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,sb] ) #else ( [$e._Bx._Ptr,sb] )) children ( #( #([size] : $e._Mysize), #([capacity] : $e._Myres), #if (($e._Myres) < ($e._BUF_SIZE)) ( #array(expr: $e._Bx._Buf[$i], size: $e._Mysize) ) #else ( #array(expr: $e._Bx._Ptr[$i], size: $e._Mysize) ) ) ) } std::basic_string|std::basic_string{ preview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,su] ) #else ( [$e._Bx._Ptr,su] )) stringview ( #if (($e._Myres) < ($e._BUF_SIZE)) ( [$e._Bx._Buf,sub] ) #else ( [$e._Bx._Ptr,sub] )) children ( #( #([size] : $e._Mysize), #([capacity] : $e._Myres), #if (($e._Myres) < ($e._BUF_SIZE)) ( #array(expr: $e._Bx._Buf[$i], size: $e._Mysize) ) #else ( #array(expr: $e._Bx._Ptr[$i], size: $e._Mysize) ) ) ) } std::_String_iterator|std::_String_const_iterator{ preview ( [$e._Ptr,s] ) stringview ( [$e._Ptr,sb] ) children ( #([ptr] : $e._Ptr) ) } std::_String_iterator|std::_String_const_iterator|std::_String_iterator|std::_String_const_iterator{ preview ( [$e._Ptr,su] ) stringview ( [$e._Ptr,sub] ) children ( #([ptr] : $e._Ptr) ) } ;------------------------------------------------------------------------------ ; std::vector from ;------------------------------------------------------------------------------ ; Despite its packed representation, vector is visualized like vector. std::vector{ preview ( #( "[", $e._Mysize, "](", #array( expr: (bool)(($e._Myvec._Myfirst[$i / _VBITS] >> ($i % _VBITS)) & 1), size: $e._Mysize ), ")" ) ) children ( #( #([size] : $e._Mysize), #([capacity] : ($e._Myvec._Myend - $e._Myvec._Myfirst) * _VBITS), #array( expr: (bool)(($e._Myvec._Myfirst[$i / _VBITS] >> ($i % _VBITS)) & 1), size: $e._Mysize ) ) ) } std::_Vb_reference<*>|std::_Vb_iterator<*>|std::_Vb_const_iterator<*>{ preview ( (bool)((*$e._Myptr >> $e._Myoff) & 1) ) children ( #( #([ptr] : $e._Myptr), #([offset] : $e._Myoff) ) ) } ;------------------------------------------------------------------------------ ; std::vector from ;------------------------------------------------------------------------------ ; vector is previewed with "[]()". ; It has [size] and [capacity] children, followed by its elements. ; The other containers follow its example. std::vector<*>{ preview ( #( "[", $e._Mylast - $e._Myfirst, "](", #array( expr: $e._Myfirst[$i], size: $e._Mylast - $e._Myfirst ), ")" ) ) children ( #( #([size] : $e._Mylast - $e._Myfirst), #([capacity] : $e._Myend - $e._Myfirst), #array( expr: $e._Myfirst[$i], size: $e._Mylast - $e._Myfirst ) ) ) } std::_Vector_iterator<*>|std::_Vector_const_iterator<*>{ preview ( *$e._Ptr ) children ( #([ptr] : $e._Ptr) ) } ;------------------------------------------------------------------------------ ; std::deque from ;------------------------------------------------------------------------------ std::deque<*>{ preview ( #( "[", $e._Mysize, "](", #array( expr: $e._Map[(($i + $e._Myoff) / $e._EEN_DS) % $e._Mapsize][($i + $e._Myoff) % $e._EEN_DS], size: $e._Mysize ), ")" ) ) children ( #( #array( expr: $e._Map[(($i + $e._Myoff) / $e._EEN_DS) % $e._Mapsize][($i + $e._Myoff) % $e._EEN_DS], size: $e._Mysize ) ) ) } std::_Deque_iterator<*,*>|std::_Deque_const_iterator<*,*>{ preview ( #if ($e._Myoff >= ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Myoff + ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Mysize) ( "end" ) #else ( ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Map[($e._Myoff / ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_EEN_DS) % ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Mapsize][$e._Myoff % ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_EEN_DS] ) ) children ( #if ($e._Myoff >= ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Myoff + ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Mysize) ( #array(expr: 0, size: 0) ) #else ( #( #([index] : $e._Myoff - ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Myoff), #([ptr] : &((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Map[($e._Myoff / ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_EEN_DS) % ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_Mapsize][$e._Myoff % ((std::deque<$T1,$T2> *)$e._Myproxy->_Mycont)->_EEN_DS] ) ) ) ) } ;------------------------------------------------------------------------------ ; std::list from ;------------------------------------------------------------------------------ std::list<*>{ preview ( #( "[", $e._Mysize, "](", #list( head: $e._Myhead->_Next, size: $e._Mysize, next: _Next ) : $e._Myval, ")" ) ) children ( #list( head: $e._Myhead->_Next, size: $e._Mysize, next: _Next ) : $e._Myval ) } std::_List_iterator<*>|std::_List_const_iterator<*>{ preview ( $e._Ptr->_Myval ) children ( #([ptr] : &$e._Ptr->_Myval) ) } ;------------------------------------------------------------------------------ ; std::queue from ; std::stack from ;------------------------------------------------------------------------------ std::queue<*>|std::stack<*>{ preview ( $e.c ) children ( #(c : $e.c) ) } ;------------------------------------------------------------------------------ ; std::priority_queue from ;------------------------------------------------------------------------------ std::priority_queue<*>{ preview ( $e.c ) children ( #( #(c [heap]: $e.c), #(comp : $e.comp) ) ) } ;------------------------------------------------------------------------------ ; std::map from ; std::multimap from ; std::set from ; std::multiset from ;------------------------------------------------------------------------------ std::map<*>|std::multimap<*>|std::set<*>|std::multiset<*>{ preview ( #( "[", $e._Mysize, "](", #tree( head: $e._Myhead->_Parent, skip: $e._Myhead, left: _Left, right: _Right, size: $e._Mysize ) : $e._Myval, ")" ) ) children ( #( #([comp] : $e.comp), #tree( head: $e._Myhead->_Parent, skip: $e._Myhead, left: _Left, right: _Right, size: $e._Mysize ) : $e._Myval ) ) } std::_Tree_iterator<*>|std::_Tree_const_iterator<*>{ preview ( $e._Ptr->_Myval ) children ( #([ptr] : &$e._Ptr->_Myval) ) } ;------------------------------------------------------------------------------ ; std::bitset from ;------------------------------------------------------------------------------ std::bitset<*>{ preview ( #( "[", $e._EEN_BITS, "](", #array( expr: [($e._Array[$i / $e._Bitsperword] >> ($i % $e._Bitsperword)) & 1,d], size: $e._EEN_BITS ), ")" ) ) children ( #array( expr: [($e._Array[$i / $e._Bitsperword] >> ($i % $e._Bitsperword)) & 1,d], size: $e._EEN_BITS ) ) } std::bitset<*>::reference{ preview ( [($e._Pbitset->_Array[$i / $e._Pbitset->_Bitsperword] >> ($e._Mypos % $e._Pbitset->_Bitsperword)) & 1,d] ) children ( #( #([bitset] : $e._Pbitset), #([pos] : $e._Mypos) ) ) } ;------------------------------------------------------------------------------ ; std::reverse_iterator from ;------------------------------------------------------------------------------ std::reverse_iterator >|std::reverse_iterator >{ preview ( #( "reverse_iterator to ", $e.current._Ptr[-1] ) ) children ( #( #([to] : $e.current._Ptr - 1), #(current : $e.current) ) ) } std::reverse_iterator >|std::reverse_iterator >{ preview ( #( "reverse_iterator to ", #if ($e.current._Myoff != 0) ( (bool)((*$e.current._Myptr >> ($e.current._Myoff - 1)) & 1) ) #else ( (bool)(($e.current._Myptr[-1] >> (_VBITS - 1)) & 1) ) ) ) children ( #if ($e.current._Myoff != 0) ( #( #([to ptr] : $e.current._Myptr), #([to offset] : $e.current._Myoff - 1), #(current : $e.current) ) ) #else ( #( #([to ptr] : $e.current._Myptr - 1), #([to offset] : _VBITS - 1), #(current : $e.current) ) ) ) } std::reverse_iterator >|std::reverse_iterator >{ preview ( #( "reverse_iterator to ", $e.current._Ptr[-1] ) ) children ( #( #([to] : $e.current._Ptr - 1), #(current : $e.current) ) ) } std::reverse_iterator >|std::reverse_iterator >{ preview ( #( "reverse_iterator to ", #if ($e.current._Myoff == ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Myoff) ( "end" ) #else ( ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Map[(($e.current._Myoff - 1) / ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_EEN_DS) % ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Mapsize][($e.current._Myoff - 1) % ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_EEN_DS] ) ) ) children ( #if ($e.current._Myoff == ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Myoff) ( #(current : $e.current) ) #else ( #( #([to index] : ($e.current._Myoff - 1) - ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Myoff), #([to ptr] : &((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Map[(($e.current._Myoff - 1) / ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_EEN_DS) % ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_Mapsize][($e.current._Myoff - 1) % ((std::deque<$T1,$T2> *)$e.current._Myproxy->_Mycont)->_EEN_DS] ), #(current : $e.current) ) ) ) } std::reverse_iterator >|std::reverse_iterator >{ preview ( #( "reverse_iterator to ", $e.current._Ptr->_Prev->_Myval ) ) children ( #( #([to] : &$e.current._Ptr->_Prev->_Myval), #(current : $e.current) ) ) } std::reverse_iterator >|std::reverse_iterator >{ preview ( #( "reverse_iterator to ", #if ($e.current._EEN_IDL == 0) ( $e.current._Ptr[-1] ) #else ( #if ($e.current._Idx == 0) ( "end" ) #else ( $e.current._Ptr[$e.current._Idx - 1] ) ) ) ) children ( #if ($e.current._EEN_IDL == 0) ( #( #([to] : $e.current._Ptr - 1), #(current : $e.current) ) ) #else ( #if ($e.current._Idx == 0) ( #(current : $e.current) ) #else ( #( #([to] : $e.current._Ptr + $e.current._Idx - 1), #(current : $e.current) ) ) ) ) } std::reverse_iterator<*>{ preview ( #( "reverse_iterator current ", $e.current ) ) children ( #(current : $e.current) ) } ;------------------------------------------------------------------------------ ; std::complex from ;------------------------------------------------------------------------------ std::complex<*>{ preview ( #if ($e._Val[1] == 0) ( ; Purely real. $e._Val[0] ) #else ( #if ($e._Val[0] == 0) ( ; Purely imaginary. #if ($e._Val[1] < 0) ( #("-i*", -$e._Val[1]) ) #else ( #("i*", $e._Val[1]) ) ) #else ( ; Mixed. #if ($e._Val[1] < 0) ( #($e._Val[0], "-i*", -$e._Val[1]) ) #else ( #($e._Val[0], "+i*", $e._Val[1]) ) ) ) ) children ( #( #(real : $e._Val[0]), #(imag : $e._Val[1]) ) ) } ;------------------------------------------------------------------------------ ; std::valarray from ;------------------------------------------------------------------------------ std::valarray<*>{ preview ( #( "[", $e._Mysize, "](", #array( expr: $e._Myptr[$i], size: $e._Mysize ), ")" ) ) children ( #array( expr: $e._Myptr[$i], size: $e._Mysize ) ) } ;------------------------------------------------------------------------------ ; std::tr1::reference_wrapper from ;------------------------------------------------------------------------------ std::tr1::reference_wrapper<*>{ preview ( #if ($e._Callee._EEN_INDIRECT == 1) ( ; For ordinary T, reference_wrapper stores a T * _Callee._Ptr ; which is non-null. Actual references are previewed with what they ; refer to, so reference_wrapper is previewed with dereferencing its ; stored pointer. *$e._Callee._Ptr ) #else ( ; When T is a pointer to data member type, reference_wrapper ; stores a T _Callee._Object directly. $e._Callee._Object ) ) children ( #if ($e._Callee._EEN_INDIRECT == 1) ( ; Actual references have the same children as what they refer to. ; Unfortunately, there appears to be no way to imitate this exactly. ; Therefore, we make reference_wrapper appear to have a single ; child, its stored pointer, with a fake name of [ptr]. #([ptr] : $e._Callee._Ptr) ) #else ( ; When T is a pointer to data member type, T has no children, ; so we make reference_wrapper appear to have no children. #array(expr: 0, size: 0) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::shared_ptr from ;------------------------------------------------------------------------------ std::tr1::_Ref_count<*>{ preview ( "default" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ref_count_del<*>{ preview ( "custom deleter" ) children ( #([deleter] : $e._Dtor) ) } std::tr1::_Ref_count_del_alloc<*>{ preview ( "custom deleter, custom allocator" ) children ( #( #([deleter] : $e._Dtor), #([allocator] : $e._Myal) ) ) } std::tr1::_Ref_count_obj<*>{ preview ( "make_shared" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ref_count_obj_alloc<*>{ preview ( "allocate_shared" ) children ( #([allocator] : $e._Myal) ) } std::tr1::shared_ptr<*>{ preview ( ; shared_ptr stores a T * _Ptr . #if ($e._Ptr == 0) ( ; A default-constructed shared_ptr has a null _Ptr and a null _Rep, ; and is formally said to be empty. ; A shared_ptr constructed from a null pointer has a null _Ptr ; and a NON-null _Rep . It is formally said to own the null pointer. ; We preview both with "empty". "empty" ) #else ( ; Raw pointers are previewed with " ". ; auto_ptr is previewed with "auto_ptr ". ; Following these examples, shared_ptr is previewed with ; "shared_ptr [N strong refs, M weak refs]". #( "shared_ptr ", *$e._Ptr, " [", $e._Rep->_Uses, #if ($e._Rep->_Uses == 1) (" strong ref") #else (" strong refs"), #if ($e._Rep->_Weaks - 1 > 0) ( #( ", ", $e._Rep->_Weaks - 1, #if ($e._Rep->_Weaks - 1 == 1) (" weak ref") #else (" weak refs") ) ), "] [", *$e._Rep, "]" ) ; Note: _Rep->_Uses counts how many shared_ptrs share ownership of the object, ; so we directly display it as the strong reference count. ; _Rep->_Weaks counts how many shared_ptrs and weak_ptrs share ownership of ; the "representation object" (or "control block"). All of the shared_ptrs are ; counted as a single owner. That is, _Weaks is initialized to 1, and when ; _Uses falls to 0, _Weaks is decremented. This avoids incrementing and decrementing ; _Weaks every time that a shared_ptr gains or loses ownership. Therefore, ; _Weaks - 1 is the weak reference count, the number of weak_ptrs that are observing ; the shared object. ) ) children ( #if ($e._Ptr == 0) ( ; We make empty shared_ptrs (and shared_ptrs that own ; the null pointer) appear to have no children. #array(expr: 0, size: 0) ) #else ( #( ; We make shared_ptr appear to have two children: ; Its stored pointer, with a fake name of [ptr]. #([ptr] : $e._Ptr), ; Its deleter and allocator, which may be default or custom. #([deleter and allocator] : *$e._Rep) ) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::weak_ptr from ;------------------------------------------------------------------------------ std::tr1::weak_ptr<*>{ preview ( #if ($e._Ptr == 0) ( "empty" ) #elif ($e._Rep->_Uses == 0) ( ; weak_ptr is just like shared_ptr, except that a weak_ptr can be expired. #( "expired [", *$e._Rep, "]" ) ) #else ( #( "weak_ptr ", *$e._Ptr, " [", $e._Rep->_Uses, #if ($e._Rep->_Uses == 1) (" strong ref") #else (" strong refs"), #if ($e._Rep->_Weaks - 1 > 0) ( #( ", ", $e._Rep->_Weaks - 1, #if ($e._Rep->_Weaks - 1 == 1) (" weak ref") #else (" weak refs") ) ), "] [", *$e._Rep, "]" ) ) ) children ( #if ($e._Ptr == 0) ( #array(expr: 0, size: 0) ) #elif ($e._Rep->_Uses == 0) ( ; When a weak_ptr is expired, we show its deleter and allocator. ; The deleter has already been used, but the control block has not yet been deallocated. #([deleter and allocator] : *$e._Rep) ) #else ( #( #([ptr] : $e._Ptr), #([deleter and allocator] : *$e._Rep) ) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::mem_fn() from ;------------------------------------------------------------------------------ ; Note that when mem_fn() is given a data member pointer, it returns a _Call_wrapper<_Callable_pmd<*> > . ; Data member pointers themselves don't have useful previews, so we don't attempt to visualize this. ; When mem_fn() is given a member function pointer, it returns a _Mem_fn[N], which we can visualize. std::tr1::_Mem_fn1<*>|std::tr1::_Mem_fn2<*>|std::tr1::_Mem_fn3<*>|std::tr1::_Mem_fn4<*>|std::tr1::_Mem_fn5<*>|std::tr1::_Mem_fn6<*>|std::tr1::_Mem_fn7<*>|std::tr1::_Mem_fn8<*>|std::tr1::_Mem_fn9<*>|std::tr1::_Mem_fn10<*>{ preview ( ; We preview the functor returned by mem_fn() with "mem_fn()". #( "mem_fn(", $e._Callee._Object, ")" ) ) children ( ; Member function pointers have no children. #array(expr: 0, size: 0) ) } ;------------------------------------------------------------------------------ ; std::tr1::bind() from ;------------------------------------------------------------------------------ ; bind() placeholders are previewed with their names. ; They have no state, so they have no children. std::tr1::_Ph<1>{ preview ( "_1" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<2>{ preview ( "_2" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<3>{ preview ( "_3" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<4>{ preview ( "_4" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<5>{ preview ( "_5" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<6>{ preview ( "_6" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<7>{ preview ( "_7" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<8>{ preview ( "_8" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<9>{ preview ( "_9" ) children ( #array(expr: 0, size: 0) ) } std::tr1::_Ph<10>{ preview ( "_10" ) children ( #array(expr: 0, size: 0) ) } ; The functor returned by bind(f, t1, t2) is previewed with "bind(f, t1, t2)". ; It has children with the fake names of [f], [t1], [t2], etc. std::tr1::_Bind<*,*,std::tr1::_Bind0<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind0<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind1<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind1<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind2<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind2<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind3<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind3<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind4<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind4<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind5<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind5<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ", ", $e._Bx._Vx4, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3), #([t5] : $e._Bx._Vx4) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind6<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind6<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ", ", $e._Bx._Vx4, ", ", $e._Bx._Vx5, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3), #([t5] : $e._Bx._Vx4), #([t6] : $e._Bx._Vx5) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind7<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind7<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ", ", $e._Bx._Vx4, ", ", $e._Bx._Vx5, ", ", $e._Bx._Vx6, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3), #([t5] : $e._Bx._Vx4), #([t6] : $e._Bx._Vx5), #([t7] : $e._Bx._Vx6) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind8<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind8<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ", ", $e._Bx._Vx4, ", ", $e._Bx._Vx5, ", ", $e._Bx._Vx6, ", ", $e._Bx._Vx7, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3), #([t5] : $e._Bx._Vx4), #([t6] : $e._Bx._Vx5), #([t7] : $e._Bx._Vx6), #([t8] : $e._Bx._Vx7) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind9<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind9<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ", ", $e._Bx._Vx4, ", ", $e._Bx._Vx5, ", ", $e._Bx._Vx6, ", ", $e._Bx._Vx7, ", ", $e._Bx._Vx8, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3), #([t5] : $e._Bx._Vx4), #([t6] : $e._Bx._Vx5), #([t7] : $e._Bx._Vx6), #([t8] : $e._Bx._Vx7), #([t9] : $e._Bx._Vx8) ) ) } std::tr1::_Bind<*,*,std::tr1::_Bind10<*> >|std::tr1::_Bind_fty<*,*,std::tr1::_Bind10<*> >{ preview ( #( "bind(", $e._Bx._Callee._Object, ", ", $e._Bx._Vx0, ", ", $e._Bx._Vx1, ", ", $e._Bx._Vx2, ", ", $e._Bx._Vx3, ", ", $e._Bx._Vx4, ", ", $e._Bx._Vx5, ", ", $e._Bx._Vx6, ", ", $e._Bx._Vx7, ", ", $e._Bx._Vx8, ", ", $e._Bx._Vx9, ")" ) ) children ( #( #([f] : $e._Bx._Callee._Object), #([t1] : $e._Bx._Vx0), #([t2] : $e._Bx._Vx1), #([t3] : $e._Bx._Vx2), #([t4] : $e._Bx._Vx3), #([t5] : $e._Bx._Vx4), #([t6] : $e._Bx._Vx5), #([t7] : $e._Bx._Vx6), #([t8] : $e._Bx._Vx7), #([t9] : $e._Bx._Vx8), #([t10] : $e._Bx._Vx9) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::function from ;------------------------------------------------------------------------------ std::tr1::_Impl_no_alloc0<*>|std::tr1::_Impl_no_alloc1<*>|std::tr1::_Impl_no_alloc2<*>|std::tr1::_Impl_no_alloc3<*>|std::tr1::_Impl_no_alloc4<*>|std::tr1::_Impl_no_alloc5<*>|std::tr1::_Impl_no_alloc6<*>|std::tr1::_Impl_no_alloc7<*>|std::tr1::_Impl_no_alloc8<*>|std::tr1::_Impl_no_alloc9<*>|std::tr1::_Impl_no_alloc10<*>{ preview ( $e._Callee._Object ) children ( #([functor] : $e._Callee._Object) ) } std::tr1::_Impl0<*>|std::tr1::_Impl1<*>|std::tr1::_Impl2<*>|std::tr1::_Impl3<*>|std::tr1::_Impl4<*>|std::tr1::_Impl5<*>|std::tr1::_Impl6<*>|std::tr1::_Impl7<*>|std::tr1::_Impl8<*>|std::tr1::_Impl9<*>|std::tr1::_Impl10<*>{ preview ( $e._Callee._Object ) children ( #( #([functor] : $e._Callee._Object), #([allocator] : $e._Myal) ) ) } std::tr1::function<*>{ preview ( #if ($e._Impl == 0) ( ; Detecting empty functions is trivial. "empty" ) #else ( *$e._Impl ) ) children ( #if ($e._Impl == 0) ( ; We make empty functions appear to have no children. #array(expr: 0, size: 0) ) #else ( #([functor and allocator] : *$e._Impl) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::tuple from ;------------------------------------------------------------------------------ ; tuple is visualized like pair, except that we have to give fake names to tuple's children. std::tr1::tuple{ preview ( "()" ) children ( #array(expr: 0, size: 0) ) } std::tr1::tuple<*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ")" ) ) children ( #( [0] : $e._Impl._Value ) ) } std::tr1::tuple<*,*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value ) ) } std::tr1::tuple<*,*,*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value, [4] : $e._Impl._Tail._Tail._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,*,*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value, [4] : $e._Impl._Tail._Tail._Tail._Tail._Value, [5] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,*,*,*,std::tr1::_Nil,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value, [4] : $e._Impl._Tail._Tail._Tail._Tail._Value, [5] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, [6] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,*,*,*,*,std::tr1::_Nil,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value, [4] : $e._Impl._Tail._Tail._Tail._Tail._Value, [5] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, [6] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, [7] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,*,*,*,*,*,std::tr1::_Nil>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value, [4] : $e._Impl._Tail._Tail._Tail._Tail._Value, [5] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, [6] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, [7] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, [8] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value ) ) } std::tr1::tuple<*,*,*,*,*,*,*,*,*,*>{ preview ( #( "(", $e._Impl._Value, ", ", $e._Impl._Tail._Value, ", ", $e._Impl._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, ", ", $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, ")" ) ) children ( #( [0] : $e._Impl._Value, [1] : $e._Impl._Tail._Value, [2] : $e._Impl._Tail._Tail._Value, [3] : $e._Impl._Tail._Tail._Tail._Value, [4] : $e._Impl._Tail._Tail._Tail._Tail._Value, [5] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Value, [6] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Value, [7] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, [8] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value, [9] : $e._Impl._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Tail._Value ) ) } ;------------------------------------------------------------------------------ ; std::tr1::array from ;------------------------------------------------------------------------------ std::tr1::array<*>{ preview ( ; An actual array is previewed with its address. ; array is previewed like vector. #( "[", $e._EEN_SIZE, "](", #array(expr: $e._Elems[$i], size: $e._EEN_SIZE), ")" ) ) children ( ; Just like an actual array. #array(expr: $e._Elems[$i], size: $e._EEN_SIZE) ) } std::_Array_iterator<*>|std::_Array_const_iterator<*>{ preview ( #if ($e._EEN_IDL == 0) ( *$e._Ptr ) #else ( #if ($e._Idx == $e._EEN_SIZE) ( ; array iterators are represented by _Ptr + _Idx, ; and they know how large their parent arrays are. Therefore, detecting ; end iterators is trivial. "end" ) #else ( ; Like vector iterators, array iterators are previewed with what they point to. $e._Ptr[$e._Idx] ) ) ) children ( #if ($e._EEN_IDL == 0) ( #([ptr] : $e._Ptr) ) #else ( #if ($e._Idx == $e._EEN_SIZE) ( ; We make end iterators appear to have no children. #array(expr: 0, size: 0) ) #else ( ; An array iterator is conceptually a pointer, so we make it appear to store one. #([ptr] : $e._Ptr + $e._Idx) ) ) ) } ;------------------------------------------------------------------------------ ; stdext::hash_map from ; stdext::hash_multimap from ; stdext::hash_set from ; stdext::hash_multiset from ;------------------------------------------------------------------------------ stdext::hash_map<*>|stdext::hash_multimap<*>|stdext::hash_set<*>|stdext::hash_multiset<*>{ preview ( #( "[", $e._List._Mysize, "](", #list( head: $e._List._Myhead->_Next, size: $e._List._Mysize, next: _Next ) : $e._Myval, ")" ) ) children ( #list( head: $e._List._Myhead->_Next, size: $e._List._Mysize, next: _Next ) : $e._Myval ) } ;------------------------------------------------------------------------------ ; std::tr1::unordered_map from ; std::tr1::unordered_multimap from ; std::tr1::unordered_set from ; std::tr1::unordered_multiset from ;------------------------------------------------------------------------------ std::hash<*>{ preview ( "hash" ) children ( #array(expr: 0, size: 0) ) } std::tr1::unordered_map<*>|std::tr1::unordered_multimap<*>|std::tr1::unordered_set<*>|std::tr1::unordered_multiset<*>{ preview ( #( "[", $e._List._Mysize, "](", #list( head: $e._List._Myhead->_Next, size: $e._List._Mysize, next: _Next ) : $e._Myval, ")" ) ) children ( #( #([hash] : $e.comp._Hashobj), #([equal] : $e.comp._Keyeqobj), #list( head: $e._List._Myhead->_Next, size: $e._List._Mysize, next: _Next ) : $e._Myval ) ) } ;------------------------------------------------------------------------------ ; std::tr1::basic_regex from ;------------------------------------------------------------------------------ std::tr1::basic_regex<*>{ preview ( #if ($e._Rep == 0) ( ; Default construction creates an empty basic_regex. "empty" ) #elif ($e._EEN_VIS == 1) ( ; By default, _ENHANCED_REGEX_VISUALIZER is defined to be 1 in debug and 0 in ship. ; When it is 1, basic_regex stores the string from which it was constructed. ; When it is 0, basic_regex stores only the resulting finite state machine. $e._Visualization ) #else ( ; basic_regex contains many static const flags, which would be shown in the preview by default. ; Its actual members are _Rep and _Traits. _Rep holds the finite state machine, so we ; use it to preview basic_regex. (It does contain some human-readable information.) *$e._Rep ) ) children ( #if ($e._Rep == 0) ( ; We make empty basic_regexes appear to have no children. #array(expr: 0, size: 0) ) #elif ($e._EEN_VIS == 1) ( ; We want to hide those static const flags. ; We also want to give _Visualization a fake name. #( #([str] : $e._Visualization), #(_Rep : $e._Rep), #(_Traits : $e._Traits) ) ) #else ( ; We want to hide those static const flags. #( _Rep : $e._Rep, _Traits : $e._Traits ) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::sub_match from ;------------------------------------------------------------------------------ std::tr1::sub_match|std::tr1::sub_match|std::tr1::sub_match|std::tr1::sub_match|std::tr1::sub_match|std::tr1::sub_match{ preview ( ; It would be nice if we could preview sub_match with its str(). ; However, visualizers cannot handle strings represented by pointer pairs. ; Therefore, our preview contains more limited information. #if ($e.matched) ( ; If this sub_match participated in a match, ; we preview it with its length(). $e.second - $e.first ) #else ( ; Otherwise, we preview it with its matched bool (i.e. "false"). ; (Why not length() (i.e. "0")? It's meaningful to have ; matched == true and length() == 0. "false" ) ) children ( #( ; sub_match's three data members are public, but we list them here ; (a) to display matched before first and second, and ; (b) to gloss over the fact that sub_match derives from std::pair. #(matched : $e.matched), #(first : $e.first), #(second : $e.second) ) ) } std::tr1::sub_match >|std::tr1::sub_match >{ preview ( #if ($e.matched) ( ; We visualize ssub_match and wssub_match just like csub_match and wcsub_match, ; except that when determining the length(), we can't subtract iterators. ; We have to subtract their stored pointers. $e.second._Ptr - $e.first._Ptr ) #else ( "false" ) ) children ( #( #(matched : $e.matched), #(first : $e.first), #(second : $e.second) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::match_results from ;------------------------------------------------------------------------------ std::tr1::match_results<*>{ preview ( ; A match_results object is empty iff its vector _Matches is empty. #if ($e._Matches._Myfirst == $e._Matches._Mylast) ( "empty" ) #else ( ; We preview a non-empty match_results object with its vector. $e._Matches ) ) children ( #if ($e._Matches._Myfirst == $e._Matches._Mylast) ( ; We make empty match_results appear to have no children. #array(expr: 0, size: 0) ) #else ( ; As match_results has operator[](), prefix(), and suffix() member functions, ; we make it appear to directly contain [0], [1], [2], etc. elements, ; as well as [prefix] and [suffix] elements. #( #array(expr: $e._Matches._Myfirst[$i], size: $e._Matches._Mylast - $e._Matches._Myfirst), #([prefix] : $e._Prefix), #([suffix] : $e._Suffix) ) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::regex_iterator from ;------------------------------------------------------------------------------ std::tr1::regex_iterator<*>{ preview ( #if ($e._MyRe == 0) ( ; We represent end-of-sequence regex_iterators with null regex pointers. "end" ) #else ( ; Dereferenceable regex_iterators return match_results when dereferenced, ; so we'll preview them with that. $e._MyVal ) ) children ( #if ($e._MyRe == 0) ( ; We make end-of-sequence regex_iterators appear to have no children. #array(expr: 0, size: 0) ) #else ( ; For ease of understanding, we make dereferenceable regex_iterators ; appear to have data members with the "for exposition only" names from TR1. #( #([begin] : $e._Begin), #([end] : $e._End), #([pregex] : $e._MyRe), #([flags] : $e._Flags), #([match] : $e._MyVal) ) ) ) } ;------------------------------------------------------------------------------ ; std::tr1::regex_token_iterator from ;------------------------------------------------------------------------------ std::tr1::regex_token_iterator<*>{ preview ( #if ($e._Res == 0) ( ; We represent end-of-sequence regex_token_iterators with null result pointers. "end" ) #else ( ; Dereferenceable regex_token_iterators return *result when dereferenced, ; so we'll preview them with that. *$e._Res ) ) children ( #if ($e._Res == 0) ( ; We make end-of-sequence regex_token_iterators appear to have no children. #array(expr: 0, size: 0) ) #else ( ; For ease of understanding, we make dereferenceable regex_token_iterators ; appear to have data members with the "for exposition only" names from TR1. #( #([position] : $e._Pos), #([result] : $e._Res), #([suffix] : $e._Suffix), #([N] : $e._Cur), #([subs] : $e._Subs) ) ) ) } ;------------------------------------------------------------------------------ ; std::identity, etc. from ;------------------------------------------------------------------------------ std::identity<*>{ preview ( "identity" ) children ( #array(expr: 0, size: 0) ) } std::bit_and<*>{ preview ( "bit_and" ) children ( #array(expr: 0, size: 0) ) } std::bit_or<*>{ preview ( "bit_or" ) children ( #array(expr: 0, size: 0) ) } std::bit_xor<*>{ preview ( "bit_xor" ) children ( #array(expr: 0, size: 0) ) } ;------------------------------------------------------------------------------ ; std::unique_ptr from ;------------------------------------------------------------------------------ std::unique_ptr<*>{ preview ( #if ($e._Myptr == 0) ( "empty" ) #else ( #( "unique_ptr ", *$e._Myptr ) ) ) children ( #if ($e._Myptr == 0) ( #array(expr: 0, size: 0) ) #else ( #([ptr] : $e._Myptr) ) ) } ;------------------------------------------------------------------------------ ; std::forward_list from ;------------------------------------------------------------------------------ std::forward_list<*>{ preview ( #( "(", #list( head: $e._Myhead, next: _Next ) : $e._Myval, ")" ) ) children ( #list( head: $e._Myhead, next: _Next ) : $e._Myval ) } std::_Flist_iterator<*>|std::_Flist_const_iterator<*>{ preview ( #if ($e._Ptr == 0) ( "end" ) #else ( $e._Ptr->_Myval ) ) children ( #if ($e._Ptr == 0) ( #array(expr: 0, size: 0) ) #else ( #([ptr] : &$e._Ptr->_Myval) ) ) } ;------------------------------------------------------------------------------ ; PROPVARIANT ;------------------------------------------------------------------------------ ; Visualizers for VT_VECTOR C arrays tagCAC|tagCAUB|tagCAI|tagCAUI|tagCAL|tagCAUL|tagCAFLT|tagCADBL|tagCACY|tagCADATE|tagCABSTR|tagCABSTRBLOB|tagCABOOL|tagCASCODE|tagCAPROPVARIANT|tagCAH|tagCAUH|tagCALPSTR|tagCALPWSTR|tagCAFILETIME|tagCACLIPDATA|tagCACLSID{ preview( #( "[", $e.cElems , "](", #array ( expr : ($e.pElems)[$i], size : $e.cElems ), ")" ) ) children ( #array ( expr : ($e.pElems)[$i], size : $e.cElems ) ) } ; Visualizers for SAFE ARRAY tagSAFEARRAY|SAFEARRAY{ preview( #if ($e.fFeatures & 0x0080) ; FADF_HAVEVARTYPE ( ; Switch on the variant type field - which is stored 4 bytes ; before the beginning of the SAFEARRAY type #switch( ((unsigned *)&($e))[-1] ) #case 0x2 ; VT_I2 | VT_ARRAY ( #( "safearray of I2 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((signed short *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x3 ; VT_I4 | VT_ARRAY ( #( "safearray of I4 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((signed int *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x4 ; VT_R4 | VT_ARRAY ( #( "safearray of R4 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((float *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x5 ; VT_R8 | VT_ARRAY ( #( "safearray of R8 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((double *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x6 ; VT_CY | VT_ARRAY ( #( "safearray of CY = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((CY *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x7 ; VT_DATE | VT_ARRAY ( #( "safearray of DATE = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((DATE *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x8 ; VT_BSTR | VT_ARRAY ( #( "safearray of BSTR = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((wchar_t **)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0xa ; VT_ERROR | VT_ARRAY ( #( "safearray of ERROR = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((long *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0xb ; VT_BOOL | VT_ARRAY ( #( "safearray of BOOL = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((short *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0xc ; VT_VARIANT | VT_ARRAY ( #( "safearray of VARIANT = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((tagVARIANT *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x10 ; VT_I1 | VT_ARRAY ( #( "safearray of I1 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((signed char *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x11 ; VT_UI1 | VT_ARRAY ( #( "safearray of UI1 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((unsigned char *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x12 ; VT_UI2 | VT_ARRAY ( #( "safearray of UI2 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((unsigned short *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x13 ; VT_UI4 | VT_ARRAY ( #( "safearray of UI4 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((unsigned int *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x14 ; VT_I8 | VT_ARRAY ( #( "safearray of I8 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((signed __int64 *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x15 ; VT_UI8 | VT_ARRAY ( #( "safearray of UI8 = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((unsigned __int64 *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x16 ; VT_INT | VT_ARRAY ( #( "safearray of INT = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((int *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x17 ; VT_UINT | VT_ARRAY ( #( "safearray of UINT = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((unsigned *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x1e ; VT_LPSTR | VT_ARRAY ( #( "safearray of LPSTR = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((char **)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x1f ; VT_LPWSTR | VT_ARRAY ( #( "safearray of LPWSTR = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((wchar_t **)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x40 ; VT_FILETIME | VT_ARRAY ( #( "safearray of FILETIME = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((FILETIME *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x47 ; VT_CLIPDATA | VT_ARRAY ( #( "safearray of CLIPDATA = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((CLIPDATA *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) #case 0x48 ; VT_CLSID | VT_ARRAY ( #( "safearray of CLSID = [", ; output the rank array #array( expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", ; output the data elements #array( expr: ((CLSID *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")" ) ) ) #elif ($e.fFeatures & 0x0100) ; FADF_BSTR ( #("safearray of BSTR = ",#array(expr: $e.rgsabound[$i].cElements, size: $e.cDims) : #("[",$e,"]"), "(", #array(expr: ((wchar_t * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")") ) #elif ($e.fFeatures & 0x0200) ; FADF_UNKNOWN ( #("safearray of IUnknown* = [",#array(expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", #array(expr: ((IUnknown * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")") ) #elif ($e.fFeatures & 0x0400) ; FADF_DISPATCH ( #("safearray of IDispatch* = [",#array(expr: $e.rgsabound[$i].cElements, size: $e.cDims), "](", #array(expr: ((IDispatch * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")") ) #elif ($e.fFeatures & 0x0800) ; FADF_VARIANT ( #("safearray of VARIANT = ",#array(expr: $e.rgsabound[$i].cElements, size: $e.cDims) : #("[",$e,"]"), "(", #array(expr: ((tagVARIANT *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ), ")") ) ) children ( #( ;[actual members]: [$e,!], #if ($e.fFeatures & 0x0080) ; FADF_HAVEVARTYPE ( #switch( ((unsigned *)&($e))[-1] ) ; for some reason the VT field is before the SAFEARRAY struct #case 2 ; VT_I2|VT_ARRAY ( #array( expr: ((signed short *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 3 ; VT_I4|VT_ARRAY ( #array( expr: ((signed int *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 4 ; VT_R4|VT_ARRAY ( #array( expr: ((float *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 5 ; VT_R8|VT_ARRAY ( #array( expr: ((double *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x10 ; VT_I1|VT_ARRAY ( #array( expr: ((signed char *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x11 ; VT_UI1|VT_ARRAY ( #array( expr: ((unsigned char *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x12 ; VT_UI2|VT_ARRAY ( #array( expr: ((unsigned short *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x13 ; VT_UI4|VT_ARRAY ( #array( expr: ((unsigned int *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x14 ; VT_I8|VT_ARRAY ( #array( expr: ((signed __int64 *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x15 ; VT_UI8|VT_ARRAY ( #array( expr: ((unsigned __int64 *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x1e ; VT_LPSTR|VT_ARRAY ( #array( expr: ((char * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x1f ; VT_LPWSTR|VT_ARRAY ( #array( expr: ((wchar_t **)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0xc ; VT_VARIANT|VT_ARRAY ( #array( expr: ((tagVARIANT *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0xb ; VT_BOOL|VT_ARRAY ( #array( expr: ((short *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0xa ; VT_ERROR|VT_ARRAY ( #array( expr: ((long *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 6 ; VT_CY|VT_ARRAY ( #array( expr: ((CY *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 7 ; VT_DATE|VT_ARRAY ( #array( expr: ((DATE *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x40 ; VT_FILETIME|VT_ARRAY ( #array( expr: ((FILETIME *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x48 ; VT_CLSID|VT_ARRAY ( #array( expr: ((CLSID *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x47 ; VT_CF|VT_ARRAY ( #array( expr: ((CLIPDATA *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 8 ; VT_BSTR|VT_ARRAY ( #array( expr: ((wchar_t * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x16 ; VT_INT|VT_ARRAY ( #array( expr: ((int *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #case 0x17 ; VT_UINT|VT_ARRAY ( #array( expr: ((unsigned int*)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #default ( #([actual members]: [$e,!]) ) #except ( #([actual members]: [$e,!]) ) ) #elif ($e.fFeatures & 0x0100) ; FADF_BSTR ( #array(expr: ((wchar_t * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #elif ($e.fFeatures & 0x0200) ; FADF_UNKNOWN ( #array(expr: ((IUnknown * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #elif ($e.fFeatures & 0x0400) ; FADF_DISPATCH ( #array(expr: ((IDispatch * *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) #elif ($e.fFeatures & 0x0800) ; FADF_VARIANT ( #array(expr: ((tagVARIANT *)$e.pvData)[$i], size: $e.rgsabound[$r].cElements, rank: $e.cDims, base: $e.rgsabound[$r].lLbound ) ) ) ) } tagPROPVARIANT|tagVARIANT|PROPVARIANT|VARIANT{ preview( #switch ($e.vt) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Base Types ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #case 0 ( #("Empty") ) ; VT_EMPTY #case 1 ( #("NULL") ) ; VT_NULL #case 2 ( #("I2 = ", $e.iVal) ) ; VT_I2 #case 3 ( #("I4 = ", $e.lVal) ) ; VT_I4 #case 4 ( #("R4 = ", $e.fltVal) ) ; VT_R4 #case 5 ( #("R8 = ", $e.dblVal) ) ; VT_R8 #case 6 ( #("CY = ", $e.cyVal) ) ; VT_CY #case 7 ( #("DATE = ", $e.date) ) ; VT_DATE #case 8 ( #("BSTR = ", $e.bstrVal) ) ; VT_BSTR #case 9 ( #("DISPATCH = ", $e.pdispVal) ) ; VT_DISPATCH #case 10 ( #("ERROR = ", $e.scode) ) ; VT_ERROR #case 0xB ( #("BOOL = ", $e.boolVal) ) ; VT_BOOL #case 0xC ( #("VARIANT ") ) ; VT_VARIANT #case 0xD ( #("UNKNOWN = ", $e.punkVal) ) ; VT_UNKOWN #case 0xE ( #("DECIMAL = ", $e.decVal) ) ; VT_DECIMAL #case 0x10 ( #("I1 = ", $e.cVal) ) ; VT_I1 #case 0x11 ( #("UI1 = ", $e.bVal) ) ; VT_UI1 #case 0x12 ( #("UI2 = ", $e.uiVal) ) ; VT_UI2 #case 0x13 ( #("UI4 = ", $e.ulVal) ) ; VT_UI4 #case 0x14 ( #("I8 = ", *(__int64*)&$e.dblVal) ) ; VT_I8 #case 0x15 ( #("UI8 = ", *(unsigned __int64*)&$e.dblVal) ) ; VT_UI8 #case 0x16 ( #("INT = ", $e.intVal) ) ; VT_INT #case 0x17 ( #("UINT = ", $e.uintVal) ) ; VT_UINT #case 0x18 ( #("VOID ") ) ; VT_VOID #case 0x19 ( #("HRESULT ") ) ; VT_HRESULT #case 0x1A ( #("PTR ") ) ; VT_PTR #case 0x1B ( #("SAFEARRAY ") ) ; VT_SAFEARRAY #case 0x1C ( #("CARRAY ") ) ; VT_CARRAY #case 0x1D ( #("USERDEFINED ") ) ; VT_USERDEFINED #case 0x1E ( #("LPSTR = ", $e.pszVal) ) ; VT_LPSTR #case 0x1F ( #("LPWSTR = ", $e.pwszVal) ) ; VT_LPWSTR #case 0x24 ( #("RECORD ") ) ; VT_RECORD #case 0x26 ( #("UINT_PTR ") ) ; VT_UINT_PTR #case 0x40 ( #("FILETIME = ", $e.filetime) ) ; VT_FILETIME #case 0x42 ( #("STREAM = ", $e.pStream) ) ; VT_STREAM #case 0x43 ( #("STORAGE = ", $e.pStorage) ) ; VT_STORAGE #case 0x44 ( #("STREAMED_OBJECT = ", $e.pStream) ) ; VT_STREAMED_OBJECT #case 0x45 ( #("STORED_OBJECT = ", $e.pStorage) ) ; VT_STORED_OBJECT #case 0x46 ( #("BLOB_OBJECT = ", $e.blob ) ) ; VT_BLOB_OBJECT #case 0x47 ( #("CF = ", $e.pclipdata) ) ; VT_CF #case 0x48 ( #("CLSID = ", $e.puuid) ) ; VT_CLSID #case 0x49 ( #("VERSIONED_STREAM = ", $e.pVersionedStream) ) ; VT_VERSIONED_STREAM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Vector types ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #case 0x1002 ( #("vector of I2 = ", $e.cai) ) ; VT_I2|VT_VECTOR #case 0x1003 ( #("vector of I4 = ", $e.cal) ) ; VT_I4|VT_VECTOR #case 0x1004 ( #("vector of R4 = ", $e.caflt) ) ; VT_R4|VT_VECTOR #case 0x1005 ( #("vector of R8 = ", $e.cadbl) ) ; VT_R8|VT_VECTOR #case 0x1010 ( #("vector of I1 = ", $e.cac) ) ; VT_I1|VT_VECTOR #case 0x1011 ( #("vector of UI1 = ", $e.caub) ) ; VT_UI1|VT_VECTOR #case 0x1012 ( #("vector of UI2 = ", $e.caui) ) ; VT_UI2|VT_VECTOR #case 0x1013 ( #("vector of UI4 = ", $e.caul) ) ; VT_UI4|VT_VECTOR #case 0x1014 ( #("vector of I8 = ", $e.cah) ) ; VT_I8|VT_VECTOR #case 0x1015 ( #("vector of UI8 = ", $e.cauh) ) ; VT_UI8|VT_VECTOR #case 0x101E ( #("vector of LPSTR = ", $e.calpstr) ) ; VT_LPSTR|VT_VECTOR #case 0x101F ( #("vector of LPWSTR = ", $e.calpwstr) ) ; VT_LPWSTR|VT_VECTOR #case 0x100C ( #("vector of VARIANT ", $e.capropvar) ) ; VT_VARIANT|VT_VECTOR #case 0x100B ( #("vector of BOOL = ", $e.cabool) ) ; VT_BOOL|VT_VECTOR #case 0x100A ( #("vector of ERROR = ", $e.cascode) ) ; VT_ERROR|VT_VECTOR #case 0x1006 ( #("vector of CY = ", $e.cacy) ) ; VT_CY|VT_VECTOR #case 0x1007 ( #("vector of DATE = ", $e.cadate) ) ; VT_DATE|VT_VECTOR #case 0x1040 ( #("vector of FILETIME = ", $e.cafiletime) ) ; VT_FILETIME|VT_VECTOR #case 0x1048 ( #("vector of CLSID = ", $e.cauuid) ) ; VT_CLSID|VT_VECTOR #case 0x1047 ( #("vector of CF = ", $e.caclipdata) ) ; VT_CF|VT_VECTOR #case 0x1008 ( #("vector of BSTR = ", $e.cabstr) ) ; VT_BSTR|VT_VECTOR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Byref Types ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #case 0x4016 ( #("byref of INT = ", $e.pintVal) ) ; VT_INT|VT_BYREF #case 0x4017 ( #("byref of UINT = ", $e.puintVal) ) ; VT_UINT|VT_BYREF #case 0x4002 ( #("byref of I2 = ", $e.piVal) ) ; VT_I2|VT_BYREF #case 0x4003 ( #("byref of I4 = ", $e.plVal) ) ; VT_I4|VT_BYREF #case 0x4004 ( #("byref of R4 = ", $e.pfltVal) ) ; VT_R4|VT_BYREF #case 0x4005 ( #("byref of R8 = ", $e.pdblVal) ) ; VT_R8|VT_BYREF #case 0x4010 ( #("byref of I1 = ", $e.pcVal) ) ; VT_I1|VT_BYREF #case 0x4011 ( #("byref of UI1 = ", $e.pbVal) ) ; VT_UI1|VT_BYREF #case 0x4012 ( #("byref of UI2 = ", $e.puiVal) ) ; VT_UI2|VT_BYREF #case 0x4013 ( #("byref of UI4 = ", $e.pulVal) ) ; VT_UI4|VT_BYREF #case 0x4014 ( #("byref of I8 = ", (__int64*)$e.pdblVal) ) ; VT_I8|VT_BYREF #case 0x4015 ( #("byref of UI8 = ", (unsigned __int64*)$e.pudblVal) ) ; VT_UI8|VT_BYREF #case 0x400C ( #("byref of VARIANT ", $e.pvarVal) ) ; VT_VARIANT|VT_BYREF #case 0x400B ( #("byref of BOOL = ", $e.pboolVal) ) ; VT_BOOL|VT_BYREF #case 0x400A ( #("byref of ERROR = ", $e.pscode) ) ; VT_ERROR|VT_BYREF #case 0x4006 ( #("byref of CY = ", $e.pcyVal) ) ; VT_CY|VT_BYREF #case 0x4007 ( #("byref of DATE = ", $e.pdate) ) ; VT_DATE|VT_BYREF #case 0x4008 ( #("byref of BSTR = ", $e.pbstrVal) ) ; VT_BSTR|VT_BYREF #case 0x400E ( #("byref of DECIMAL = ", $e.pdecVal) ) ; VT_DECIMAL|VT_BYREF #case 0x400D ( #("byref of UNKNOWN = ", $e.ppunkVal) ) ; VT_UNKOWN|VT_BYREF #case 0x4009 ( #("byref of DISPATCH = ", $e.ppdispVal) ) ; VT_DISPATCH|VT_BYREF #case 0x6000 ( #("byref of ARRAY = ", $e.pparray) ) ; VT_ARRAY|VT_BYREF #default ( #if ($e.vt & 0x2000) ( $e.parray) #else ( #("Unknown vt type = ", $e.vt)) ) ) children( #( vt: $e.vt, #switch ($e.vt) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Base Types ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #case 0x2 ( #(I2 : $e.iVal) ) ; VT_I2 #case 0x3 ( #(I4 : $e.lVal) ) ; VT_I4 #case 0x4 ( #(R4 : $e.fltVal) ) ; VT_R4 #case 0x5 ( #(R8 : $e.dblVal) ) ; VT_R8 #case 0x6 ( #(CY : $e.cyVal) ) ; VT_CY #case 0x7 ( #(DATE : $e.date) ) ; VT_DATE #case 0x8 ( #(BSTR : $e.bstrVal) ) ; VT_BSTR #case 0x9 ( #(DISPATCH : $e.pdispVal) ) ; VT_DISPATCH #case 0xA ( #(ERROR : $e.scode) ) ; VT_ERROR #case 0xB ( #(BOOL : $e.boolVal) ) ; VT_BOOL #case 0xD ( #(UNKNOWN : $e.punkVal) ) ; VT_UNKOWN #case 0xE ( #(DECIMAL : $e.decVal) ) ; VT_DECIMAL #case 0x10 ( #(I1 : $e.cVal) ) ; VT_I1 #case 0x11 ( #(UI1 : $e.bVal) ) ; VT_UI1 #case 0x12 ( #(UI2 : $e.uiVal) ) ; VT_UI2 #case 0x13 ( #(UI4 : $e.ulVal) ) ; VT_UI4 #case 0x14 ( #(I8 : *(__int64*)&$e.dblVal) ) ; VT_I8 #case 0x15 ( #(UI8 : *(unsigned __int64*)&$e.dblVal) ) ; VT_UI8 #case 0x16 ( #(INT : $e.intVal) ) ; VT_INT #case 0x17 ( #(UINT : $e.uintVal) ) ; VT_UINT #case 0x1E ( #(LPSTR : $e.pszVal) ) ; VT_LPSTR #case 0x1F ( #(LPWSTR : $e.pwszVal) ) ; VT_LPWSTR #case 0x40 ( #(FILETIME : $e.filetime) ) ; VT_FILETIME #case 0x42 ( #(STREAM : $e.pStream) ) ; VT_STREAM #case 0x43 ( #(STORAGE : $e.pStorage) ) ; VT_STORAGE #case 0x44 ( #(STREAMED_OBJECT : $e.pStream) ) ; VT_STREAMED_OBJECT #case 0x45 ( #(STORED_OBJECT : $e.pStorage) ) ; VT_STORED_OBJECT #case 0x46 ( #(BLOB_OBJECT : $e.blob ) ) ; VT_BLOB_OBJECT #case 0x47 ( #(CF : $e.pclipdata) ) ; VT_CF #case 0x48 ( #(CLSID : $e.puuid) ) ; VT_CLSID #case 0x49 ( #(VERSIONED_STREAM : $e.pVersionedStream) ) ; VT_VERSIONED_STREAM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Vector types ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #case 0x1002 ( #(vector of I2 : $e.cai) ) ; VT_I2|VT_VECTOR #case 0x1003 ( #(vector of I4 : $e.cal) ) ; VT_I4|VT_VECTOR #case 0x1004 ( #(vector of R4 : $e.caflt) ) ; VT_R4|VT_VECTOR #case 0x1005 ( #(vector of R8 : $e.cadbl) ) ; VT_R8|VT_VECTOR #case 0x1010 ( #(vector of I1 : $e.cac) ) ; VT_I1|VT_VECTOR #case 0x1011 ( #(vector of UI1 : $e.caub) ) ; VT_UI1|VT_VECTOR #case 0x1012 ( #(vector of UI2 : $e.caui) ) ; VT_UI2|VT_VECTOR #case 0x1013 ( #(vector of UI4 : $e.caul) ) ; VT_UI4|VT_VECTOR #case 0x1014 ( #(vector of I8 : $e.cah) ) ; VT_I8|VT_VECTOR #case 0x1015 ( #(vector of UI8 : $e.cauh) ) ; VT_UI8|VT_VECTOR #case 0x101E ( #(vector of LPSTR : $e.calpstr) ) ; VT_LPSTR|VT_VECTOR #case 0x101F ( #(vector of LPWSTR : $e.calpwstr) ) ; VT_LPWSTR|VT_VECTOR #case 0x100C ( #(vector of VARIANT : $e.capropvar) ) ; VT_VARIANT|VT_VECTOR #case 0x100B ( #(vector of BOOL : $e.cabool) ) ; VT_BOOL|VT_VECTOR #case 0x100A ( #(vector of ERROR : $e.cascode) ) ; VT_ERROR|VT_VECTOR #case 0x1006 ( #(vector of CY : $e.cacy) ) ; VT_CY|VT_VECTOR #case 0x1007 ( #(vector of DATE : $e.cadate) ) ; VT_DATE|VT_VECTOR #case 0x1040 ( #(vector of FILETIME : $e.cafiletime) ) ; VT_FILETIME|VT_VECTOR #case 0x1048 ( #(vector of CLSID : $e.cauuid) ) ; VT_CLSID|VT_VECTOR #case 0x1047 ( #(vector of CF : $e.caclipdata) ) ; VT_CF|VT_VECTOR #case 0x1008 ( #(vector of BSTR : $e.cabstr) ) ; VT_BSTR|VT_VECTOR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Byref Types ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #case 0x4016 ( #(byref of INT : $e.pintVal) ) ; VT_INT|VT_BYREF #case 0x4017 ( #(byref of UINT : $e.puintVal) ) ; VT_UINT|VT_BYREF #case 0x4002 ( #(byref of I2 : $e.piVal) ) ; VT_I2|VT_BYREF #case 0x4003 ( #(byref of I4 : $e.plVal) ) ; VT_I4|VT_BYREF #case 0x4004 ( #(byref of R4 : $e.pfltVal) ) ; VT_R4|VT_BYREF #case 0x4005 ( #(byref of R8 : $e.pdblVal) ) ; VT_R8|VT_BYREF #case 0x4010 ( #(byref of I1 : $e.pcVal) ) ; VT_I1|VT_BYREF #case 0x4011 ( #(byref of UI1 : $e.pbVal) ) ; VT_UI1|VT_BYREF #case 0x4012 ( #(byref of UI2 : $e.puiVal) ) ; VT_UI2|VT_BYREF #case 0x4013 ( #(byref of UI4 : $e.pulVal) ) ; VT_UI4|VT_BYREF #case 0x4014 ( #(byref of I8 : (__int64*)$e.pdblVal) ) ; VT_I8|VT_BYREF #case 0x4015 ( #(byref of UI8 : (unsigned __int64*)$e.pdblVal) ) ; VT_UI8|VT_BYREF #case 0x400C ( #(byref of VARIANT : $e.pvarVal) ) ; VT_VARIANT|VT_BYREF #case 0x400B ( #(byref of BOOL : $e.pboolVal) ) ; VT_BOOL|VT_BYREF #case 0x400A ( #(byref of ERROR : $e.pscode) ) ; VT_ERROR|VT_BYREF #case 0x4006 ( #(byref of CY : $e.pcyVal) ) ; VT_CY|VT_BYREF #case 0x4007 ( #(byref of DATE : $e.pdate) ) ; VT_DATE|VT_BYREF #case 0x4008 ( #(byref of BSTR : $e.pbstrVal) ) ; VT_BSTR|VT_BYREF #case 0x400E ( #(byref of DECIMAL : $e.pdecVal) ) ; VT_DECIMAL|VT_BYREF #case 0x400D ( #(byref of UNKNOWN : $e.ppunkVal) ) ; VT_UNKOWN|VT_BYREF #case 0x4009 ( #(byref of DISPATCH : $e.ppdispVal) ) ; VT_DISPATCH|VT_BYREF #case 0x6000 ( #(byref of ARRAY : $e.pparray) ) ; VT_ARRAY|VT_BYREF ; the following are either empty or invalid vt values for a variant ; #case 0 ( #(Empty :) ) ; VT_EMPTY ; #case 0x1 ( #(NULL :) ) ; VT_NULL ; #case 0xC ( #(VARIANT :) ) ; VT_VARIANT ; #case 0x18 ( #(VOID :) ) ; VT_VOID ; #case 0x19 ( #(HRESULT :) ) ; VT_HRESULT ; #case 0x1A ( #(PTR :) ) ; VT_PTR ; #case 0x1B ( #(SAFEARRAY :) ) ; VT_SAFEARRAY ; #case 0x1C ( #(CARRAY :) ) ; VT_CARRAY ; #case 0x1D ( #(USERDEFINED :) ) ; VT_USERDEFINED ; #case 0x24 ( #(RECORD :) ) ; VT_RECORD ; #case 0x26 ( #(UINT_PTR :) ) ; VT_UINT_PTR #default ( #if ($e.vt & 0x2000 ) ( #(safearray: $e.parray)) #else ( #( [raw members]: [$e,!] ; unformatted data members ) ) ) #except ( #( [raw members]: [$e,!] ; unformatted data members ) ) ) ) } ; Visualizers for data structures in namespace Concurrency ;------------------------------------------------------------------------------ ; Concurrency::message from ;------------------------------------------------------------------------------ Concurrency::message<*>{ preview ( #( $e.payload ) ) children ( #( #(payload: $e.payload), #([msg_id]: $e._M_id) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::multi_link_registry from ;------------------------------------------------------------------------------ Concurrency::multi_link_registry<*>{ preview ( #( "[", $e._M_vector._M_index, "](", #array( expr: *($e._M_vector._M_array[$i]), size: $e._M_vector._M_index ), ")" ) ) children ( #( #([size]: $e._M_vector._M_index), #array( expr: *($e._M_vector._M_array[$i]), size: $e._M_vector._M_index ) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::_Queue from ;------------------------------------------------------------------------------ Concurrency::details::_Queue<*>{ preview ( #( "[", $e._M_count, "](", #list( head: $e._M_pHead, next: _M_pNext, size: _M_count ), ")" ) ) children ( #( #([size]: $e._M_count), #list( head: $e._M_pHead, next: _M_pNext, size: _M_count ) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::unbounded_buffer from ;------------------------------------------------------------------------------ Concurrency::unbounded_buffer<*>{ preview ( #( $e._M_messageBuffer ) ) children ( #( #(unprocessed_messages: $e._M_messageProcessor._M_queuedMessages._M_queue), #(messages: $e._M_messageBuffer), #(message_filter: *($e._M_pFilter)), #(linked_sources: $e._M_connectedSources._M_links), #(linked_targets: $e._M_connectedTargets), #(reserving_target: *($e._M_pReservedFor)), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::overwrite_buffer from ;------------------------------------------------------------------------------ Concurrency::overwrite_buffer<*>{ preview ( #( $e._M_pMessage ) ) children ( #( #(value: *($e._M_pMessage)), #(unprocessed_messages: $e._M_messageProcessor._M_queuedMessages._M_queue), #(message_filter: *($e._M_pFilter)), #(linked_sources: $e._M_connectedSources._M_links), #(linked_targets: $e._M_connectedTargets), #(reserving_target: *($e._M_pReservedFor)), #(reserved_message: *($e._M_pReservedMessage)), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::single_assignment from ;------------------------------------------------------------------------------ Concurrency::single_assignment<*>{ preview ( #( $e._M_pMessage ) ) children ( #( #(value: *($e._M_pMessage)), #(unprocessed_messages: $e._M_messageProcessor._M_queuedMessages._M_queue), #(message_filter: *($e._M_pFilter)), #(linked_sources: $e._M_connectedSources._M_links), #(linked_targets: $e._M_connectedTargets), #(reserving_target: *($e._M_pReservedFor)), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::call from ;------------------------------------------------------------------------------ Concurrency::call<*>{ preview ( #( $e._M_pFunc ) ) children ( #( #(call_method: $e._M_pFunc), #(unprocessed_messages: $e._M_messageProcessor._M_queuedMessages._M_queue), #(message_filter: *($e._M_pFilter)), #(linked_sources: $e._M_connectedSources._M_links), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::transformer from ;------------------------------------------------------------------------------ Concurrency::transformer<*>{ preview ( #( $e._M_pFunc ) ) children ( #( #(transform_method: $e._M_pFunc), #(unprocessed_messages: $e._M_messageProcessor._M_queuedMessages._M_queue), #(messages: $e._M_messageBuffer), #(message_filter: *($e._M_pFilter)), #(linked_sources: $e._M_connectedSources._M_links), #(linked_target: *($e._M_connectedTargets._M_connectedLink)), #(reserving_target: *($e._M_pReservedFor)), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::choice from ;------------------------------------------------------------------------------ Concurrency::choice<*>{ preview ( #( "[", #if ($e._M_pSingleAssignment->_M_fIsInitialized) ("initialized") #else ("not_initialized"), "] ", $e._M_sourceTuple ) ) children ( #( #([input_count]: $e._M_pSingleAssignment->_M_connectedSources._M_links._M_vector._M_index), #(index: $e._M_pSingleAssignment->_M_pMessage->payload), #(source_tuple: $e._M_sourceTuple), #(linked_sources: $e._M_pSingleAssignment->_M_connectedSources._M_links), #(linked_targets: $e._M_pSingleAssignment->_M_connectedTargets), #(reserving_target: *($e._M_pSingleAssignment->_M_pReservedFor)), #(Scheduler: *($e._M_pScheduler)), #(ScheduleGroup: *($e._M_pScheduleGroup)), #([raw _M_pSourceChoices] : $e._M_pSourceChoices) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::join<*,*>::_MessageArray from ;------------------------------------------------------------------------------ Concurrency::join<*,*>::_MessageArray{ preview ( #( "[", $e._M_count, "](", #array( expr: *(((Concurrency::message<$T1>**)$e._M_messages)[$i]), size: $e._M_count ), ")" ) ) children ( #( #([size]: $e._M_count), #array( expr: *(((Concurrency::message<$T1>**)$e._M_messages)[$i]), size: $e._M_count ) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::join<*,*>::_SavedMessageIdArray from ;------------------------------------------------------------------------------ Concurrency::join<*,*>::_SavedMessageIdArray{ preview ( #( "[", $e._M_count, "](", #array( expr: ((int*)$e._M_savedIds)[$i], size: $e._M_count ), ")" ) ) children ( #( #([size]: $e._M_count), #array( expr: ((int*)$e._M_savedIds)[$i], size: $e._M_count ) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::join from ;------------------------------------------------------------------------------ Concurrency::join<*,*>{ preview ( #( "[", $e._M_messageArray._M_count - $e._M_messagesRemaining, "/", $e._M_messageArray._M_count, "](", #array( expr: *($e._M_connectedSources._M_links._M_vector._M_array[$i]), size: $e._M_connectedSources._M_links._M_vector._M_index ), ")" ) ) children ( #( #([join_type]: (Concurrency::join_type)$T2), #([offer_count]: $e._M_messageArray._M_count - $e._M_messagesRemaining), #(offer_IDs: $e._M_savedMessageIdArray), #([input_count]: $e._M_messageArray._M_count), #(input_values: $e._M_messageArray), #(messages: $e._M_messageBuffer), #(message_filter: *($e._M_pFilter)), #(linked_sources: $e._M_connectedSources._M_links), #(linked_target: $e._M_connectedTargets._M_connectedLink), #(reserving_target: *($e._M_pReservedFor)), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::multitype_join from ;------------------------------------------------------------------------------ Concurrency::multitype_join<*,*>{ preview ( #( "[", $e._M_pJoinNode->_M_connectedSources._M_links._M_vector._M_index - $e._M_pJoinNode->_M_counter, "/", $e._M_pJoinNode->_M_connectedSources._M_links._M_vector._M_index, "]", $e._M_sourceTuple ) ) children ( #( #([join_type]: (Concurrency::join_type)$T2), #([offer_count]: $e._M_pJoinNode->_M_connectedSources._M_links._M_vector._M_index - $e._M_pJoinNode->_M_counter), #([input_count]: $e._M_pJoinNode->_M_connectedSources._M_links._M_vector._M_index), #(source_tuple: $e._M_sourceTuple), #(messages: $e._M_pJoinNode->_M_messageBuffer), #(linked_sources: $e._M_pJoinNode->_M_connectedSources._M_links), #(linked_target: $e._M_pJoinNode->_M_connectedTargets._M_connectedLink), #(reserving_target: *($e._M_pJoinNode->_M_pReservedFor)), #(Scheduler: *($e._M_pJoinNode->_M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_pJoinNode->_M_messageProcessor._M_pScheduleGroup)), #([raw _M_pSourceJoins] : $e._M_pSourceJoins) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::timer from ;------------------------------------------------------------------------------ Concurrency::timer<*>{ preview ( #( $e._M_state ) ) children ( #( #(state: $e._M_state), #(value: $e._M_value), #(repeating: $e._M_fRepeating), #(interval_ms: $e._M_ms), #(linked_target: *($e._M_connectedTargets._M_connectedLink)), #(reserving_target: *($e._M_pReservedFor)), #(Scheduler: *($e._M_messageProcessor._M_pScheduler)), #(ScheduleGroup: *($e._M_messageProcessor._M_pScheduleGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::SchedulerBase from ; Concurrency::details::ThreadScheduler from ; Concurrency::details::UMSThreadScheduler from ;------------------------------------------------------------------------------ Concurrency::details::SchedulerBase|Concurrency::details::ThreadScheduler|Concurrency::details::UMSThreadScheduler{ preview ( #( "[", $e.m_id, "] ", #if ($e.m_schedulerKind == 0) ("ThreadScheduler") #else ("UmsScheduler"), #if ($e.m_id == $e.s_pDefaultScheduler->m_id) (", default") #else ("") ) ) children ( #( #(ID: $e.m_id), #(SchedulerPolicy: $e.m_policy), #(VirtualProcessorCount: $e.m_virtualProcessorCount), #(ReferenceCount: $e.m_refCount), #([isDefaultScheduler]: $e.m_id == $e.s_pDefaultScheduler->m_id) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::ScheduleGroupBase from ; Concurrency::details::CacheLocalScheduleGroup from ; Concurrency::details::FairScheduleGroup from ;------------------------------------------------------------------------------ Concurrency::details::ScheduleGroupBase|Concurrency::details::CacheLocalScheduleGroup|Concurrency::details::FairScheduleGroup{ preview ( #( "[", $e.m_id, "]", #if ($e.m_kind & 4) (" AnonymousScheduleGroup") #else ("") ) ) children ( #( #(ID: $e.m_id), #(Scheduler: *($e.m_pScheduler)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::ContextBase from ; Concurrency::details::InternalContextBase from ; Concurrency::details::ThreadInternalContext from ; Concurrency::details::UMSThreadInternalContext from ;------------------------------------------------------------------------------ Concurrency::details::ContextBase|Concurrency::details::InternalContextBase|Concurrency::details::ThreadInternalContext|Concurrency::details::UMSThreadInternalContext{ preview ( #( "[", $e.m_threadId, "] ", #if ($e.m_blockedState == 0) ("not_concrt_blocked") #elif ($e.m_blockedState == 1) ("concrt_blocked") #elif ($e.m_blockedState == 2) ("ums_sync_blocked") #elif ($e.m_blockedState == 4) ("ums_async_blocked") #else ("") ) ) children ( #( #(ID: $e.m_id), #(ThreadID: $e.m_threadId), #(Scheduler: *($e.m_pScheduler)), #(ScheduleGroup: *($e.m_pGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::ExternalContextBase from ;------------------------------------------------------------------------------ Concurrency::details::ExternalContextBase{ preview ( #( "[", $e.m_threadId, "] ", #if ($e.m_contextSwitchingFence == 1) ("concrt_blocked") #else ("not_concrt_blocked") ) ) children ( #( #(ID: $e.m_id), #(ThreadID: $e.m_threadId), #(Scheduler: *($e.m_pScheduler)), #(ScheduleGroup: *($e.m_pGroup)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::SchedulerPolicy from ;------------------------------------------------------------------------------ Concurrency::SchedulerPolicy{ preview ( #( $e._M_pPolicyBag->_M_values._M_specificValues._M_schedulerKind, ", Min=", $e._M_pPolicyBag->_M_values._M_specificValues._M_minConcurrency, ", Max=", $e._M_pPolicyBag->_M_values._M_specificValues._M_maxConcurrency ) ) children ( #( #(SchedulerKind: $e._M_pPolicyBag->_M_values._M_specificValues._M_schedulerKind), #(MinConcurrency: $e._M_pPolicyBag->_M_values._M_specificValues._M_minConcurrency), #(MaxConcurrency: $e._M_pPolicyBag->_M_values._M_specificValues._M_maxConcurrency), #(TargetOversubscriptionFactor: $e._M_pPolicyBag->_M_values._M_specificValues._M_targetOversubscriptionFactor), #(LocalContextCacheSize: $e._M_pPolicyBag->_M_values._M_specificValues._M_localContextCacheSize), #(ContextStackSize: $e._M_pPolicyBag->_M_values._M_specificValues._M_contextStackSize), #(ContextPriority: $e._M_pPolicyBag->_M_values._M_specificValues._M_contextPriority), #(SchedulingProtocol: $e._M_pPolicyBag->_M_values._M_specificValues._M_schedulingProtocol), #(DynamicProgressFeedback: $e._M_pPolicyBag->_M_values._M_specificValues._M_dynamicProgressFeedback) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::event from ;------------------------------------------------------------------------------ Concurrency::event{ preview ( #( #if ($e._M_pWaitChain == 1) ("set") #else ("not_set") ) ) children ( #( #([is_set]: ($e._M_pWaitChain == 1)), #([has_waiters]: (($e._M_pWaitChain != 0) && ($e._M_pWaitChain != 1))) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::critical_section from ;------------------------------------------------------------------------------ Concurrency::critical_section{ preview ( #( #if ($e._M_pHead != 0) ("locked") #else ("not_locked") ) ) children ( #( #([is_locked]: ($e._M_pHead != 0)), #(OwningContext: *((Concurrency::Context*)($e._M_activeNode[0]))) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::critical_section::scoped_lock from ;------------------------------------------------------------------------------ Concurrency::critical_section::scoped_lock{ preview ( #( $e._M_critical_section ) ) children ( #( CriticalSection: $e._M_critical_section ) ) } ;------------------------------------------------------------------------------ ; Concurrency::reader_writer_lock from ;------------------------------------------------------------------------------ Concurrency::reader_writer_lock{ preview ( #( #if (($e._M_lockState < 8) && ($e._M_lockState & 2)) ("held_by_writer") #elif ($e._M_lockState >= 8) ( #( "held_by_reader(s) [", ($e._M_lockState / 8), "]" ) ) #else ("not_held") ) ) children ( #( #([is_reader_lock_held]: ($e._M_lockState >= 8)), #([num_reader_lock_holders]: ($e._M_lockState / 8)), #([is_writer_lock_held]: ($e._M_lockState < 8) && ($e._M_lockState & 2)), #(OwningWriterContext: *((Concurrency::Context*)($e._M_activeWriter[0]))) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::reader_writer_lock::scoped_lock from ; Concurrency::reader_writer_lock::scoped_lock_read from ;------------------------------------------------------------------------------ Concurrency::reader_writer_lock::scoped_lock|Concurrency::reader_writer_lock::scoped_lock_read{ preview ( #( $e._M_reader_writer_lock ) ) children ( #( ReaderWriterLock: $e._M_reader_writer_lock ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::_TaskCollectionBase from ;------------------------------------------------------------------------------ Concurrency::details::_TaskCollectionBase{ preview ( #( #if ((((int)$e._M_pException & ~0x3) != 0) && (((int)$e._M_pException & ~0x3) != 0xC)) ("exception") #else ("no_exception") ) ) children ( #( #([has_exception]: (((int)$e._M_pException & ~0x3) != 0) && (((int)$e._M_pException & ~0x3) != 0xC)), #(CreatingContext: *((Concurrency::Context*)$e._M_pOwningContext)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::task_group from ; Concurrency::structured_task_group from ;------------------------------------------------------------------------------ Concurrency::task_group|Concurrency::structured_task_group{ preview ( #( #if ((((int)$e._M_task_collection._M_pException & ~0x3) != 0) && (((int)$e._M_task_collection._M_pException & ~0x3) != 0xC)) ("exception") #else ("no_exception") ) ) children ( #( #([has_exception]: (((int)$e._M_task_collection._M_pException & ~0x3) != 0) && (((int)$e._M_task_collection._M_pException & ~0x3) != 0xC)), #(CreatingContext: *((Concurrency::Context*)$e._M_task_collection._M_pOwningContext)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::task_handle from ;------------------------------------------------------------------------------ Concurrency::task_handle<*>{ preview ( #( $e._M_function ) ) children ( #( #(Function: $e._M_function), #(RuntimeOwnsLifetime: $e._M_fRuntimeOwnsLifetime), #(TaskCollection: *($e._M_pTaskCollection)) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::combinable from ;------------------------------------------------------------------------------ Concurrency::combinable<*>{ preview( #( "(", #array( expr: *($e._M_buckets[$i]), size: $e._M_size ) : #list( head: $e, next: _M_chain ) : $e._M_value, ")" ) ) children( #( #array( expr: *($e._M_buckets[$i]), size: $e._M_size ) : #list( head: $e, next: _M_chain ) : $e._M_value, #(InitFunction : $e._M_fnInitialize) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::concurrent_vector from ;------------------------------------------------------------------------------ Concurrency::concurrent_vector<*,*>{ preview( #( "[", $e._My_early_size._M_value, "](", #array ( expr: #( #if (($i >> 1) == 0) ((($T1*)$e._My_segment._M_value[0]._My_array)[$i]) #else ((($T1*)$e._My_segment._M_value[__log2($i)]._My_array)[$i - (0x1 << __log2($i))]) ), size: $e._My_early_size._M_value ), ")" ) ) children( #( [size] : $e._My_early_size._M_value, #array ( expr: #( #if (($i >> 1) == 0) ((($T1*)$e._My_segment._M_value[0]._My_array)[$i]) #else ((($T1*)$e._My_segment._M_value[__log2($i)]._My_array)[$i - (0x1 << __log2($i))]) ), size: $e._My_early_size._M_value ) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::_Vector_iterator from ;------------------------------------------------------------------------------ Concurrency::details::_Vector_iterator,*>{ preview( #( #if (($e._My_index >> 1) == 0) ((($T1*)$e._My_vector->_My_segment._M_value[0]._My_array)[$e._My_index]) #else ((($T1*)$e._My_vector->_My_segment._M_value[__log2($e._My_index)]._My_array)[$e._My_index - (0x1 << __log2($e._My_index))]) ) ) children( #( [ptr]: #if (($e._My_index >> 1) == 0) (&((($T1*)$e._My_vector->_My_segment._M_value[0]._My_array)[$e._My_index])) #else (&((($T1*)$e._My_vector->_My_segment._M_value[__log2($e._My_index)]._My_array)[$e._My_index - (0x1 << __log2($e._My_index))])) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::concurrent_queue from ;------------------------------------------------------------------------------ Concurrency::concurrent_queue<*,*>{ preview ( #( "[", $e._My_rep->_Tail_counter._M_value - $e._My_rep->_Head_counter._M_value, "](", #array ( expr : #if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 0) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 1) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 2) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 3) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 4) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 5) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 6) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 7) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 8) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 9) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 10) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 11) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 12) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 13) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 14) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 15) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 16) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 17) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 18) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 19) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1])))))))))))))))))))), size : #if ($e._My_rep->_Tail_counter._M_value-$e._My_rep->_Head_counter._M_value < 20*8*$e._Items_per_page) ($e._My_rep->_Tail_counter._M_value-$e._My_rep->_Head_counter._M_value) #else (20*8*$e._Items_per_page) ), ")" ) ) children ( #( #([unsafe_size]: $e._My_rep->_Tail_counter._M_value-$e._My_rep->_Head_counter._M_value), #array ( expr : #if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 0) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 1) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 2) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 3) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 4) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 5) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 6) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 7) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 8) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 9) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 10) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 11) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 12) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 13) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 14) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 15) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 16) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 17) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 18) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else (#if (($i+($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)))/(8*$e._Items_per_page)-($e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>(8*($e._Items_per_page-1)))*($i%8+$e._My_rep->_Head_counter._M_value%(8*$e._Items_per_page)>=(8*$e._Items_per_page)) == 19) ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1]) #else ((($T1*)(($e._My_rep->_Array[(($i+$e._My_rep->_Head_counter._M_value)*3%8)]._Head_page._M_value->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next->_Next) + 1))[(($i+$e._My_rep->_Head_counter._M_value)&-8)/8&$e._Items_per_page-1])))))))))))))))))))), size : #if ($e._My_rep->_Tail_counter._M_value-$e._My_rep->_Head_counter._M_value < 20*8*$e._Items_per_page) ($e._My_rep->_Tail_counter._M_value-$e._My_rep->_Head_counter._M_value) #else (20*8*$e._Items_per_page) ) ) ) } ;------------------------------------------------------------------------------ ; Concurrency::details::_Concurrent_queue_iterator from ;------------------------------------------------------------------------------ Concurrency::details::_Concurrent_queue_iterator,*>{ preview( #( *(($T1*)$e._My_item) ) ) children( #( [ptr]: (($T1*)$e._My_item) ) ) } ; This section lets you define your own errors for the HRESULT display. ; You need to list the error code in unsigned decimal, followed by the message. ; Changes will take effect the next time you redisplay the variable. [hresult] ;1234=my custom error code [Visualizer] glm::detail::tvec2<*>{ preview ( #(#($c.x,$c.y)) ) children ( #([x]: $c.x,[y]: $c.y) ) } glm::detail::tvec3<*>{ preview ( #($e.x,$e.y,$e.z) ) children ( #([x]: $e.x,[y]: $e.y,[z]: $e.z) ) } glm::detail::tvec4<*>{ preview ( #($c.x,$c.y,$c.z,$c.w) ) children ( #([x]: $e.x,[y]: $e.y,[z]: $e.z, #([w]: $e.w)) ) } glm/util/autoexp.txt0000644000000000000000000000071612451741412013543 0ustar rootroot[Visualizer] glm::detail::tvec2<*>{ preview ( #(#($c.x,$c.y)) ) children ( #([x]: $c.x,[y]: $c.y) ) } glm::detail::tvec3<*>{ preview ( #($e.x,$e.y,$e.z) ) children ( #([x]: $e.x,[y]: $e.y,[z]: $e.z) ) } glm::detail::tvec4<*>{ preview ( #($c.x,$c.y,$c.z,$c.w) ) children ( #([x]: $e.x,[y]: $e.y,[z]: $e.z, #([w]: $e.w)) ) } glm/test/0000755000000000000000000000000012642261102011306 5ustar rootrootglm/test/gtx/0000755000000000000000000000000012642261104012112 5ustar rootrootglm/test/gtx/gtx_wrap.cpp0000644000000000000000000001167312543554314014471 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_normal.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include namespace clamp { int test() { int Error(0); float A = glm::clamp(0.5f); Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1; float B = glm::clamp(0.0f); Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1; float C = glm::clamp(1.0f); Error += glm::epsilonEqual(C, 1.0f, 0.00001f) ? 0 : 1; float D = glm::clamp(-0.5f); Error += glm::epsilonEqual(D, 0.0f, 0.00001f) ? 0 : 1; float E = glm::clamp(1.5f); Error += glm::epsilonEqual(E, 1.0f, 0.00001f) ? 0 : 1; return Error; } }//namespace clamp namespace repeat { int test() { int Error(0); float A = glm::repeat(0.5f); Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1; float B = glm::repeat(0.0f); Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1; float C = glm::repeat(1.0f); Error += glm::epsilonEqual(C, 0.0f, 0.00001f) ? 0 : 1; float D = glm::repeat(-0.5f); Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1; float E = glm::repeat(1.5f); Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1; float F = glm::repeat(0.9f); Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1; return Error; } }//namespace repeat namespace mirrorClamp { int test() { int Error(0); float A = glm::mirrorClamp(0.5f); Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1; float B = glm::mirrorClamp(0.0f); Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1; float C = glm::mirrorClamp(1.1f); Error += glm::epsilonEqual(C, 0.1f, 0.00001f) ? 0 : 1; float D = glm::mirrorClamp(-0.5f); Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1; float E = glm::mirrorClamp(1.5f); Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1; float F = glm::mirrorClamp(0.9f); Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1; float G = glm::mirrorClamp(3.1f); Error += glm::epsilonEqual(G, 0.1f, 0.00001f) ? 0 : 1; float H = glm::mirrorClamp(-3.1f); Error += glm::epsilonEqual(H, 0.1f, 0.00001f) ? 0 : 1; float I = glm::mirrorClamp(-0.9f); Error += glm::epsilonEqual(I, 0.9f, 0.00001f) ? 0 : 1; return Error; } }//namespace mirrorClamp namespace mirrorRepeat { int test() { int Error(0); float A = glm::mirrorRepeat(0.5f); Error += glm::epsilonEqual(A, 0.5f, 0.00001f) ? 0 : 1; float B = glm::mirrorRepeat(0.0f); Error += glm::epsilonEqual(B, 0.0f, 0.00001f) ? 0 : 1; float C = glm::mirrorRepeat(1.0f); Error += glm::epsilonEqual(C, 1.0f, 0.00001f) ? 0 : 1; float D = glm::mirrorRepeat(-0.5f); Error += glm::epsilonEqual(D, 0.5f, 0.00001f) ? 0 : 1; float E = glm::mirrorRepeat(1.5f); Error += glm::epsilonEqual(E, 0.5f, 0.00001f) ? 0 : 1; float F = glm::mirrorRepeat(0.9f); Error += glm::epsilonEqual(F, 0.9f, 0.00001f) ? 0 : 1; float G = glm::mirrorRepeat(3.0f); Error += glm::epsilonEqual(G, 1.0f, 0.00001f) ? 0 : 1; float H = glm::mirrorRepeat(-3.0f); Error += glm::epsilonEqual(H, 1.0f, 0.00001f) ? 0 : 1; float I = glm::mirrorRepeat(-1.0f); Error += glm::epsilonEqual(I, 1.0f, 0.00001f) ? 0 : 1; return Error; } }//namespace mirrorRepeat int main() { int Error(0); Error += clamp::test(); Error += repeat::test(); Error += mirrorClamp::test(); Error += mirrorRepeat::test(); return Error; } glm/test/gtx/gtx_vector_query.cpp0000644000000000000000000000570712605553150016244 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_vector_query.cpp /// @date 2011-11-23 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include int test_areCollinear() { int Error(0); { bool TestA = glm::areCollinear(glm::vec2(-1), glm::vec2(1), 0.00001f); Error += TestA ? 0 : 1; } { bool TestA = glm::areCollinear(glm::vec3(-1), glm::vec3(1), 0.00001f); Error += TestA ? 0 : 1; } { bool TestA = glm::areCollinear(glm::vec4(-1), glm::vec4(1), 0.00001f); Error += TestA ? 0 : 1; } return Error; } int test_areOrthogonal() { int Error(0); bool TestA = glm::areOrthogonal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f); Error += TestA ? 0 : 1; return Error; } int test_isNormalized() { int Error(0); bool TestA = glm::isNormalized(glm::vec4(1, 0, 0, 0), 0.00001f); Error += TestA ? 0 : 1; return Error; } int test_isNull() { int Error(0); bool TestA = glm::isNull(glm::vec4(0), 0.00001f); Error += TestA ? 0 : 1; return Error; } int test_areOrthonormal() { int Error(0); bool TestA = glm::areOrthonormal(glm::vec2(1, 0), glm::vec2(0, 1), 0.00001f); Error += TestA ? 0 : 1; return Error; } int main() { int Error(0); Error += test_areCollinear(); Error += test_areOrthogonal(); Error += test_isNormalized(); Error += test_isNull(); Error += test_areOrthonormal(); return Error; } glm/test/gtx/gtx_vector_angle.cpp0000644000000000000000000000670212470135714016163 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_vector_angle.cpp /// @date 2011-05-15 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include int test_angle() { int Error = 0; float AngleA = glm::angle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1))); Error += glm::epsilonEqual(AngleA, glm::pi() * 0.25f, 0.01f) ? 0 : 1; float AngleB = glm::angle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0))); Error += glm::epsilonEqual(AngleB, glm::pi() * 0.25f, 0.01f) ? 0 : 1; float AngleC = glm::angle(glm::vec4(1, 0, 0, 0), glm::normalize(glm::vec4(1, 1, 0, 0))); Error += glm::epsilonEqual(AngleC, glm::pi() * 0.25f, 0.01f) ? 0 : 1; return Error; } int test_orientedAngle_vec2() { int Error = 0; float AngleA = glm::orientedAngle(glm::vec2(1, 0), glm::normalize(glm::vec2(1, 1))); Error += AngleA == glm::pi() * 0.25f ? 0 : 1; float AngleB = glm::orientedAngle(glm::vec2(0, 1), glm::normalize(glm::vec2(1, 1))); Error += AngleB == -glm::pi() * 0.25f ? 0 : 1; float AngleC = glm::orientedAngle(glm::normalize(glm::vec2(1, 1)), glm::vec2(0, 1)); Error += AngleC == glm::pi() * 0.25f ? 0 : 1; return Error; } int test_orientedAngle_vec3() { int Error = 0; float AngleA = glm::orientedAngle(glm::vec3(1, 0, 0), glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 0, 1)); Error += AngleA == glm::pi() * 0.25f ? 0 : 1; float AngleB = glm::orientedAngle(glm::vec3(0, 1, 0), glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 0, 1)); Error += AngleB == -glm::pi() * 0.25f ? 0 : 1; float AngleC = glm::orientedAngle(glm::normalize(glm::vec3(1, 1, 0)), glm::vec3(0, 1, 0), glm::vec3(0, 0, 1)); Error += AngleC == glm::pi() * 0.25f ? 0 : 1; return Error; } int main() { int Error(0); Error += test_angle(); Error += test_orientedAngle_vec2(); Error += test_orientedAngle_vec3(); return Error; } glm/test/gtx/gtx_type_aligned.cpp0000644000000000000000000000701612571067272016163 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_type_aligned.cpp /// @date 2014-11-23 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int test_decl() { int Error(0); { struct S1 { glm::aligned_vec4 B; }; struct S2 { glm::vec4 B; }; printf("vec4 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } { struct S1 { bool A; glm::vec3 B; }; struct S2 { bool A; glm::aligned_vec3 B; }; printf("vec3 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) <= sizeof(S2) ? 0 : 1; } { struct S1 { bool A; glm::aligned_vec4 B; }; struct S2 { bool A; glm::vec4 B; }; printf("vec4 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } { struct S1 { bool A; glm::aligned_dvec4 B; }; struct S2 { bool A; glm::dvec4 B; }; printf("dvec4 - Aligned: %d, unaligned: %d\n", static_cast(sizeof(S1)), static_cast(sizeof(S2))); Error += sizeof(S1) >= sizeof(S2) ? 0 : 1; } return Error; } template void print(genType const & Mat0) { printf("mat4(\n"); printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[0][0], Mat0[0][1], Mat0[0][2], Mat0[0][3]); printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[1][0], Mat0[1][1], Mat0[1][2], Mat0[1][3]); printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f)\n", Mat0[2][0], Mat0[2][1], Mat0[2][2], Mat0[2][3]); printf("\tvec4(%2.9f, %2.9f, %2.9f, %2.9f))\n\n", Mat0[3][0], Mat0[3][1], Mat0[3][2], Mat0[3][3]); } int perf_mul() { int Error = 0; glm::mat4 A(1.0f); glm::mat4 B(1.0f); glm::mat4 C = A * B; print(C); return Error; } int main() { int Error(0); Error += test_decl(); Error += perf_mul(); return Error; } glm/test/gtx/gtx_string_cast.cpp0000644000000000000000000001175612571125236016040 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_string_cast.cpp /// @date 2011-09-01 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include int test_string_cast_vector() { int Error = 0; { glm::vec2 A1(1, 2); std::string A2 = glm::to_string(A1); Error += A2 != std::string("vec2(1.000000, 2.000000)") ? 1 : 0; glm::vec3 B1(1, 2, 3); std::string B2 = glm::to_string(B1); Error += B2 != std::string("vec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::vec4 C1(1, 2, 3, 4); std::string C2 = glm::to_string(C1); Error += C2 != std::string("vec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; glm::dvec2 J1(1, 2); std::string J2 = glm::to_string(J1); Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0; glm::dvec3 K1(1, 2, 3); std::string K2 = glm::to_string(K1); Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::dvec4 L1(1, 2, 3, 4); std::string L2 = glm::to_string(L1); Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; } { glm::bvec2 M1(false, true); std::string M2 = glm::to_string(M1); Error += M2 != std::string("bvec2(false, true)") ? 1 : 0; glm::bvec3 O1(false, true, false); std::string O2 = glm::to_string(O1); Error += O2 != std::string("bvec3(false, true, false)") ? 1 : 0; glm::bvec4 P1(false, true, false, true); std::string P2 = glm::to_string(P1); Error += P2 != std::string("bvec4(false, true, false, true)") ? 1 : 0; } { glm::ivec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0; glm::ivec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0; glm::ivec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0; } { glm::i8vec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("i8vec2(1, 2)") ? 1 : 0; glm::i8vec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("i8vec3(1, 2, 3)") ? 1 : 0; glm::i8vec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("i8vec4(1, 2, 3, 4)") ? 1 : 0; } { glm::i16vec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("i16vec2(1, 2)") ? 1 : 0; glm::i16vec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("i16vec3(1, 2, 3)") ? 1 : 0; glm::i16vec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("i16vec4(1, 2, 3, 4)") ? 1 : 0; } { glm::i64vec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("i64vec2(1, 2)") ? 1 : 0; glm::i64vec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("i64vec3(1, 2, 3)") ? 1 : 0; glm::i64vec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("i64vec4(1, 2, 3, 4)") ? 1 : 0; } return Error; } int test_string_cast_matrix() { int Error = 0; glm::mat2x2 A1(1.000000, 2.000000, 3.000000, 4.000000); std::string A2 = glm::to_string(A1); Error += A2 != std::string("mat2x2((1.000000, 2.000000), (3.000000, 4.000000))") ? 1 : 0; return Error; } int main() { int Error = 0; Error += test_string_cast_vector(); Error += test_string_cast_matrix(); return Error; } glm/test/gtx/gtx_spline.cpp0000644000000000000000000000730412470135714015004 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_spline.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include namespace catmullRom { int test() { int Error(0); glm::vec2 Result2 = glm::catmullRom( glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f), glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f), 0.5f); glm::vec3 Result3 = glm::catmullRom( glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), 0.5f); glm::vec4 Result4 = glm::catmullRom( glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f); return Error; } }//catmullRom namespace hermite { int test() { int Error(0); glm::vec2 Result2 = glm::hermite( glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f), glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f), 0.5f); glm::vec3 Result3 = glm::hermite( glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), 0.5f); glm::vec4 Result4 = glm::hermite( glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f); return Error; } }//catmullRom namespace cubic { int test() { int Error(0); glm::vec2 Result2 = glm::cubic( glm::vec2(0.0f, 0.0f), glm::vec2(1.0f, 0.0f), glm::vec2(1.0f, 1.0f), glm::vec2(0.0f, 1.0f), 0.5f); glm::vec3 Result3 = glm::cubic( glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), 0.5f); glm::vec4 Result = glm::cubic( glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(1.0f, 0.0f, 0.0f, 1.0f), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.5f); return Error; } }//catmullRom int main() { int Error(0); Error += catmullRom::test(); Error += hermite::test(); Error += cubic::test(); return Error; } glm/test/gtx/gtx_simd_vec4.cpp0000644000000000000000000000523312642261004015357 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_simd_vec4.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #if(GLM_ARCH != GLM_ARCH_PURE) int main() { #ifdef GLM_META_PROG_HELPERS assert(glm::simdVec4::components == glm::simdVec4::pure_type::components); #endif glm::simdVec4 A1(0.0f, 0.1f, 0.2f, 0.3f); glm::simdVec4 B1(0.4f, 0.5f, 0.6f, 0.7f); glm::simdVec4 C1 = A1 + B1; glm::simdVec4 D1 = A1.swizzle(); glm::simdVec4 E1(glm::vec4(1.0f)); glm::vec4 F1 = glm::vec4_cast(E1); //glm::vec4 G1(E1); //printf("A1(%2.3f, %2.3f, %2.3f, %2.3f)\n", A1.x, A1.y, A1.z, A1.w); //printf("B1(%2.3f, %2.3f, %2.3f, %2.3f)\n", B1.x, B1.y, B1.z, B1.w); //printf("C1(%2.3f, %2.3f, %2.3f, %2.3f)\n", C1.x, C1.y, C1.z, C1.w); //printf("D1(%2.3f, %2.3f, %2.3f, %2.3f)\n", D1.x, D1.y, D1.z, D1.w); __m128 value = _mm_set1_ps(0.0f); __m128 data = _mm_cmpeq_ps(value, value); __m128 add0 = _mm_add_ps(data, data); glm::simdVec4 GNI(add0); return 0; } #else int main() { int Error = 0; return Error; } #endif//(GLM_ARCH != GLM_ARCH_PURE) glm/test/gtx/gtx_simd_mat4.cpp0000644000000000000000000002302712642261004015364 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_simd_mat4.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #if(GLM_ARCH != GLM_ARCH_PURE) std::vector test_detA(std::vector const & Data) { std::vector Test(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Test.size() - 1; ++i) Test[i] = glm::determinant(Data[i]); std::clock_t TimeEnd = clock(); printf("Det A: %ld\n", TimeEnd - TimeStart); return Test; } std::vector test_detB(std::vector const & Data) { std::vector Test(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Test.size() - 1; ++i) { _mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0); glm::simdMat4 m(Data[i]); glm::simdVec4 d(glm::detail::sse_slow_det_ps((__m128 const * const)&m)); glm::vec4 v;//(d); Test[i] = v.x; } std::clock_t TimeEnd = clock(); printf("Det B: %ld\n", TimeEnd - TimeStart); return Test; } std::vector test_detC(std::vector const & Data) { std::vector Test(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Test.size() - 1; ++i) { _mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0); glm::simdMat4 m(Data[i]); glm::simdVec4 d(glm::detail::sse_det_ps((__m128 const * const)&m)); glm::vec4 v;//(d); Test[i] = v.x; } std::clock_t TimeEnd = clock(); printf("Det C: %ld\n", TimeEnd - TimeStart); return Test; } std::vector test_detD(std::vector const & Data) { std::vector Test(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Test.size() - 1; ++i) { _mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0); glm::simdMat4 m(Data[i]); glm::simdVec4 d(glm::detail::sse_detd_ps((__m128 const * const)&m)); glm::vec4 v;//(d); Test[i] = v.x; } std::clock_t TimeEnd = clock(); printf("Det D: %ld\n", TimeEnd - TimeStart); return Test; } void test_invA(std::vector const & Data, std::vector & Out) { //std::vector Test(Data.size()); Out.resize(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Out.size() - 1; ++i) { Out[i] = glm::inverse(Data[i]); } std::clock_t TimeEnd = clock(); printf("Inv A: %ld\n", TimeEnd - TimeStart); } void test_invC(std::vector const & Data, std::vector & Out) { //std::vector Test(Data.size()); Out.resize(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Out.size() - 1; ++i) { _mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0); glm::simdMat4 m(Data[i]); glm::simdMat4 o; glm::detail::sse_inverse_fast_ps((__m128 const * const)&m, (__m128 *)&o); Out[i] = *(glm::mat4*)&o; } std::clock_t TimeEnd = clock(); printf("Inv C: %ld\n", TimeEnd - TimeStart); } void test_invD(std::vector const & Data, std::vector & Out) { //std::vector Test(Data.size()); Out.resize(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Out.size() - 1; ++i) { _mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0); glm::simdMat4 m(Data[i]); glm::simdMat4 o; glm::detail::sse_inverse_ps((__m128 const * const)&m, (__m128 *)&o); Out[i] = *(glm::mat4*)&o; } std::clock_t TimeEnd = clock(); printf("Inv D: %ld\n", TimeEnd - TimeStart); } void test_mulA(std::vector const & Data, std::vector & Out) { //std::vector Test(Data.size()); Out.resize(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Out.size() - 1; ++i) { Out[i] = Data[i] * Data[i]; } std::clock_t TimeEnd = clock(); printf("Mul A: %ld\n", TimeEnd - TimeStart); } void test_mulD(std::vector const & Data, std::vector & Out) { //std::vector Test(Data.size()); Out.resize(Data.size()); std::clock_t TimeStart = clock(); for(std::size_t i = 0; i < Out.size() - 1; ++i) { _mm_prefetch((char*)&Data[i + 1], _MM_HINT_T0); glm::simdMat4 m(Data[i]); glm::simdMat4 o; glm::detail::sse_mul_ps((__m128 const * const)&m, (__m128 const * const)&m, (__m128*)&o); Out[i] = *(glm::mat4*)&o; } std::clock_t TimeEnd = clock(); printf("Mul D: %ld\n", TimeEnd - TimeStart); } int test_compute_glm() { return 0; } int test_compute_gtx() { std::vector Output(1000000); std::clock_t TimeStart = clock(); for(std::size_t k = 0; k < Output.size(); ++k) { float i = float(k) / 1000.f + 0.001f; glm::vec3 A = glm::normalize(glm::vec3(i)); glm::vec3 B = glm::cross(A, glm::normalize(glm::vec3(1, 1, 2))); glm::mat4 C = glm::rotate(glm::mat4(1.0f), i, B); glm::mat4 D = glm::scale(C, glm::vec3(0.8f, 1.0f, 1.2f)); glm::mat4 E = glm::translate(D, glm::vec3(1.4f, 1.2f, 1.1f)); glm::mat4 F = glm::perspective(i, 1.5f, 0.1f, 1000.f); glm::mat4 G = glm::inverse(F * E); glm::vec3 H = glm::unProject(glm::vec3(i), G, F, E[3]); glm::vec3 I = glm::any(glm::isnan(glm::project(H, G, F, E[3]))) ? glm::vec3(2) : glm::vec3(1); glm::mat4 J = glm::lookAt(glm::normalize(glm::max(B, glm::vec3(0.001f))), H, I); glm::mat4 K = glm::transpose(J); glm::quat L = glm::normalize(glm::quat_cast(K)); glm::vec4 M = L * glm::smoothstep(K[3], J[3], glm::vec4(i)); glm::mat4 N = glm::mat4(glm::normalize(glm::max(M, glm::vec4(0.001f))), K[3], J[3], glm::vec4(i)); glm::mat4 O = N * glm::inverse(N); glm::vec4 P = O * glm::reflect(N[3], glm::vec4(A, 1.0f)); glm::vec4 Q = glm::vec4(glm::dot(M, P)); glm::vec4 R = glm::quat(Q.w, glm::vec3(Q)) * P; Output[k] = R; } std::clock_t TimeEnd = clock(); printf("test_compute_gtx: %ld\n", TimeEnd - TimeStart); return 0; } int main() { int Error = 0; #ifdef GLM_META_PROG_HELPERS assert(glm::simdMat4::rows == glm::simdMat4::row_type::components); assert(glm::simdMat4::cols == glm::simdMat4::col_type::components); assert(glm::simdMat4::components == glm::simdMat4::pure_type::components); assert(glm::simdMat4::rows == glm::simdMat4::pure_row_type::components); assert(glm::simdMat4::cols == glm::simdMat4::pure_col_type::components); #endif std::vector Data(64 * 64 * 1); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = glm::mat4( glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))), glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))), glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f))), glm::vec4(glm::linearRand(glm::vec4(-2.0f), glm::vec4(2.0f)))); { std::vector TestInvA; test_invA(Data, TestInvA); } { std::vector TestInvC; test_invC(Data, TestInvC); } { std::vector TestInvD; test_invD(Data, TestInvD); } { std::vector TestA; test_mulA(Data, TestA); } { std::vector TestD; test_mulD(Data, TestD); } { std::vector TestDetA = test_detA(Data); std::vector TestDetB = test_detB(Data); std::vector TestDetD = test_detD(Data); std::vector TestDetC = test_detC(Data); for(std::size_t i = 0; i < TestDetA.size(); ++i) if(TestDetA[i] != TestDetB[i] && TestDetC[i] != TestDetB[i] && TestDetC[i] != TestDetD[i]) return 1; } // shuffle test glm::simdVec4 A(1.0f, 2.0f, 3.0f, 4.0f); glm::simdVec4 B(5.0f, 6.0f, 7.0f, 8.0f); //__m128 C = _mm_shuffle_ps(A.Data, B.Data, _MM_SHUFFLE(1, 0, 1, 0)); Error += test_compute_glm(); Error += test_compute_gtx(); float Det = glm::determinant(glm::simdMat4(1.0)); Error += Det == 1.0f ? 0 : 1; glm::simdMat4 D = glm::matrixCompMult(glm::simdMat4(1.0), glm::simdMat4(1.0)); return Error; } #else int main() { int Error = 0; return Error; } #endif//(GLM_ARCH != GLM_ARCH_PURE) glm/test/gtx/gtx_scalar_relational.cpp0000644000000000000000000001372312470135714017173 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_scalar_relational.cpp /// @date 2013-02-04 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include int test_lessThan() { int Error(0); Error += glm::lessThan(0, 1) ? 0 : 1; Error += glm::lessThan(1, 0) ? 1 : 0; Error += glm::lessThan(0, 0) ? 1 : 0; Error += glm::lessThan(1, 1) ? 1 : 0; Error += glm::lessThan(0.0f, 1.0f) ? 0 : 1; Error += glm::lessThan(1.0f, 0.0f) ? 1 : 0; Error += glm::lessThan(0.0f, 0.0f) ? 1 : 0; Error += glm::lessThan(1.0f, 1.0f) ? 1 : 0; Error += glm::lessThan(0.0, 1.0) ? 0 : 1; Error += glm::lessThan(1.0, 0.0) ? 1 : 0; Error += glm::lessThan(0.0, 0.0) ? 1 : 0; Error += glm::lessThan(1.0, 1.0) ? 1 : 0; return Error; } int test_lessThanEqual() { int Error(0); Error += glm::lessThanEqual(0, 1) ? 0 : 1; Error += glm::lessThanEqual(1, 0) ? 1 : 0; Error += glm::lessThanEqual(0, 0) ? 0 : 1; Error += glm::lessThanEqual(1, 1) ? 0 : 1; Error += glm::lessThanEqual(0.0f, 1.0f) ? 0 : 1; Error += glm::lessThanEqual(1.0f, 0.0f) ? 1 : 0; Error += glm::lessThanEqual(0.0f, 0.0f) ? 0 : 1; Error += glm::lessThanEqual(1.0f, 1.0f) ? 0 : 1; Error += glm::lessThanEqual(0.0, 1.0) ? 0 : 1; Error += glm::lessThanEqual(1.0, 0.0) ? 1 : 0; Error += glm::lessThanEqual(0.0, 0.0) ? 0 : 1; Error += glm::lessThanEqual(1.0, 1.0) ? 0 : 1; return Error; } int test_greaterThan() { int Error(0); Error += glm::greaterThan(0, 1) ? 1 : 0; Error += glm::greaterThan(1, 0) ? 0 : 1; Error += glm::greaterThan(0, 0) ? 1 : 0; Error += glm::greaterThan(1, 1) ? 1 : 0; Error += glm::greaterThan(0.0f, 1.0f) ? 1 : 0; Error += glm::greaterThan(1.0f, 0.0f) ? 0 : 1; Error += glm::greaterThan(0.0f, 0.0f) ? 1 : 0; Error += glm::greaterThan(1.0f, 1.0f) ? 1 : 0; Error += glm::greaterThan(0.0, 1.0) ? 1 : 0; Error += glm::greaterThan(1.0, 0.0) ? 0 : 1; Error += glm::greaterThan(0.0, 0.0) ? 1 : 0; Error += glm::greaterThan(1.0, 1.0) ? 1 : 0; return Error; } int test_greaterThanEqual() { int Error(0); Error += glm::greaterThanEqual(0, 1) ? 1 : 0; Error += glm::greaterThanEqual(1, 0) ? 0 : 1; Error += glm::greaterThanEqual(0, 0) ? 0 : 1; Error += glm::greaterThanEqual(1, 1) ? 0 : 1; Error += glm::greaterThanEqual(0.0f, 1.0f) ? 1 : 0; Error += glm::greaterThanEqual(1.0f, 0.0f) ? 0 : 1; Error += glm::greaterThanEqual(0.0f, 0.0f) ? 0 : 1; Error += glm::greaterThanEqual(1.0f, 1.0f) ? 0 : 1; Error += glm::greaterThanEqual(0.0, 1.0) ? 1 : 0; Error += glm::greaterThanEqual(1.0, 0.0) ? 0 : 1; Error += glm::greaterThanEqual(0.0, 0.0) ? 0 : 1; Error += glm::greaterThanEqual(1.0, 1.0) ? 0 : 1; return Error; } int test_equal() { int Error(0); Error += glm::equal(0, 1) ? 1 : 0; Error += glm::equal(1, 0) ? 1 : 0; Error += glm::equal(0, 0) ? 0 : 1; Error += glm::equal(1, 1) ? 0 : 1; Error += glm::equal(0.0f, 1.0f) ? 1 : 0; Error += glm::equal(1.0f, 0.0f) ? 1 : 0; Error += glm::equal(0.0f, 0.0f) ? 0 : 1; Error += glm::equal(1.0f, 1.0f) ? 0 : 1; Error += glm::equal(0.0, 1.0) ? 1 : 0; Error += glm::equal(1.0, 0.0) ? 1 : 0; Error += glm::equal(0.0, 0.0) ? 0 : 1; Error += glm::equal(1.0, 1.0) ? 0 : 1; return Error; } int test_notEqual() { int Error(0); Error += glm::notEqual(0, 1) ? 0 : 1; Error += glm::notEqual(1, 0) ? 0 : 1; Error += glm::notEqual(0, 0) ? 1 : 0; Error += glm::notEqual(1, 1) ? 1 : 0; Error += glm::notEqual(0.0f, 1.0f) ? 0 : 1; Error += glm::notEqual(1.0f, 0.0f) ? 0 : 1; Error += glm::notEqual(0.0f, 0.0f) ? 1 : 0; Error += glm::notEqual(1.0f, 1.0f) ? 1 : 0; Error += glm::notEqual(0.0, 1.0) ? 0 : 1; Error += glm::notEqual(1.0, 0.0) ? 0 : 1; Error += glm::notEqual(0.0, 0.0) ? 1 : 0; Error += glm::notEqual(1.0, 1.0) ? 1 : 0; return Error; } int test_any() { int Error(0); Error += glm::any(true) ? 0 : 1; Error += glm::any(false) ? 1 : 0; return Error; } int test_all() { int Error(0); Error += glm::all(true) ? 0 : 1; Error += glm::all(false) ? 1 : 0; return Error; } int test_not() { int Error(0); Error += glm::not_(true) ? 1 : 0; Error += glm::not_(false) ? 0 : 1; return Error; } int main() { int Error = 0; Error += test_lessThan(); Error += test_lessThanEqual(); Error += test_greaterThan(); Error += test_greaterThanEqual(); Error += test_equal(); Error += test_notEqual(); Error += test_any(); Error += test_all(); Error += test_not(); return Error; } glm/test/gtx/gtx_scalar_multiplication.cpp0000644000000000000000000000455712470135714020103 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_scalar_multiplication.cpp /// @date 2014-09-22 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #if GLM_HAS_TEMPLATE_ALIASES & !(GLM_COMPILER & GLM_COMPILER_GCC) #include int main() { int Error(0); glm::vec3 v(0.5, 3.1, -9.1); Error += glm::all(glm::equal(v, 1.0 * v)) ? 0 : 1; Error += glm::all(glm::equal(v, 1 * v)) ? 0 : 1; Error += glm::all(glm::equal(v, 1u * v)) ? 0 : 1; glm::mat3 m(1, 2, 3, 4, 5, 6, 7, 8, 9); glm::vec3 w = 0.5f * m * v; Error += glm::all(glm::equal((m*v)/2, w)) ? 0 : 1; Error += glm::all(glm::equal(m*(v/2), w)) ? 0 : 1; Error += glm::all(glm::equal((m/2)*v, w)) ? 0 : 1; Error += glm::all(glm::equal((0.5*m)*v, w)) ? 0 : 1; Error += glm::all(glm::equal(0.5*(m*v), w)) ? 0 : 1; return Error; } #else int main() { return 0; } #endif glm/test/gtx/gtx_rotate_vector.cpp0000644000000000000000000000677212470135714016402 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_rotate_vector.cpp /// @date 2011-05-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int test_rotate() { int Error = 0; glm::vec2 A = glm::rotate(glm::vec2(1, 0), glm::pi() * 0.5f); glm::vec3 B = glm::rotate(glm::vec3(1, 0, 0), glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::vec4 C = glm::rotate(glm::vec4(1, 0, 0, 1), glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::vec3 D = glm::rotateX(glm::vec3(1, 0, 0), glm::pi() * 0.5f); glm::vec4 E = glm::rotateX(glm::vec4(1, 0, 0, 1), glm::pi() * 0.5f); glm::vec3 F = glm::rotateY(glm::vec3(1, 0, 0), glm::pi() * 0.5f); glm::vec4 G = glm::rotateY(glm::vec4(1, 0, 0, 1), glm::pi() * 0.5f); glm::vec3 H = glm::rotateZ(glm::vec3(1, 0, 0), glm::pi() * 0.5f); glm::vec4 I = glm::rotateZ(glm::vec4(1, 0, 0,1 ), glm::pi() * 0.5f); glm::mat4 O = glm::orientation(glm::normalize(glm::vec3(1)), glm::vec3(0, 0, 1)); return Error; } int test_rotateX() { int Error = 0; glm::vec3 D = glm::rotateX(glm::vec3(1, 0, 0), glm::pi() * 0.5f); glm::vec4 E = glm::rotateX(glm::vec4(1, 0, 0, 1), glm::pi() * 0.5f); return Error; } int test_rotateY() { int Error = 0; glm::vec3 F = glm::rotateY(glm::vec3(1, 0, 0), glm::pi() * 0.5f); glm::vec4 G = glm::rotateY(glm::vec4(1, 0, 0, 1), glm::pi() * 0.5f); return Error; } int test_rotateZ() { int Error = 0; glm::vec3 H = glm::rotateZ(glm::vec3(1, 0, 0), glm::pi() * 0.5f); glm::vec4 I = glm::rotateZ(glm::vec4(1, 0, 0,1 ), glm::pi() * 0.5f); return Error; } int test_orientation() { int Error = 0; glm::mat4 O = glm::orientation(glm::normalize(glm::vec3(1)), glm::vec3(0, 0, 1)); return Error; } int main() { int Error = 0; Error += test_rotate(); Error += test_rotateX(); Error += test_rotateY(); Error += test_rotateZ(); Error += test_orientation(); return Error; } glm/test/gtx/gtx_rotate_normalized_axis.cpp0000644000000000000000000000331312470135714020254 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_rotate_normalized_axis.cpp /// @date 2012-12-13 / 2012-12-13 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_range.cpp0000644000000000000000000000460612470135714014610 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_range.cpp /// @date 2014-09-19 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #if GLM_HAS_RANGE_FOR #include int testVec() { int Error(0); glm::vec3 v(1, 2, 3); int count = 0; for(float x : v){ count++; } Error += count == 3 ? 0 : 1; for(float& x : v){ x = 0; } Error += glm::all(glm::equal(v, glm::vec3(0, 0, 0))) ? 0 : 1; return Error; } int testMat() { int Error(0); glm::mat4x3 m(1); int count = 0; for(float x : m){ count++; } Error += count == 12 ? 0 : 1; for(float& x : m){ x = 0; } glm::vec4 v(1, 1, 1, 1); Error += glm::all(glm::equal(m*v, glm::vec3(0, 0, 0))) ? 0 : 1; return Error; } int main() { int Error(0); Error += testVec(); Error += testMat(); return Error; } #else int main() { return 0; } #endif//GLM_HAS_RANGE_FOR glm/test/gtx/gtx_random.cpp0000644000000000000000000000556112451741412014772 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2011-05-31 // Updated : 2011-05-31 // Licence : This source is under MIT licence // File : test/gtx/random.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include int test_signedRand1() { int Error = 0; { float ResultFloat = 0.0f; double ResultDouble = 0.0f; for(std::size_t i = 0; i < 100000; ++i) { ResultFloat += glm::signedRand1(); ResultDouble += glm::signedRand1(); } Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f); Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001); } return Error; } int test_normalizedRand2() { int Error = 0; { std::size_t Max = 100000; float ResultFloat = 0.0f; double ResultDouble = 0.0f; for(std::size_t i = 0; i < Max; ++i) { ResultFloat += glm::length(glm::normalizedRand2()); ResultDouble += glm::length(glm::normalizedRand2()); } Error += glm::equalEpsilon(ResultFloat, float(Max), 0.000001f) ? 0 : 1; Error += glm::equalEpsilon(ResultDouble, double(Max), 0.000001) ? 0 : 1; assert(!Error); } return Error; } int test_normalizedRand3() { int Error = 0; { std::size_t Max = 100000; float ResultFloatA = 0.0f; float ResultFloatB = 0.0f; float ResultFloatC = 0.0f; double ResultDoubleA = 0.0f; double ResultDoubleB = 0.0f; double ResultDoubleC = 0.0f; for(std::size_t i = 0; i < Max; ++i) { ResultFloatA += glm::length(glm::normalizedRand3()); ResultDoubleA += glm::length(glm::normalizedRand3()); ResultFloatB += glm::length(glm::normalizedRand3(2.0f, 2.0f)); ResultDoubleB += glm::length(glm::normalizedRand3(2.0, 2.0)); ResultFloatC += glm::length(glm::normalizedRand3(1.0f, 3.0f)); ResultDoubleC += glm::length(glm::normalizedRand3(1.0, 3.0)); } Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.0001f) ? 0 : 1; Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1; Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.0001f) ? 0 : 1; Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1; Error += (ResultFloatC >= float(Max) && ResultFloatC <= float(Max * 3)) ? 0 : 1; Error += (ResultDoubleC >= double(Max) && ResultDoubleC <= double(Max * 3)) ? 0 : 1; } return Error; } int main() { int Error = 0; Error += test_signedRand1(); Error += test_normalizedRand2(); Error += test_normalizedRand3(); return Error; } glm/test/gtx/gtx_quaternion.cpp0000644000000000000000000000741012470135714015675 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_quaternion.cpp /// @date 2011-05-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include int test_quat_fastMix() { int Error = 0; glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); glm::quat B = glm::angleAxis(glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::quat C = glm::fastMix(A, B, 0.5f); glm::quat D = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 1)); Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1; return Error; } int test_quat_shortMix() { int Error(0); glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); glm::quat B = glm::angleAxis(glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::quat C = glm::shortMix(A, B, 0.5f); glm::quat D = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 1)); Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1; return Error; } int test_orientation() { int Error(0); { glm::quat q(1.0f, 0.0f, 0.0f, 1.0f); float p = glm::roll(q); } { glm::quat q(1.0f, 0.0f, 0.0f, 1.0f); float p = glm::pitch(q); } { glm::quat q(1.0f, 0.0f, 0.0f, 1.0f); float p = glm::yaw(q); } return Error; } int test_rotation() { int Error(0); glm::vec3 v(1, 0, 0); glm::vec3 u(0, 1, 0); glm::quat Rotation = glm::rotation(v, u); float Angle = glm::angle(Rotation); Error += glm::abs(Angle - glm::pi() * 0.5f) < glm::epsilon() ? 0 : 1; return Error; } int test_log() { int Error(0); glm::quat q; glm::quat p = glm::log(q); glm::quat r = glm::exp(p); return Error; } int main() { int Error(0); Error += test_log(); Error += test_rotation(); Error += test_quat_fastMix(); Error += test_quat_shortMix(); return Error; } glm/test/gtx/gtx_projection.cpp0000644000000000000000000000326312470135714015666 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_projection.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_polar_coordinates.cpp0000644000000000000000000000330112470135714017212 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_polar_coordinates.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_perpendicular.cpp0000644000000000000000000000327112470135714016346 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_perpendicular.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_orthonormalize.cpp0000644000000000000000000000327312470135714016567 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_orthonormalize.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_optimum_pow.cpp0000644000000000000000000000326512470135714016073 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_optimum_pow.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_number_precision.cpp0000644000000000000000000000327712470135714017062 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_number_precision.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_normalize_dot.cpp0000644000000000000000000000327112470135714016357 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_normalize_dot.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_normal.cpp0000644000000000000000000000325312470135714015001 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_normal.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_norm.cpp0000644000000000000000000000324712470135714014467 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_norm.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_mixed_product.cpp0000644000000000000000000000123212470135714016352 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2013-10-25 // Updated : 2013-10-25 // Licence : This source is under MIT licence // File : test/gtx/associated_min_max.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_matrix_transform_2d.cpp0000644000000000000000000000330512470135714017473 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_matrix_transform_2d.cpp /// @date 2014-02-21 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_matrix_query.cpp0000644000000000000000000000511512470135714016241 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_matrix_query.cpp /// @date 2011-11-22 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int test_isNull() { int Error(0); bool TestA = glm::isNull(glm::mat4(0), 0.00001f); Error += TestA ? 0 : 1; return Error; } int test_isIdentity() { int Error(0); { bool TestA = glm::isIdentity(glm::mat2(1), 0.00001f); Error += TestA ? 0 : 1; } { bool TestA = glm::isIdentity(glm::mat3(1), 0.00001f); Error += TestA ? 0 : 1; } { bool TestA = glm::isIdentity(glm::mat4(1), 0.00001f); Error += TestA ? 0 : 1; } return Error; } int test_isNormalized() { int Error(0); bool TestA = glm::isNormalized(glm::mat4(1), 0.00001f); Error += TestA ? 0 : 1; return Error; } int test_isOrthogonal() { int Error(0); bool TestA = glm::isOrthogonal(glm::mat4(1), 0.00001f); Error += TestA ? 0 : 1; return Error; } int main() { int Error(0); Error += test_isNull(); Error += test_isIdentity(); Error += test_isNormalized(); Error += test_isOrthogonal(); return Error; } glm/test/gtx/gtx_matrix_operation.cpp0000644000000000000000000000327712470135714017103 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_matrix_operation.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_matrix_major_storage.cpp0000644000000000000000000000330712470135714017731 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_matrix_major_storage.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_matrix_interpolation.cpp0000644000000000000000000000331312470135714017761 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_matrix_interpolation.cpp /// @date 2012-09-19 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_matrix_decompose.cpp0000644000000000000000000000363512557101472017057 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_decomposition.cpp /// @date 2014-08-31 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); glm::mat4 Matrix(1); glm::vec3 Scale; glm::quat Orientation; glm::vec3 Translation; glm::vec3 Skew(1); glm::vec4 Perspective(1); glm::decompose(Matrix, Scale, Orientation, Translation, Skew, Perspective); return Error; } glm/test/gtx/gtx_matrix_cross_product.cpp0000644000000000000000000000330712470135714017766 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_matrix_cross_product.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_log_base.cpp0000644000000000000000000000545612642253134015271 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_log_base.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include namespace test_log { int run() { int Error = 0; { float A = glm::log(10.f, 2.0f); float B = glm::log2(10.f); Error += glm::epsilonEqual(A, B, 0.00001f) ? 0 : 1; } { glm::vec1 A = glm::log(glm::vec1(10.f), glm::vec1(2.0f)); glm::vec1 B = glm::log2(glm::vec1(10.f)); Error += glm::all(glm::epsilonEqual(A, B, glm::vec1(0.00001f))) ? 0 : 1; } { glm::vec2 A = glm::log(glm::vec2(10.f), glm::vec2(2.0f)); glm::vec2 B = glm::log2(glm::vec2(10.f)); Error += glm::all(glm::epsilonEqual(A, B, glm::vec2(0.00001f))) ? 0 : 1; } { glm::vec3 A = glm::log(glm::vec3(10.f), glm::vec3(2.0f)); glm::vec3 B = glm::log2(glm::vec3(10.f)); Error += glm::all(glm::epsilonEqual(A, B, glm::vec3(0.00001f))) ? 0 : 1; } { glm::vec4 A = glm::log(glm::vec4(10.f), glm::vec4(2.0f)); glm::vec4 B = glm::log2(glm::vec4(10.f)); Error += glm::all(glm::epsilonEqual(A, B, glm::vec4(0.00001f))) ? 0 : 1; } return Error; } }//namespace test_log int main() { int Error(0); Error += test_log::run(); return Error; } glm/test/gtx/gtx_io.cpp0000644000000000000000000002212712470135714014121 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_io.cpp /// @date 2013-11-22 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include namespace { template std::basic_ostream& operator<<(std::basic_ostream& os, glm::precision const& a) { typename std::basic_ostream::sentry const cerberus(os); if (cerberus) { switch (a) { case glm::highp: os << "hi"; break; case glm::mediump: os << "md"; break; case glm::lowp: os << "lo"; break; } } return os; } template std::basic_string type_name(std::basic_ostream& os, T const&) { std::basic_ostringstream ostr; if (typeid(T) == typeid(glm::tquat)) { ostr << "quat"; } else if (typeid(T) == typeid(glm::tvec2)) { ostr << "vec2"; } else if (typeid(T) == typeid(glm::tvec3)) { ostr << "vec3"; } else if (typeid(T) == typeid(glm::tvec4)) { ostr << "vec4"; } else if (typeid(T) == typeid(glm::tmat2x2)) { ostr << "mat2x2"; } else if (typeid(T) == typeid(glm::tmat2x3)) { ostr << "mat2x3"; } else if (typeid(T) == typeid(glm::tmat2x4)) { ostr << "mat2x4"; } else if (typeid(T) == typeid(glm::tmat3x2)) { ostr << "mat3x2"; } else if (typeid(T) == typeid(glm::tmat3x3)) { ostr << "mat3x3"; } else if (typeid(T) == typeid(glm::tmat3x4)) { ostr << "mat3x4"; } else if (typeid(T) == typeid(glm::tmat4x2)) { ostr << "mat4x2"; } else if (typeid(T) == typeid(glm::tmat4x3)) { ostr << "mat4x3"; } else if (typeid(T) == typeid(glm::tmat4x4)) { ostr << "mat4x4"; } else { ostr << "unknown"; } ostr << '<' << typeid(U).name() << ',' << P << '>'; return ostr.str(); } } // namespace { template int test_io_quat(OS& os) { os << '\n' << typeid(OS).name() << '\n'; glm::tquat const q(1, 0, 0, 0); { glm::io::basic_format_saver const iofs(os); os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) << type_name(os, q) << ": " << q << '\n'; } { glm::io::basic_format_saver const iofs(os); os << glm::io::unformatted << type_name(os, q) << ": " << q << '\n'; } return 0; } template int test_io_vec(OS& os) { os << '\n' << typeid(OS).name() << '\n'; glm::tvec2 const v2(0, 1); glm::tvec3 const v3(2, 3, 4); glm::tvec4 const v4(5, 6, 7, 8); os << type_name(os, v2) << ": " << v2 << '\n' << type_name(os, v3) << ": " << v3 << '\n' << type_name(os, v4) << ": " << v4 << '\n'; glm::io::basic_format_saver const iofs(os); os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) << type_name(os, v2) << ": " << v2 << '\n' << type_name(os, v3) << ": " << v3 << '\n' << type_name(os, v4) << ": " << v4 << '\n'; return 0; } template int test_io_mat(OS& os) { os << '\n' << typeid(OS).name() << '\n'; glm::tvec2 const v2_1( 0, 1); glm::tvec2 const v2_2( 2, 3); glm::tvec2 const v2_3( 4, 5); glm::tvec2 const v2_4( 6, 7); glm::tvec3 const v3_1( 8, 9, 10); glm::tvec3 const v3_2(11, 12, 13); glm::tvec3 const v3_3(14, 15, 16); glm::tvec3 const v3_4(17, 18, 19); glm::tvec4 const v4_1(20, 21, 22, 23); glm::tvec4 const v4_2(24, 25, 26, 27); glm::tvec4 const v4_3(28, 29, 30, 31); glm::tvec4 const v4_4(32, 33, 34, 35); #if 0 os << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2(v2_1, v2_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3(v3_1, v3_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4(v4_1, v4_2) << '\n' << "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2(v2_1, v2_2, v2_3) << '\n' << "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3(v3_1, v3_2, v3_3) << '\n' << "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4(v4_1, v4_2, v4_3) << '\n' << "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2(v2_1, v2_2, v2_3, v2_4) << '\n' << "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3(v3_1, v3_2, v3_3, v3_4) << '\n' << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4(v4_1, v4_2, v4_3, v4_4) << '\n'; #endif glm::io::basic_format_saver const iofs(os); os << glm::io::precision(2) << glm::io::width(1 + 2 + 1 + 2) << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2(v2_1, v2_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3(v3_1, v3_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4(v4_1, v4_2) << '\n' << "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2(v2_1, v2_2, v2_3) << '\n' << "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3(v3_1, v3_2, v3_3) << '\n' << "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4(v4_1, v4_2, v4_3) << '\n' << "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2(v2_1, v2_2, v2_3, v2_4) << '\n' << "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3(v3_1, v3_2, v3_3, v3_4) << '\n' << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4(v4_1, v4_2, v4_3, v4_4) << '\n'; os << glm::io::unformatted << glm::io::order(glm::io::column_major) << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x2(v2_1, v2_2) << '\n' << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x3(v3_1, v3_2) << '\n' << "mat2x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat2x4(v4_1, v4_2) << '\n' << "mat3x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x2(v2_1, v2_2, v2_3) << '\n' << "mat3x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x3(v3_1, v3_2, v3_3) << '\n' << "mat3x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat3x4(v4_1, v4_2, v4_3) << '\n' << "mat4x2<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x2(v2_1, v2_2, v2_3, v2_4) << '\n' << "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x3(v3_1, v3_2, v3_3, v3_4) << '\n' << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::tmat4x4(v4_1, v4_2, v4_3, v4_4) << '\n'; return 0; } int main() { int Error(0); Error += test_io_quat(std::cout); Error += test_io_quat(std::wcout); Error += test_io_quat(std::cout); Error += test_io_quat(std::wcout); Error += test_io_quat(std::cout); Error += test_io_quat(std::wcout); Error += test_io_vec(std::cout); Error += test_io_vec(std::wcout); Error += test_io_vec(std::cout); Error += test_io_vec(std::wcout); Error += test_io_vec(std::cout); Error += test_io_vec(std::wcout); Error += test_io_mat(std::cout); Error += test_io_mat(std::wcout); return Error; } glm/test/gtx/gtx_int_10_10_10_2.cpp0000644000000000000000000000123212470135714015617 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2013-10-25 // Updated : 2013-10-25 // Licence : This source is under MIT licence // File : test/gtx/associated_min_max.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_intersect.cpp0000644000000000000000000000326112605553150015506 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_intersect.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_integer.cpp0000644000000000000000000000547212642261004015144 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_integer.cpp /// @date 2011-10-11 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include /* int test_floor_log2() { int Error = 0; for(std::size_t i = 1; i < 1000000; ++i) { glm::uint A = glm::floor_log2(glm::uint(i)); glm::uint B = glm::uint(glm::floor(glm::log2(double(i)))); // Will fail with float, lack of accuracy Error += A == B ? 0 : 1; assert(!Error); } return Error; } */ int test_log2() { int Error = 0; for(std::size_t i = 1; i < 24; ++i) { glm::uint A = glm::log2(glm::uint(1 << i)); glm::uint B = glm::uint(glm::log2(double(1 << i))); //Error += glm::equalEpsilon(double(A), B, 1.0) ? 0 : 1; Error += glm::abs(double(A) - B) <= 24 ? 0 : 1; assert(!Error); printf("Log2(%d) Error: %d, %d\n", 1 << i, A, B); } printf("log2 error: %d\n", Error); return Error; } int test_nlz() { int Error = 0; for(glm::uint i = 1; i < glm::uint(33); ++i) Error += glm::nlz(i) == glm::uint(31u) - glm::findMSB(i) ? 0 : 1; //printf("%d, %d\n", glm::nlz(i), 31u - glm::findMSB(i)); return Error; } int main() { int Error = 0; Error += test_nlz(); // Error += test_floor_log2(); Error += test_log2(); return Error; } glm/test/gtx/gtx_handed_coordinate_space.cpp0000644000000000000000000000331512470135714020315 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_handed_coordinate_space.cpp /// @date 2011-10-13 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_gradient_paint.cpp0000644000000000000000000000423212470135714016477 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_gradient_paint.cpp /// @date 2011-10-13 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int test_radialGradient() { int Error = 0; float Gradient = glm::radialGradient(glm::vec2(0), 1.0f, glm::vec2(1), glm::vec2(0.5)); Error += Gradient != 0.0f ? 0 : 1; return Error; } int test_linearGradient() { int Error = 0; float Gradient = glm::linearGradient(glm::vec2(0), glm::vec2(1), glm::vec2(0.5)); Error += Gradient != 0.0f ? 0 : 1; return Error; } int main() { int Error = 0; Error += test_radialGradient(); Error += test_linearGradient(); return Error; } glm/test/gtx/gtx_fast_trigonometry.cpp0000644000000000000000000004051612573105534017274 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_fast_trigonometry.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include #include #include namespace fastCos { int perf(bool NextFloat) { const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::fastCos(i); const std::clock_t timestamp2 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::cos(i); const std::clock_t timestamp3 = std::clock(); const std::clock_t time_fast = timestamp2 - timestamp1; const std::clock_t time_default = timestamp3 - timestamp2; std::printf("fastCos Time %d clocks\n", static_cast(time_fast)); std::printf("cos Time %d clocks\n", static_cast(time_default)); return time_fast <= time_default ? 0 : 1; } }//namespace fastCos namespace fastSin { /* float sin(float x) { float temp; temp = (x + M_PI) / ((2 * M_PI) - M_PI); return limited_sin((x + M_PI) - ((2 * M_PI) - M_PI) * temp)); } */ int perf(bool NextFloat) { const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::fastSin(i); const std::clock_t timestamp2 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::sin(i); const std::clock_t timestamp3 = std::clock(); const std::clock_t time_fast = timestamp2 - timestamp1; const std::clock_t time_default = timestamp3 - timestamp2; std::printf("fastSin Time %d clocks\n", static_cast(time_fast)); std::printf("sin Time %d clocks\n", static_cast(time_default)); return time_fast <= time_default ? 0 : 1; } }//namespace fastSin namespace fastTan { int perf(bool NextFloat) { const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::fastTan(i); const std::clock_t timestamp2 = std::clock(); for (float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::tan(i); const std::clock_t timestamp3 = std::clock(); const std::clock_t time_fast = timestamp2 - timestamp1; const std::clock_t time_default = timestamp3 - timestamp2; std::printf("fastTan Time %d clocks\n", static_cast(time_fast)); std::printf("tan Time %d clocks\n", static_cast(time_default)); return time_fast <= time_default ? 0 : 1; } }//namespace fastTan namespace fastAcos { int perf(bool NextFloat) { const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::fastAcos(i); const std::clock_t timestamp2 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::acos(i); const std::clock_t timestamp3 = std::clock(); const std::clock_t time_fast = timestamp2 - timestamp1; const std::clock_t time_default = timestamp3 - timestamp2; std::printf("fastAcos Time %d clocks\n", static_cast(time_fast)); std::printf("acos Time %d clocks\n", static_cast(time_default)); return time_fast <= time_default ? 0 : 1; } }//namespace fastAcos namespace fastAsin { int perf(bool NextFloat) { const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::fastAsin(i); const std::clock_t timestamp2 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::asin(i); const std::clock_t timestamp3 = std::clock(); const std::clock_t time_fast = timestamp2 - timestamp1; const std::clock_t time_default = timestamp3 - timestamp2; std::printf("fastAsin Time %d clocks\n", static_cast(time_fast)); std::printf("asin Time %d clocks\n", static_cast(time_default)); return time_fast <= time_default ? 0 : 1; } }//namespace fastAsin namespace fastAtan { int perf(bool NextFloat) { const float begin = -glm::pi(); const float end = glm::pi(); float result = 0.f; const std::clock_t timestamp1 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::fastAtan(i); const std::clock_t timestamp2 = std::clock(); for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f) result = glm::atan(i); const std::clock_t timestamp3 = std::clock(); const std::clock_t time_fast = timestamp2 - timestamp1; const std::clock_t time_default = timestamp3 - timestamp2; std::printf("fastAtan Time %d clocks\n", static_cast(time_fast)); std::printf("atan Time %d clocks\n", static_cast(time_default)); return time_fast <= time_default ? 0 : 1; } }//namespace fastAtan namespace taylorCos { glm::vec4 const AngleShift(0.0f, glm::pi() * 0.5f, glm::pi() * 1.0f, glm::pi() * 1.5f); template class vecType> GLM_FUNC_QUALIFIER vecType taylorSeriesNewCos(vecType const & x) { vecType const Powed2(x * x); vecType const Powed4(Powed2 * Powed2); vecType const Powed6(Powed4 * Powed2); vecType const Powed8(Powed4 * Powed4); return static_cast(1) - Powed2 * static_cast(0.5) + Powed4 * static_cast(0.04166666666666666666666666666667) - Powed6 * static_cast(0.00138888888888888888888888888889) + Powed8 * static_cast(2.4801587301587301587301587301587e-5); } template class vecType> GLM_FUNC_QUALIFIER vecType taylorSeriesNewCos6(vecType const & x) { vecType const Powed2(x * x); vecType const Powed4(Powed2 * Powed2); vecType const Powed6(Powed4 * Powed2); return static_cast(1) - Powed2 * static_cast(0.5) + Powed4 * static_cast(0.04166666666666666666666666666667) - Powed6 * static_cast(0.00138888888888888888888888888889); } template class vecType> GLM_FUNC_QUALIFIER vecType fastAbs(vecType x) { int* Pointer = reinterpret_cast(&x[0]); Pointer[0] &= 0x7fffffff; Pointer[1] &= 0x7fffffff; Pointer[2] &= 0x7fffffff; Pointer[3] &= 0x7fffffff; return x; } template class vecType> GLM_FUNC_QUALIFIER vecType fastCosNew(vecType const & x) { vecType const Angle0_PI(fastAbs(fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); return taylorSeriesNewCos6(x); /* vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi()))); vecType const RevertAngle(mix(vecType(glm::pi()), vecType(0), FirstQuarterPi)); vecType const ReturnSign(mix(vecType(-1), vecType(1), FirstQuarterPi)); vecType const SectionAngle(RevertAngle - Angle0_PI); return ReturnSign * taylorSeriesNewCos(SectionAngle); */ } int perf_fastCosNew(float Begin, float End, std::size_t Samples) { std::vector Results; Results.resize(Samples); float Steps = (End - Begin) / Samples; std::clock_t const TimeStampBegin = std::clock(); for(std::size_t i = 0; i < Samples; ++i) Results[i] = fastCosNew(AngleShift + glm::vec4(Begin + Steps * i)); std::clock_t const TimeStampEnd = std::clock(); std::printf("fastCosNew %ld clocks\n", TimeStampEnd - TimeStampBegin); int Error = 0; for(std::size_t i = 0; i < Samples; ++i) Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1; return Error; } template class vecType> GLM_FUNC_QUALIFIER vecType deterministic_fmod(vecType const & x, T y) { return x - y * trunc(x / y); } template class vecType> GLM_FUNC_QUALIFIER vecType fastCosDeterminisctic(vecType const & x) { vecType const Angle0_PI(abs(deterministic_fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi()))); vecType const RevertAngle(mix(vecType(glm::pi()), vecType(0), FirstQuarterPi)); vecType const ReturnSign(mix(vecType(-1), vecType(1), FirstQuarterPi)); vecType const SectionAngle(RevertAngle - Angle0_PI); return ReturnSign * taylorSeriesNewCos(SectionAngle); } int perf_fastCosDeterminisctic(float Begin, float End, std::size_t Samples) { std::vector Results; Results.resize(Samples); float Steps = (End - Begin) / Samples; std::clock_t const TimeStampBegin = std::clock(); for(std::size_t i = 0; i < Samples; ++i) Results[i] = taylorCos::fastCosDeterminisctic(AngleShift + glm::vec4(Begin + Steps * i)); std::clock_t const TimeStampEnd = std::clock(); std::printf("fastCosDeterminisctic %ld clocks\n", TimeStampEnd - TimeStampBegin); int Error = 0; for(std::size_t i = 0; i < Samples; ++i) Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1; return Error; } template class vecType> GLM_FUNC_QUALIFIER vecType taylorSeriesRefCos(vecType const & x) { return static_cast(1) - (x * x) / glm::factorial(static_cast(2)) + (x * x * x * x) / glm::factorial(static_cast(4)) - (x * x * x * x * x * x) / glm::factorial(static_cast(6)) + (x * x * x * x * x * x * x * x) / glm::factorial(static_cast(8)); } template class vecType> GLM_FUNC_QUALIFIER vecType fastRefCos(vecType const & x) { vecType const Angle0_PI(glm::abs(fmod(x + glm::pi(), glm::two_pi()) - glm::pi())); // return taylorSeriesRefCos(Angle0_PI); vecType const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType(glm::half_pi()))); vecType const RevertAngle(mix(vecType(glm::pi()), vecType(0), FirstQuarterPi)); vecType const ReturnSign(mix(vecType(-1), vecType(1), FirstQuarterPi)); vecType const SectionAngle(RevertAngle - Angle0_PI); return ReturnSign * taylorSeriesRefCos(SectionAngle); } int perf_fastCosRef(float Begin, float End, std::size_t Samples) { std::vector Results; Results.resize(Samples); float Steps = (End - Begin) / Samples; std::clock_t const TimeStampBegin = std::clock(); for(std::size_t i = 0; i < Samples; ++i) Results[i] = taylorCos::fastRefCos(AngleShift + glm::vec4(Begin + Steps * i)); std::clock_t const TimeStampEnd = std::clock(); std::printf("fastCosRef %ld clocks\n", TimeStampEnd - TimeStampBegin); int Error = 0; for(std::size_t i = 0; i < Samples; ++i) Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1; return Error; } int perf_fastCosOld(float Begin, float End, std::size_t Samples) { std::vector Results; Results.resize(Samples); float Steps = (End - Begin) / Samples; std::clock_t const TimeStampBegin = std::clock(); for(std::size_t i = 0; i < Samples; ++i) Results[i] = glm::fastCos(AngleShift + glm::vec4(Begin + Steps * i)); std::clock_t const TimeStampEnd = std::clock(); std::printf("fastCosOld %ld clocks\n", TimeStampEnd - TimeStampBegin); int Error = 0; for(std::size_t i = 0; i < Samples; ++i) Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1; return Error; } int perf_cos(float Begin, float End, std::size_t Samples) { std::vector Results; Results.resize(Samples); float Steps = (End - Begin) / Samples; std::clock_t const TimeStampBegin = std::clock(); for(std::size_t i = 0; i < Samples; ++i) Results[i] = glm::cos(AngleShift + glm::vec4(Begin + Steps * i)); std::clock_t const TimeStampEnd = std::clock(); std::printf("cos %ld clocks\n", TimeStampEnd - TimeStampBegin); int Error = 0; for(std::size_t i = 0; i < Samples; ++i) Error += Results[i].x >= -1.0f && Results[i].x <= 1.0f ? 0 : 1; return Error; } int perf(std::size_t const Samples) { int Error = 0; float const Begin = -glm::pi(); float const End = glm::pi(); Error += perf_cos(Begin, End, Samples); Error += perf_fastCosOld(Begin, End, Samples); Error += perf_fastCosRef(Begin, End, Samples); //Error += perf_fastCosNew(Begin, End, Samples); Error += perf_fastCosDeterminisctic(Begin, End, Samples); return Error; } int test() { int Error = 0; //for(float Angle = -4.0f * glm::pi(); Angle < 4.0f * glm::pi(); Angle += 0.1f) //for(float Angle = -720.0f; Angle < 720.0f; Angle += 0.1f) for(float Angle = 0.0f; Angle < 180.0f; Angle += 0.1f) { float const modAngle = std::fmod(glm::abs(Angle), 360.f); assert(modAngle >= 0.0f && modAngle <= 360.f); float const radAngle = glm::radians(modAngle); float const Cos0 = std::cos(radAngle); float const Cos1 = taylorCos::fastRefCos(glm::fvec1(radAngle)).x; Error += glm::abs(Cos1 - Cos0) < 0.1f ? 0 : 1; float const Cos2 = taylorCos::fastCosNew(glm::fvec1(radAngle)).x; //Error += glm::abs(Cos2 - Cos0) < 0.1f ? 0 : 1; assert(!Error); } return Error; } }//namespace taylorCos int main() { int Error(0); Error += ::taylorCos::test(); Error += ::taylorCos::perf(1000); # ifdef NDEBUG ::fastCos::perf(false); ::fastSin::perf(false); ::fastTan::perf(false); ::fastAcos::perf(false); ::fastAsin::perf(false); ::fastAtan::perf(false); # endif//NDEBUG return Error; } glm/test/gtx/gtx_fast_square_root.cpp0000644000000000000000000000636112470135714017074 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_fast_square_root.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include int test_fastInverseSqrt() { int Error(0); Error += glm::epsilonEqual(glm::fastInverseSqrt(1.0f), 1.0f, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(glm::fastInverseSqrt(1.0), 1.0, 0.01) ? 0 : 1; Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::vec2(1.0f)), glm::vec2(1.0f), 0.01f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::dvec3(1.0)), glm::dvec3(1.0), 0.01)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(glm::fastInverseSqrt(glm::dvec4(1.0)), glm::dvec4(1.0), 0.01)) ? 0 : 1; return 0; } int test_fastDistance() { int Error(0); glm::mediump_f32 A = glm::fastDistance(glm::mediump_f32(0.0f), glm::mediump_f32(1.0f)); glm::mediump_f32 B = glm::fastDistance(glm::mediump_f32vec2(0.0f), glm::mediump_f32vec2(1.0f, 0.0f)); glm::mediump_f32 C = glm::fastDistance(glm::mediump_f32vec3(0.0f), glm::mediump_f32vec3(1.0f, 0.0f, 0.0f)); glm::mediump_f32 D = glm::fastDistance(glm::mediump_f32vec4(0.0f), glm::mediump_f32vec4(1.0f, 0.0f, 0.0f, 0.0f)); Error += glm::epsilonEqual(A, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; Error += glm::epsilonEqual(B, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; Error += glm::epsilonEqual(C, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; Error += glm::epsilonEqual(D, glm::mediump_f32(1.0f), glm::mediump_f32(0.01f)) ? 0 : 1; return Error; } int main() { int Error(0); Error += test_fastInverseSqrt(); Error += test_fastDistance(); return Error; } glm/test/gtx/gtx_fast_exponential.cpp0000644000000000000000000000327712470135714017062 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_fast_exponential.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_extented_min_max.cpp0000644000000000000000000000327712642261004017040 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_extented_min_max.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_extend.cpp0000644000000000000000000000325312470135714015000 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_extend.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_euler_angle.cpp0000644000000000000000000003276412470135714016004 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_euler_angle.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// // Code sample from Filippo Ramaciotti #include #include #include #include #include namespace test_eulerAngleX { int test() { int Error = 0; float const Angle(glm::pi() * 0.5f); glm::vec3 const X(1.0f, 0.0f, 0.0f); glm::vec4 const Y(0.0f, 1.0f, 0.0f, 1.0f); glm::vec4 const Y1 = glm::rotate(glm::mat4(1.0f), Angle, X) * Y; glm::vec4 const Y2 = glm::eulerAngleX(Angle) * Y; glm::vec4 const Y3 = glm::eulerAngleXY(Angle, 0.0f) * Y; glm::vec4 const Y4 = glm::eulerAngleYX(0.0f, Angle) * Y; glm::vec4 const Y5 = glm::eulerAngleXZ(Angle, 0.0f) * Y; glm::vec4 const Y6 = glm::eulerAngleZX(0.0f, Angle) * Y; glm::vec4 const Y7 = glm::eulerAngleYXZ(0.0f, Angle, 0.0f) * Y; Error += glm::all(glm::epsilonEqual(Y1, Y2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Y1, Y3, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Y1, Y4, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Y1, Y5, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Y1, Y6, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Y1, Y7, 0.00001f)) ? 0 : 1; glm::vec4 const Z(0.0f, 0.0f, 1.0f, 1.0f); glm::vec4 const Z1 = glm::rotate(glm::mat4(1.0f), Angle, X) * Z; glm::vec4 const Z2 = glm::eulerAngleX(Angle) * Z; glm::vec4 const Z3 = glm::eulerAngleXY(Angle, 0.0f) * Z; glm::vec4 const Z4 = glm::eulerAngleYX(0.0f, Angle) * Z; glm::vec4 const Z5 = glm::eulerAngleXZ(Angle, 0.0f) * Z; glm::vec4 const Z6 = glm::eulerAngleZX(0.0f, Angle) * Z; glm::vec4 const Z7 = glm::eulerAngleYXZ(0.0f, Angle, 0.0f) * Z; Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleX namespace test_eulerAngleY { int test() { int Error = 0; float const Angle(glm::pi() * 0.5f); glm::vec3 const Y(0.0f, 1.0f, 0.0f); glm::vec4 const X(1.0f, 0.0f, 0.0f, 1.0f); glm::vec4 const X1 = glm::rotate(glm::mat4(1.0f), Angle, Y) * X; glm::vec4 const X2 = glm::eulerAngleY(Angle) * X; glm::vec4 const X3 = glm::eulerAngleYX(Angle, 0.0f) * X; glm::vec4 const X4 = glm::eulerAngleXY(0.0f, Angle) * X; glm::vec4 const X5 = glm::eulerAngleYZ(Angle, 0.0f) * X; glm::vec4 const X6 = glm::eulerAngleZY(0.0f, Angle) * X; glm::vec4 const X7 = glm::eulerAngleYXZ(Angle, 0.0f, 0.0f) * X; Error += glm::all(glm::epsilonEqual(X1, X2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X3, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X4, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X5, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X6, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X7, 0.00001f)) ? 0 : 1; glm::vec4 const Z(0.0f, 0.0f, 1.0f, 1.0f); glm::vec4 const Z1 = glm::eulerAngleY(Angle) * Z; glm::vec4 const Z2 = glm::rotate(glm::mat4(1.0f), Angle, Y) * Z; glm::vec4 const Z3 = glm::eulerAngleYX(Angle, 0.0f) * Z; glm::vec4 const Z4 = glm::eulerAngleXY(0.0f, Angle) * Z; glm::vec4 const Z5 = glm::eulerAngleYZ(Angle, 0.0f) * Z; glm::vec4 const Z6 = glm::eulerAngleZY(0.0f, Angle) * Z; glm::vec4 const Z7 = glm::eulerAngleYXZ(Angle, 0.0f, 0.0f) * Z; Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleY namespace test_eulerAngleZ { int test() { int Error = 0; float const Angle(glm::pi() * 0.5f); glm::vec3 const Z(0.0f, 0.0f, 1.0f); glm::vec4 const X(1.0f, 0.0f, 0.0f, 1.0f); glm::vec4 const X1 = glm::rotate(glm::mat4(1.0f), Angle, Z) * X; glm::vec4 const X2 = glm::eulerAngleZ(Angle) * X; glm::vec4 const X3 = glm::eulerAngleZX(Angle, 0.0f) * X; glm::vec4 const X4 = glm::eulerAngleXZ(0.0f, Angle) * X; glm::vec4 const X5 = glm::eulerAngleZY(Angle, 0.0f) * X; glm::vec4 const X6 = glm::eulerAngleYZ(0.0f, Angle) * X; glm::vec4 const X7 = glm::eulerAngleYXZ(0.0f, 0.0f, Angle) * X; Error += glm::all(glm::epsilonEqual(X1, X2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X3, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X4, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X5, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X6, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(X1, X7, 0.00001f)) ? 0 : 1; glm::vec4 const Y(1.0f, 0.0f, 0.0f, 1.0f); glm::vec4 const Z1 = glm::rotate(glm::mat4(1.0f), Angle, Z) * Y; glm::vec4 const Z2 = glm::eulerAngleZ(Angle) * Y; glm::vec4 const Z3 = glm::eulerAngleZX(Angle, 0.0f) * Y; glm::vec4 const Z4 = glm::eulerAngleXZ(0.0f, Angle) * Y; glm::vec4 const Z5 = glm::eulerAngleZY(Angle, 0.0f) * Y; glm::vec4 const Z6 = glm::eulerAngleYZ(0.0f, Angle) * Y; glm::vec4 const Z7 = glm::eulerAngleYXZ(0.0f, 0.0f, Angle) * Y; Error += glm::all(glm::epsilonEqual(Z1, Z2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z3, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z4, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z5, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z6, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Z1, Z7, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleZ namespace test_eulerAngleXY { int test() { int Error = 0; glm::vec4 const V(1.0f); float const AngleX(glm::pi() * 0.5f); float const AngleY(glm::pi() * 0.25f); glm::vec3 const axisX(1.0f, 0.0f, 0.0f); glm::vec3 const axisY(0.0f, 1.0f, 0.0f); glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleX, axisX) * glm::rotate(glm::mat4(1.0f), AngleY, axisY)) * V; glm::vec4 const V2 = glm::eulerAngleXY(AngleX, AngleY) * V; glm::vec4 const V3 = glm::eulerAngleX(AngleX) * glm::eulerAngleY(AngleY) * V; Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleXY namespace test_eulerAngleYX { int test() { int Error = 0; glm::vec4 const V(1.0f); float const AngleX(glm::pi() * 0.5f); float const AngleY(glm::pi() * 0.25f); glm::vec3 const axisX(1.0f, 0.0f, 0.0f); glm::vec3 const axisY(0.0f, 1.0f, 0.0f); glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleY, axisY) * glm::rotate(glm::mat4(1.0f), AngleX, axisX)) * V; glm::vec4 const V2 = glm::eulerAngleYX(AngleY, AngleX) * V; glm::vec4 const V3 = glm::eulerAngleY(AngleY) * glm::eulerAngleX(AngleX) * V; Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleYX namespace test_eulerAngleXZ { int test() { int Error = 0; glm::vec4 const V(1.0f); float const AngleX(glm::pi() * 0.5f); float const AngleZ(glm::pi() * 0.25f); glm::vec3 const axisX(1.0f, 0.0f, 0.0f); glm::vec3 const axisZ(0.0f, 0.0f, 1.0f); glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleX, axisX) * glm::rotate(glm::mat4(1.0f), AngleZ, axisZ)) * V; glm::vec4 const V2 = glm::eulerAngleXZ(AngleX, AngleZ) * V; glm::vec4 const V3 = glm::eulerAngleX(AngleX) * glm::eulerAngleZ(AngleZ) * V; Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleXZ namespace test_eulerAngleZX { int test() { int Error = 0; glm::vec4 const V(1.0f); float const AngleX(glm::pi() * 0.5f); float const AngleZ(glm::pi() * 0.25f); glm::vec3 const axisX(1.0f, 0.0f, 0.0f); glm::vec3 const axisZ(0.0f, 0.0f, 1.0f); glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleZ, axisZ) * glm::rotate(glm::mat4(1.0f), AngleX, axisX)) * V; glm::vec4 const V2 = glm::eulerAngleZX(AngleZ, AngleX) * V; glm::vec4 const V3 = glm::eulerAngleZ(AngleZ) * glm::eulerAngleX(AngleX) * V; Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleZX namespace test_eulerAngleYZ { int test() { int Error = 0; glm::vec4 const V(1.0f); float const AngleY(glm::pi() * 0.5f); float const AngleZ(glm::pi() * 0.25f); glm::vec3 const axisX(1.0f, 0.0f, 0.0f); glm::vec3 const axisY(0.0f, 1.0f, 0.0f); glm::vec3 const axisZ(0.0f, 0.0f, 1.0f); glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleY, axisY) * glm::rotate(glm::mat4(1.0f), AngleZ, axisZ)) * V; glm::vec4 const V2 = glm::eulerAngleYZ(AngleY, AngleZ) * V; glm::vec4 const V3 = glm::eulerAngleY(AngleY) * glm::eulerAngleZ(AngleZ) * V; Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleYZ namespace test_eulerAngleZY { int test() { int Error = 0; glm::vec4 const V(1.0f); float const AngleY(glm::pi() * 0.5f); float const AngleZ(glm::pi() * 0.25f); glm::vec3 const axisX(1.0f, 0.0f, 0.0f); glm::vec3 const axisY(0.0f, 1.0f, 0.0f); glm::vec3 const axisZ(0.0f, 0.0f, 1.0f); glm::vec4 const V1 = (glm::rotate(glm::mat4(1.0f), AngleZ, axisZ) * glm::rotate(glm::mat4(1.0f), AngleY, axisY)) * V; glm::vec4 const V2 = glm::eulerAngleZY(AngleZ, AngleY) * V; glm::vec4 const V3 = glm::eulerAngleZ(AngleZ) * glm::eulerAngleY(AngleY) * V; Error += glm::all(glm::epsilonEqual(V1, V2, 0.00001f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(V1, V3, 0.00001f)) ? 0 : 1; return Error; } }//namespace test_eulerAngleZY namespace test_eulerAngleYXZ { int test() { glm::f32 first = 1.046f; glm::f32 second = 0.52f; glm::f32 third = -0.785f; glm::fmat4 rotationEuler = glm::eulerAngleYXZ(first, second, third); glm::fmat4 rotationInvertedY = glm::eulerAngleY(-1.f*first) * glm::eulerAngleX(second) * glm::eulerAngleZ(third); glm::fmat4 rotationDumb = glm::fmat4(); rotationDumb = glm::rotate(rotationDumb, first, glm::fvec3(0,1,0)); rotationDumb = glm::rotate(rotationDumb, second, glm::fvec3(1,0,0)); rotationDumb = glm::rotate(rotationDumb, third, glm::fvec3(0,0,1)); std::printf("%s\n", glm::to_string(glm::fmat3(rotationEuler)).c_str()); std::printf("%s\n", glm::to_string(glm::fmat3(rotationDumb)).c_str()); std::printf("%s\n", glm::to_string(glm::fmat3(rotationInvertedY)).c_str()); std::printf("\nRESIDUAL\n"); std::printf("%s\n", glm::to_string(glm::fmat3(rotationEuler-(rotationDumb))).c_str()); std::printf("%s\n", glm::to_string(glm::fmat3(rotationEuler-(rotationInvertedY))).c_str()); return 0; } }//namespace eulerAngleYXZ int main() { int Error = 0; Error += test_eulerAngleX::test(); Error += test_eulerAngleY::test(); Error += test_eulerAngleZ::test(); Error += test_eulerAngleXY::test(); Error += test_eulerAngleYX::test(); Error += test_eulerAngleXZ::test(); Error += test_eulerAngleZX::test(); Error += test_eulerAngleYZ::test(); Error += test_eulerAngleZY::test(); Error += test_eulerAngleYXZ::test(); return Error; } glm/test/gtx/gtx_dual_quaternion.cpp0000644000000000000000000001734712554773746016734 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_dual_quaternion.cpp /// @date 2013-02-10 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #if GLM_HAS_TRIVIAL_QUERIES # include #endif int myrand() { static int holdrand = 1; return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff); } float myfrand() // returns values from -1 to 1 inclusive { return float(double(myrand()) / double( 0x7ffff )) * 2.0f - 1.0f; } int test_dquat_type() { glm::dvec3 vA; glm::dquat dqA,dqB; glm::ddualquat C(dqA,dqB); glm::ddualquat B(dqA); glm::ddualquat D(dqA,vA); return 0; } int test_scalars() { float const Epsilon = 0.0001f; int Error(0); glm::quat src_q1 = glm::quat(1.0f,2.0f,3.0f,4.0f); glm::quat src_q2 = glm::quat(5.0f,6.0f,7.0f,8.0f); glm::dualquat src1(src_q1,src_q2); { glm::dualquat dst1 = src1 * 2.0f; glm::dualquat dst2 = 2.0f * src1; glm::dualquat dst3 = src1; dst3 *= 2.0f; glm::dualquat dstCmp(src_q1 * 2.0f,src_q2 * 2.0f); Error += glm::all(glm::epsilonEqual(dst1.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst1.dual,dstCmp.dual, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst2.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst2.dual,dstCmp.dual, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst3.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst3.dual,dstCmp.dual, Epsilon)) ? 0 : 1; } { glm::dualquat dst1 = src1 / 2.0f; glm::dualquat dst2 = src1; dst2 /= 2.0f; glm::dualquat dstCmp(src_q1 / 2.0f,src_q2 / 2.0f); Error += glm::all(glm::epsilonEqual(dst1.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst1.dual,dstCmp.dual, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst2.real,dstCmp.real, Epsilon)) && glm::all(glm::epsilonEqual(dst2.dual,dstCmp.dual, Epsilon)) ? 0 : 1; } return Error; } int test_inverse() { int Error(0); float const Epsilon = 0.0001f; glm::dualquat dqid; glm::mat4x4 mid(1.0f); for (int j = 0; j < 100; ++j) { glm::mat4x4 rot = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f); glm::vec3 vt = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f); glm::mat4x4 m = glm::translate(mid, vt) * rot; glm::quat qr = glm::quat_cast(m); glm::dualquat dq(qr); glm::dualquat invdq = glm::inverse(dq); glm::dualquat r1 = invdq * dq; glm::dualquat r2 = dq * invdq; Error += glm::all(glm::epsilonEqual(r1.real, dqid.real, Epsilon)) && glm::all(glm::epsilonEqual(r1.dual, dqid.dual, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(r2.real, dqid.real, Epsilon)) && glm::all(glm::epsilonEqual(r2.dual, dqid.dual, Epsilon)) ? 0 : 1; // testing commutative property glm::dualquat r ( glm::quat( myfrand() * glm::pi() * 2.0f, myfrand(), myfrand(), myfrand() ), glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f) ); glm::dualquat riq = (r * invdq) * dq; glm::dualquat rqi = (r * dq) * invdq; Error += glm::all(glm::epsilonEqual(riq.real, rqi.real, Epsilon)) && glm::all(glm::epsilonEqual(riq.dual, rqi.dual, Epsilon)) ? 0 : 1; } return Error; } int test_mul() { int Error(0); float const Epsilon = 0.0001f; glm::mat4x4 mid(1.0f); for (int j = 0; j < 100; ++j) { // generate random rotations and translations and compare transformed by matrix and dualquats random points glm::vec3 vt1 = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f); glm::vec3 vt2 = glm::vec3(myfrand() * 10.0f, myfrand() * 10.0f, myfrand() * 10.0f); glm::mat4x4 rot1 = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f); glm::mat4x4 rot2 = glm::yawPitchRoll(myfrand() * 360.0f, myfrand() * 360.0f, myfrand() * 360.0f); glm::mat4x4 m1 = glm::translate(mid, vt1) * rot1; glm::mat4x4 m2 = glm::translate(mid, vt2) * rot2; glm::mat4x4 m3 = m2 * m1; glm::mat4x4 m4 = m1 * m2; glm::quat qrot1 = glm::quat_cast(rot1); glm::quat qrot2 = glm::quat_cast(rot2); glm::dualquat dq1 = glm::dualquat(qrot1,vt1); glm::dualquat dq2 = glm::dualquat(qrot2,vt2); glm::dualquat dq3 = dq2 * dq1; glm::dualquat dq4 = dq1 * dq2; for (int i = 0; i < 100; ++i) { glm::vec4 src_pt = glm::vec4(myfrand() * 4.0f, myfrand() * 5.0f, myfrand() * 3.0f,1.0f); // test both multiplication orders glm::vec4 dst_pt_m3 = m3 * src_pt; glm::vec4 dst_pt_dq3 = dq3 * src_pt; glm::vec4 dst_pt_m3_i = glm::inverse(m3) * src_pt; glm::vec4 dst_pt_dq3_i = src_pt * dq3; glm::vec4 dst_pt_m4 = m4 * src_pt; glm::vec4 dst_pt_dq4 = dq4 * src_pt; glm::vec4 dst_pt_m4_i = glm::inverse(m4) * src_pt; glm::vec4 dst_pt_dq4_i = src_pt * dq4; Error += glm::all(glm::epsilonEqual(dst_pt_m3, dst_pt_dq3, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst_pt_m4, dst_pt_dq4, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst_pt_m3_i, dst_pt_dq3_i, Epsilon)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(dst_pt_m4_i, dst_pt_dq4_i, Epsilon)) ? 0 : 1; } } return Error; } int test_dual_quat_ctr() { int Error(0); # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; Error += std::is_trivially_copyable::value ? 0 : 1; Error += std::is_trivially_copyable::value ? 0 : 1; Error += std::is_copy_constructible::value ? 0 : 1; Error += std::is_copy_constructible::value ? 0 : 1; # endif return Error; } int main() { int Error(0); #ifdef GLM_META_PROG_HELPERS assert(glm::dualquat::components == glm::dualquat().length()); #endif Error += test_dual_quat_ctr(); Error += test_dquat_type(); Error += test_scalars(); Error += test_inverse(); Error += test_mul(); return Error; } glm/test/gtx/gtx_component_wise.cpp0000644000000000000000000000327312642261004016535 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_component_wise.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_compatibility.cpp0000644000000000000000000000412312552723204016355 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_compatibility.cpp /// @date 2014-09-08 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); Error += glm::isfinite(1.0f) ? 0 : 1; Error += glm::isfinite(1.0) ? 0 : 1; Error += glm::isfinite(-1.0f) ? 0 : 1; Error += glm::isfinite(-1.0) ? 0 : 1; Error += glm::all(glm::isfinite(glm::vec4(1.0f))) ? 0 : 1; Error += glm::all(glm::isfinite(glm::dvec4(1.0))) ? 0 : 1; Error += glm::all(glm::isfinite(glm::vec4(-1.0f))) ? 0 : 1; Error += glm::all(glm::isfinite(glm::dvec4(-1.0))) ? 0 : 1; return Error; } glm/test/gtx/gtx_common.cpp0000644000000000000000000001073312571064072015002 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_common.cpp /// @date 2014-09-08 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include namespace fmod_ { template GLM_FUNC_QUALIFIER genType modTrunc(genType a, genType b) { return a - b * glm::trunc(a / b); } int test() { int Error(0); { float A0(3.0); float B0(2.0f); float C0 = glm::fmod(A0, B0); Error += glm::abs(C0 - 1.0f) < 0.00001f ? 0 : 1; glm::vec4 A1(3.0); float B1(2.0f); glm::vec4 C1 = glm::fmod(A1, B1); Error += glm::all(glm::epsilonEqual(C1, glm::vec4(1.0f), 0.00001f)) ? 0 : 1; glm::vec4 A2(3.0); glm::vec4 B2(2.0f); glm::vec4 C2 = glm::fmod(A2, B2); Error += glm::all(glm::epsilonEqual(C2, glm::vec4(1.0f), 0.00001f)) ? 0 : 1; glm::ivec4 A3(3); int B3(2); glm::ivec4 C3 = glm::fmod(A3, B3); Error += glm::all(glm::equal(C3, glm::ivec4(1))) ? 0 : 1; glm::ivec4 A4(3); glm::ivec4 B4(2); glm::ivec4 C4 = glm::fmod(A4, B4); Error += glm::all(glm::equal(C4, glm::ivec4(1))) ? 0 : 1; } { float A0(22.0); float B0(-10.0f); float C0 = glm::fmod(A0, B0); Error += glm::abs(C0 - 2.0f) < 0.00001f ? 0 : 1; glm::vec4 A1(22.0); float B1(-10.0f); glm::vec4 C1 = glm::fmod(A1, B1); Error += glm::all(glm::epsilonEqual(C1, glm::vec4(2.0f), 0.00001f)) ? 0 : 1; glm::vec4 A2(22.0); glm::vec4 B2(-10.0f); glm::vec4 C2 = glm::fmod(A2, B2); Error += glm::all(glm::epsilonEqual(C2, glm::vec4(2.0f), 0.00001f)) ? 0 : 1; glm::ivec4 A3(22); int B3(-10); glm::ivec4 C3 = glm::fmod(A3, B3); Error += glm::all(glm::equal(C3, glm::ivec4(2))) ? 0 : 1; glm::ivec4 A4(22); glm::ivec4 B4(-10); glm::ivec4 C4 = glm::fmod(A4, B4); Error += glm::all(glm::equal(C4, glm::ivec4(2))) ? 0 : 1; } // http://stackoverflow.com/questions/7610631/glsl-mod-vs-hlsl-fmod { for (float y = -10.0f; y < 10.0f; y += 0.1f) for (float x = -10.0f; x < 10.0f; x += 0.1f) { float const A(std::fmod(x, y)); //float const B(std::remainder(x, y)); float const C(glm::fmod(x, y)); float const D(modTrunc(x, y)); //Error += glm::epsilonEqual(A, B, 0.0001f) ? 0 : 1; //assert(!Error); Error += glm::epsilonEqual(A, C, 0.0001f) ? 0 : 1; assert(!Error); Error += glm::epsilonEqual(A, D, 0.00001f) ? 0 : 1; assert(!Error); } } return Error; } }//namespace fmod_ int test_isdenormal() { int Error(0); bool A = glm::isdenormal(1.0f); glm::bvec1 B = glm::isdenormal(glm::vec1(1.0f)); glm::bvec2 C = glm::isdenormal(glm::vec2(1.0f)); glm::bvec3 D = glm::isdenormal(glm::vec3(1.0f)); glm::bvec4 E = glm::isdenormal(glm::vec4(1.0f)); return Error; } int main() { int Error(0); Error += test_isdenormal(); Error += ::fmod_::test(); return Error; } glm/test/gtx/gtx_color_space_YCoCg.cpp0000644000000000000000000000330112470135714017020 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_color_space_YCoCg.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_color_space.cpp0000644000000000000000000000354312470135714016004 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_color_space.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int test_saturation() { int Error(0); glm::vec4 Color = glm::saturation(1.0f, glm::vec4(1.0, 0.5, 0.0, 1.0)); return Error; } int main() { int Error(0); Error += test_saturation(); return Error; } glm/test/gtx/gtx_closest_point.cpp0000644000000000000000000000327112470135714016376 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_closest_point.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error(0); return Error; } glm/test/gtx/gtx_associated_min_max.cpp0000644000000000000000000000335212470135714017340 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtx/gtx_associated_min_max.cpp /// @date 2013-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int main() { int Error(0); return Error; } glm/test/gtx/CMakeLists.txt0000644000000000000000000000346212642261004014656 0ustar rootrootglmCreateTestGTC(gtx_associated_min_max) glmCreateTestGTC(gtx_closest_point) glmCreateTestGTC(gtx_color_space_YCoCg) glmCreateTestGTC(gtx_color_space) glmCreateTestGTC(gtx_common) glmCreateTestGTC(gtx_compatibility) glmCreateTestGTC(gtx_component_wise) glmCreateTestGTC(gtx_euler_angle) glmCreateTestGTC(gtx_extend) glmCreateTestGTC(gtx_extented_min_max) glmCreateTestGTC(gtx_fast_exponential) glmCreateTestGTC(gtx_fast_square_root) glmCreateTestGTC(gtx_fast_trigonometry) glmCreateTestGTC(gtx_gradient_paint) glmCreateTestGTC(gtx_handed_coordinate_space) glmCreateTestGTC(gtx_integer) glmCreateTestGTC(gtx_intersect) glmCreateTestGTC(gtx_io) glmCreateTestGTC(gtx_log_base) glmCreateTestGTC(gtx_matrix_cross_product) glmCreateTestGTC(gtx_matrix_decompose) glmCreateTestGTC(gtx_matrix_interpolation) glmCreateTestGTC(gtx_matrix_major_storage) glmCreateTestGTC(gtx_matrix_operation) glmCreateTestGTC(gtx_matrix_query) glmCreateTestGTC(gtx_matrix_transform_2d) glmCreateTestGTC(gtx_norm) glmCreateTestGTC(gtx_normal) glmCreateTestGTC(gtx_normalize_dot) glmCreateTestGTC(gtx_number_precision) glmCreateTestGTC(gtx_orthonormalize) glmCreateTestGTC(gtx_optimum_pow) glmCreateTestGTC(gtx_perpendicular) glmCreateTestGTC(gtx_polar_coordinates) glmCreateTestGTC(gtx_projection) glmCreateTestGTC(gtx_quaternion) glmCreateTestGTC(gtx_dual_quaternion) glmCreateTestGTC(gtx_range) glmCreateTestGTC(gtx_rotate_normalized_axis) glmCreateTestGTC(gtx_rotate_vector) glmCreateTestGTC(gtx_scalar_multiplication) glmCreateTestGTC(gtx_scalar_relational) glmCreateTestGTC(gtx_simd_vec4) glmCreateTestGTC(gtx_simd_mat4) glmCreateTestGTC(gtx_spline) glmCreateTestGTC(gtx_string_cast) glmCreateTestGTC(gtx_type_aligned) glmCreateTestGTC(gtx_vector_angle) glmCreateTestGTC(gtx_vector_query) glmCreateTestGTC(gtx_wrap) glm/test/gtc/0000755000000000000000000000000012642261102012063 5ustar rootrootglm/test/gtc/gtc_vec1.cpp0000644000000000000000000000325012470135714014272 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_vec1.cpp /// @date 2014-10-11 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error = 0; return Error; } glm/test/gtc/gtc_user_defined_types.cpp0000644000000000000000000000141712470135714017317 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2010-09-16 // Updated : 2011-05-27 // Licence : This source is under MIT licence // File : test/gtc/type_ptr.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #define GLM_FORCE_RADIANS #include int test_make_pointer_vec() { int Error = 0; glm::func(); //func(); return Error; } int main() { int Error = 0; Error += test_make_pointer_vec(); return Error; } glm/test/gtc/gtc_ulp.cpp0000644000000000000000000000642112470135714014237 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_ulp.cpp /// @date 2011-04-26 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int test_ulp_float_dist() { int Error = 0; float A = 1.0f; float B = glm::next_float(A); Error += A != B ? 0 : 1; float C = glm::prev_float(B); Error += A == C ? 0 : 1; int D = glm::float_distance(A, B); Error += D == 1 ? 0 : 1; int E = glm::float_distance(A, C); Error += E == 0 ? 0 : 1; return Error; } int test_ulp_float_step() { int Error = 0; float A = 1.0f; for(int i = 10; i < 1000; i *= 10) { float B = glm::next_float(A, i); Error += A != B ? 0 : 1; float C = glm::prev_float(B, i); Error += A == C ? 0 : 1; int D = glm::float_distance(A, B); Error += D == i ? 0 : 1; int E = glm::float_distance(A, C); Error += E == 0 ? 0 : 1; } return Error; } int test_ulp_double_dist() { int Error = 0; double A = 1.0; double B = glm::next_float(A); Error += A != B ? 0 : 1; double C = glm::prev_float(B); Error += A == C ? 0 : 1; int D = glm::float_distance(A, B); Error += D == 1 ? 0 : 1; int E = glm::float_distance(A, C); Error += E == 0 ? 0 : 1; return Error; } int test_ulp_double_step() { int Error = 0; double A = 1.0; for(int i = 10; i < 1000; i *= 10) { double B = glm::next_float(A, i); Error += A != B ? 0 : 1; double C = glm::prev_float(B, i); Error += A == C ? 0 : 1; int D = glm::float_distance(A, B); Error += D == i ? 0 : 1; int E = glm::float_distance(A, C); Error += E == 0 ? 0 : 1; } return Error; } int main() { int Error = 0; Error += test_ulp_float_dist(); Error += test_ulp_float_step(); Error += test_ulp_double_dist(); Error += test_ulp_double_step(); return Error; } glm/test/gtc/gtc_type_ptr.cpp0000644000000000000000000001612612470135714015310 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_type_ptr.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int test_value_ptr_vec() { int Error = 0; { glm::vec2 v(1.0); float * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::vec3 v(1.0); float * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::vec4 v(1.0); float * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::dvec2 v(1.0); double * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::dvec3 v(1.0); double * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::dvec4 v(1.0); double * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } return Error; } int test_value_ptr_vec_const() { int Error = 0; { glm::vec2 const v(1.0); float const * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::vec3 const v(1.0); float const * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::vec4 const v(1.0); float const * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::dvec2 const v(1.0); double const * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::dvec3 const v(1.0); double const * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } { glm::dvec4 const v(1.0); double const * p = glm::value_ptr(v); Error += p == &v[0] ? 0 : 1; } return Error; } int test_value_ptr_mat() { int Error = 0; { glm::mat2x2 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat2x3 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat2x4 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat3x2 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat3x3 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat3x4 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat4x2 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat4x3 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat4x4 m(1.0); float * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } return Error; } int test_value_ptr_mat_const() { int Error = 0; { glm::mat2x2 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat2x3 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat2x4 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat3x2 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat3x3 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat3x4 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat4x2 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat4x3 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } { glm::mat4x4 const m(1.0); float const * p = glm::value_ptr(m); Error += p == &m[0][0] ? 0 : 1; } return Error; } int test_make_pointer_mat() { int Error = 0; float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; double ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; glm::mat2x2 Mat2x2A = glm::make_mat2x2(ArrayA); glm::mat2x3 Mat2x3A = glm::make_mat2x3(ArrayA); glm::mat2x4 Mat2x4A = glm::make_mat2x4(ArrayA); glm::mat3x2 Mat3x2A = glm::make_mat3x2(ArrayA); glm::mat3x3 Mat3x3A = glm::make_mat3x3(ArrayA); glm::mat3x4 Mat3x4A = glm::make_mat3x4(ArrayA); glm::mat4x2 Mat4x2A = glm::make_mat4x2(ArrayA); glm::mat4x3 Mat4x3A = glm::make_mat4x3(ArrayA); glm::mat4x4 Mat4x4A = glm::make_mat4x4(ArrayA); glm::dmat2x2 Mat2x2B = glm::make_mat2x2(ArrayB); glm::dmat2x3 Mat2x3B = glm::make_mat2x3(ArrayB); glm::dmat2x4 Mat2x4B = glm::make_mat2x4(ArrayB); glm::dmat3x2 Mat3x2B = glm::make_mat3x2(ArrayB); glm::dmat3x3 Mat3x3B = glm::make_mat3x3(ArrayB); glm::dmat3x4 Mat3x4B = glm::make_mat3x4(ArrayB); glm::dmat4x2 Mat4x2B = glm::make_mat4x2(ArrayB); glm::dmat4x3 Mat4x3B = glm::make_mat4x3(ArrayB); glm::dmat4x4 Mat4x4B = glm::make_mat4x4(ArrayB); return Error; } int test_make_pointer_vec() { int Error = 0; float ArrayA[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int ArrayB[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; bool ArrayC[] = {true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false}; glm::vec2 Vec2A = glm::make_vec2(ArrayA); glm::vec3 Vec3A = glm::make_vec3(ArrayA); glm::vec4 Vec4A = glm::make_vec4(ArrayA); glm::ivec2 Vec2B = glm::make_vec2(ArrayB); glm::ivec3 Vec3B = glm::make_vec3(ArrayB); glm::ivec4 Vec4B = glm::make_vec4(ArrayB); glm::bvec2 Vec2C = glm::make_vec2(ArrayC); glm::bvec3 Vec3C = glm::make_vec3(ArrayC); glm::bvec4 Vec4C = glm::make_vec4(ArrayC); return Error; } int main() { int Error = 0; Error += test_make_pointer_vec(); Error += test_make_pointer_mat(); Error += test_value_ptr_vec(); Error += test_value_ptr_vec_const(); Error += test_value_ptr_mat(); Error += test_value_ptr_mat_const(); return Error; } glm/test/gtc/gtc_type_precision.cpp0000644000000000000000000007212112470135714016473 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_type_precision.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #if GLM_HAS_OPENMP # include #endif static int test_scalar_size() { int Error(0); Error += sizeof(glm::int8) != 1; Error += sizeof(glm::int16) != 2; Error += sizeof(glm::int32) != 4; Error += sizeof(glm::int64) != 8; Error += sizeof(glm::uint8) != 1; Error += sizeof(glm::uint16) != 2; Error += sizeof(glm::uint32) != 4; Error += sizeof(glm::uint64) != 8; Error += sizeof(glm::float32) != 4; Error += sizeof(glm::float64) != 8; Error += sizeof(glm::lowp_int8) != 1; Error += sizeof(glm::lowp_int16) != 2; Error += sizeof(glm::lowp_int32) != 4; Error += sizeof(glm::lowp_int64) != 8; Error += sizeof(glm::lowp_uint8) != 1; Error += sizeof(glm::lowp_uint16) != 2; Error += sizeof(glm::lowp_uint32) != 4; Error += sizeof(glm::lowp_uint64) != 8; Error += sizeof(glm::lowp_float32) != 4; Error += sizeof(glm::lowp_float64) != 8; Error += sizeof(glm::mediump_int8) != 1; Error += sizeof(glm::mediump_int16) != 2; Error += sizeof(glm::mediump_int32) != 4; Error += sizeof(glm::mediump_int64) != 8; Error += sizeof(glm::mediump_uint8) != 1; Error += sizeof(glm::mediump_uint16) != 2; Error += sizeof(glm::mediump_uint32) != 4; Error += sizeof(glm::mediump_uint64) != 8; Error += sizeof(glm::mediump_float32) != 4; Error += sizeof(glm::mediump_float64) != 8; Error += sizeof(glm::highp_int8) != 1; Error += sizeof(glm::highp_int16) != 2; Error += sizeof(glm::highp_int32) != 4; Error += sizeof(glm::highp_int64) != 8; Error += sizeof(glm::highp_uint8) != 1; Error += sizeof(glm::highp_uint16) != 2; Error += sizeof(glm::highp_uint32) != 4; Error += sizeof(glm::highp_uint64) != 8; Error += sizeof(glm::highp_float32) != 4; Error += sizeof(glm::highp_float64) != 8; return Error; } static int test_fvec_size() { int Error(0); Error += sizeof(glm::f32vec2) != 8; Error += sizeof(glm::f32vec3) != 12; Error += sizeof(glm::f32vec4) != 16; Error += sizeof(glm::f64vec2) != 16; Error += sizeof(glm::f64vec3) != 24; Error += sizeof(glm::f64vec4) != 32; Error += sizeof(glm::lowp_f32vec2) != 8; Error += sizeof(glm::lowp_f32vec3) != 12; Error += sizeof(glm::lowp_f32vec4) != 16; Error += sizeof(glm::lowp_f64vec2) != 16; Error += sizeof(glm::lowp_f64vec3) != 24; Error += sizeof(glm::lowp_f64vec4) != 32; Error += sizeof(glm::mediump_f32vec2) != 8; Error += sizeof(glm::mediump_f32vec3) != 12; Error += sizeof(glm::mediump_f32vec4) != 16; Error += sizeof(glm::mediump_f64vec2) != 16; Error += sizeof(glm::mediump_f64vec3) != 24; Error += sizeof(glm::mediump_f64vec4) != 32; Error += sizeof(glm::highp_f32vec2) != 8; Error += sizeof(glm::highp_f32vec3) != 12; Error += sizeof(glm::highp_f32vec4) != 16; Error += sizeof(glm::highp_f64vec2) != 16; Error += sizeof(glm::highp_f64vec3) != 24; Error += sizeof(glm::highp_f64vec4) != 32; return Error; } static int test_fvec_precision() { int Error(0); /* { glm::f32vec2 v1; glm::lowp_f32vec2 v2((glm::f32vec2(v1))); glm::mediump_f32vec2 v3((glm::f32vec2(v1))); glm::highp_f32vec2 v4((glm::f32vec2(v1))); Error += glm::all(glm::equal(v1, v2)) ? 0 : 1; Error += glm::all(glm::equal(v1, v3)) ? 0 : 1; Error += glm::all(glm::equal(v1, v4)) ? 0 : 1; } */ { glm::f32vec2 v1; glm::lowp_f32vec2 v2(v1); glm::mediump_f32vec2 v3(v1); glm::highp_f32vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::f32vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f32vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f32vec2(v4))) ? 0 : 1; } { glm::f32vec3 v1; glm::lowp_f32vec3 v2(v1); glm::mediump_f32vec3 v3(v1); glm::highp_f32vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::f32vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f32vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f32vec3(v4))) ? 0 : 1; } { glm::f32vec4 v1; glm::lowp_f32vec4 v2(v1); glm::mediump_f32vec4 v3(v1); glm::highp_f32vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::f32vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f32vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f32vec4(v4))) ? 0 : 1; } return Error; } static int test_dvec_precision() { int Error(0); { glm::f64vec2 v1; glm::lowp_f64vec2 v2(v1); glm::mediump_f64vec2 v3(v1); glm::highp_f64vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::f64vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f64vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f64vec2(v4))) ? 0 : 1; } { glm::f64vec3 v1; glm::lowp_f64vec3 v2(v1); glm::mediump_f64vec3 v3(v1); glm::highp_f64vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::f64vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f64vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f64vec3(v4))) ? 0 : 1; } { glm::f64vec4 v1; glm::lowp_f64vec4 v2(v1); glm::mediump_f64vec4 v3(v1); glm::highp_f64vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::f64vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f64vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::f64vec4(v4))) ? 0 : 1; } return Error; } static int test_ivec_size() { int Error(0); Error += sizeof(glm::i8vec2) != 2; Error += sizeof(glm::i8vec3) != 3; Error += sizeof(glm::i8vec4) != 4; Error += sizeof(glm::i16vec2) != 4; Error += sizeof(glm::i16vec3) != 6; Error += sizeof(glm::i16vec4) != 8; Error += sizeof(glm::i32vec2) != 8; Error += sizeof(glm::i32vec3) != 12; Error += sizeof(glm::i32vec4) != 16; Error += sizeof(glm::i64vec2) != 16; Error += sizeof(glm::i64vec3) != 24; Error += sizeof(glm::i64vec4) != 32; Error += sizeof(glm::lowp_i8vec2) != 2; Error += sizeof(glm::lowp_i8vec3) != 3; Error += sizeof(glm::lowp_i8vec4) != 4; Error += sizeof(glm::lowp_i16vec2) != 4; Error += sizeof(glm::lowp_i16vec3) != 6; Error += sizeof(glm::lowp_i16vec4) != 8; Error += sizeof(glm::lowp_i32vec2) != 8; Error += sizeof(glm::lowp_i32vec3) != 12; Error += sizeof(glm::lowp_i32vec4) != 16; Error += sizeof(glm::lowp_i64vec2) != 16; Error += sizeof(glm::lowp_i64vec3) != 24; Error += sizeof(glm::lowp_i64vec4) != 32; Error += sizeof(glm::mediump_i8vec2) != 2; Error += sizeof(glm::mediump_i8vec3) != 3; Error += sizeof(glm::mediump_i8vec4) != 4; Error += sizeof(glm::mediump_i16vec2) != 4; Error += sizeof(glm::mediump_i16vec3) != 6; Error += sizeof(glm::mediump_i16vec4) != 8; Error += sizeof(glm::mediump_i32vec2) != 8; Error += sizeof(glm::mediump_i32vec3) != 12; Error += sizeof(glm::mediump_i32vec4) != 16; Error += sizeof(glm::mediump_i64vec2) != 16; Error += sizeof(glm::mediump_i64vec3) != 24; Error += sizeof(glm::mediump_i64vec4) != 32; Error += sizeof(glm::highp_i8vec2) != 2; Error += sizeof(glm::highp_i8vec3) != 3; Error += sizeof(glm::highp_i8vec4) != 4; Error += sizeof(glm::highp_i16vec2) != 4; Error += sizeof(glm::highp_i16vec3) != 6; Error += sizeof(glm::highp_i16vec4) != 8; Error += sizeof(glm::highp_i32vec2) != 8; Error += sizeof(glm::highp_i32vec3) != 12; Error += sizeof(glm::highp_i32vec4) != 16; Error += sizeof(glm::highp_i64vec2) != 16; Error += sizeof(glm::highp_i64vec3) != 24; Error += sizeof(glm::highp_i64vec4) != 32; return Error; } static int test_ivec_precision() { int Error(0); { glm::i8vec2 v1; glm::lowp_i8vec2 v2(v1); glm::mediump_i8vec2 v3(v1); glm::highp_i8vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::i8vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i8vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i8vec2(v4))) ? 0 : 1; } { glm::i8vec3 v1; glm::lowp_i8vec3 v2(v1); glm::mediump_i8vec3 v3(v1); glm::highp_i8vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::i8vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i8vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i8vec3(v4))) ? 0 : 1; } { glm::i8vec4 v1; glm::lowp_i8vec4 v2(v1); glm::mediump_i8vec4 v3(v1); glm::highp_i8vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::i8vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i8vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i8vec4(v4))) ? 0 : 1; } { glm::i16vec2 v1; glm::lowp_i16vec2 v2(v1); glm::mediump_i16vec2 v3(v1); glm::highp_i16vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::i16vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i16vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i16vec2(v4))) ? 0 : 1; } { glm::i16vec3 v1; glm::lowp_i16vec3 v2(v1); glm::mediump_i16vec3 v3(v1); glm::highp_i16vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::i16vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i16vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i16vec3(v4))) ? 0 : 1; } { glm::i16vec4 v1; glm::lowp_i16vec4 v2(v1); glm::mediump_i16vec4 v3(v1); glm::highp_i16vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::i16vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i16vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i16vec4(v4))) ? 0 : 1; } { glm::i32vec2 v1; glm::lowp_i32vec2 v2(v1); glm::mediump_i32vec2 v3(v1); glm::highp_i32vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::i32vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i32vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i32vec2(v4))) ? 0 : 1; } { glm::i32vec3 v1; glm::lowp_i32vec3 v2(v1); glm::mediump_i32vec3 v3(v1); glm::highp_i32vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::i32vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i32vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i32vec3(v4))) ? 0 : 1; } { glm::i32vec4 v1; glm::lowp_i32vec4 v2(v1); glm::mediump_i32vec4 v3(v1); glm::highp_i32vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::i32vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i32vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i32vec4(v4))) ? 0 : 1; } { glm::i64vec2 v1; glm::lowp_i64vec2 v2(v1); glm::mediump_i64vec2 v3(v1); glm::highp_i64vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::i64vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i64vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i64vec2(v4))) ? 0 : 1; } { glm::i64vec3 v1; glm::lowp_i64vec3 v2(v1); glm::mediump_i64vec3 v3(v1); glm::highp_i64vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::i64vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i64vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i64vec3(v4))) ? 0 : 1; } { glm::i64vec4 v1; glm::lowp_i64vec4 v2(v1); glm::mediump_i64vec4 v3(v1); glm::highp_i64vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::i64vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i64vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::i64vec4(v4))) ? 0 : 1; } return Error; } static int test_uvec_size() { int Error(0); Error += sizeof(glm::u8vec2) != 2; Error += sizeof(glm::u8vec3) != 3; Error += sizeof(glm::u8vec4) != 4; Error += sizeof(glm::u16vec2) != 4; Error += sizeof(glm::u16vec3) != 6; Error += sizeof(glm::u16vec4) != 8; Error += sizeof(glm::u32vec2) != 8; Error += sizeof(glm::u32vec3) != 12; Error += sizeof(glm::u32vec4) != 16; Error += sizeof(glm::u64vec2) != 16; Error += sizeof(glm::u64vec3) != 24; Error += sizeof(glm::u64vec4) != 32; Error += sizeof(glm::lowp_u8vec2) != 2; Error += sizeof(glm::lowp_u8vec3) != 3; Error += sizeof(glm::lowp_u8vec4) != 4; Error += sizeof(glm::lowp_u16vec2) != 4; Error += sizeof(glm::lowp_u16vec3) != 6; Error += sizeof(glm::lowp_u16vec4) != 8; Error += sizeof(glm::lowp_u32vec2) != 8; Error += sizeof(glm::lowp_u32vec3) != 12; Error += sizeof(glm::lowp_u32vec4) != 16; Error += sizeof(glm::lowp_u64vec2) != 16; Error += sizeof(glm::lowp_u64vec3) != 24; Error += sizeof(glm::lowp_u64vec4) != 32; Error += sizeof(glm::mediump_u8vec2) != 2; Error += sizeof(glm::mediump_u8vec3) != 3; Error += sizeof(glm::mediump_u8vec4) != 4; Error += sizeof(glm::mediump_u16vec2) != 4; Error += sizeof(glm::mediump_u16vec3) != 6; Error += sizeof(glm::mediump_u16vec4) != 8; Error += sizeof(glm::mediump_u32vec2) != 8; Error += sizeof(glm::mediump_u32vec3) != 12; Error += sizeof(glm::mediump_u32vec4) != 16; Error += sizeof(glm::mediump_u64vec2) != 16; Error += sizeof(glm::mediump_u64vec3) != 24; Error += sizeof(glm::mediump_u64vec4) != 32; Error += sizeof(glm::highp_u8vec2) != 2; Error += sizeof(glm::highp_u8vec3) != 3; Error += sizeof(glm::highp_u8vec4) != 4; Error += sizeof(glm::highp_u16vec2) != 4; Error += sizeof(glm::highp_u16vec3) != 6; Error += sizeof(glm::highp_u16vec4) != 8; Error += sizeof(glm::highp_u32vec2) != 8; Error += sizeof(glm::highp_u32vec3) != 12; Error += sizeof(glm::highp_u32vec4) != 16; Error += sizeof(glm::highp_u64vec2) != 16; Error += sizeof(glm::highp_u64vec3) != 24; Error += sizeof(glm::highp_u64vec4) != 32; return Error; } static int test_uvec_precision() { int Error(0); { glm::u8vec2 v1; glm::lowp_u8vec2 v2(v1); glm::mediump_u8vec2 v3(v1); glm::highp_u8vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::u8vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u8vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u8vec2(v4))) ? 0 : 1; } { glm::u8vec3 v1; glm::lowp_u8vec3 v2(v1); glm::mediump_u8vec3 v3(v1); glm::highp_u8vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::u8vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u8vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u8vec3(v4))) ? 0 : 1; } { glm::u8vec4 v1; glm::lowp_u8vec4 v2(v1); glm::mediump_u8vec4 v3(v1); glm::highp_u8vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::u8vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u8vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u8vec4(v4))) ? 0 : 1; } { glm::u16vec2 v1; glm::lowp_u16vec2 v2(v1); glm::mediump_u16vec2 v3(v1); glm::highp_u16vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::u16vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u16vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u16vec2(v4))) ? 0 : 1; } { glm::u16vec3 v1; glm::lowp_u16vec3 v2(v1); glm::mediump_u16vec3 v3(v1); glm::highp_u16vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::u16vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u16vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u16vec3(v4))) ? 0 : 1; } { glm::u16vec4 v1; glm::lowp_u16vec4 v2(v1); glm::mediump_u16vec4 v3(v1); glm::highp_u16vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::u16vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u16vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u16vec4(v4))) ? 0 : 1; } { glm::u32vec2 v1; glm::lowp_u32vec2 v2(v1); glm::mediump_u32vec2 v3(v1); glm::highp_u32vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::u32vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u32vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u32vec2(v4))) ? 0 : 1; } { glm::u32vec3 v1; glm::lowp_u32vec3 v2(v1); glm::mediump_u32vec3 v3(v1); glm::highp_u32vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::u32vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u32vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u32vec3(v4))) ? 0 : 1; } { glm::u32vec4 v1; glm::lowp_u32vec4 v2(v1); glm::mediump_u32vec4 v3(v1); glm::highp_u32vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::u32vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u32vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u32vec4(v4))) ? 0 : 1; } { glm::u64vec2 v1; glm::lowp_u64vec2 v2(v1); glm::mediump_u64vec2 v3(v1); glm::highp_u64vec2 v4(v1); Error += glm::all(glm::equal(v1, glm::u64vec2(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u64vec2(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u64vec2(v4))) ? 0 : 1; } { glm::u64vec3 v1; glm::lowp_u64vec3 v2(v1); glm::mediump_u64vec3 v3(v1); glm::highp_u64vec3 v4(v1); Error += glm::all(glm::equal(v1, glm::u64vec3(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u64vec3(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u64vec3(v4))) ? 0 : 1; } { glm::u64vec4 v1; glm::lowp_u64vec4 v2(v1); glm::mediump_u64vec4 v3(v1); glm::highp_u64vec4 v4(v1); Error += glm::all(glm::equal(v1, glm::u64vec4(v2))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u64vec4(v3))) ? 0 : 1; Error += glm::all(glm::equal(v1, glm::u64vec4(v4))) ? 0 : 1; } return Error; } static int test_fmat_size() { int Error(0); Error += sizeof(glm::mat2) != 16; Error += sizeof(glm::mat3) != 36; Error += sizeof(glm::mat4) != 64; Error += sizeof(glm::mat2x2) != 16; Error += sizeof(glm::mat2x3) != 24; Error += sizeof(glm::mat2x4) != 32; Error += sizeof(glm::mat3x2) != 24; Error += sizeof(glm::mat3x3) != 36; Error += sizeof(glm::mat3x4) != 48; Error += sizeof(glm::mat4x2) != 32; Error += sizeof(glm::mat4x3) != 48; Error += sizeof(glm::mat4x4) != 64; Error += sizeof(glm::fmat2) != 16; Error += sizeof(glm::fmat3) != 36; Error += sizeof(glm::fmat4) != 64; Error += sizeof(glm::fmat2x2) != 16; Error += sizeof(glm::fmat2x3) != 24; Error += sizeof(glm::fmat2x4) != 32; Error += sizeof(glm::fmat3x2) != 24; Error += sizeof(glm::fmat3x3) != 36; Error += sizeof(glm::fmat3x4) != 48; Error += sizeof(glm::fmat4x2) != 32; Error += sizeof(glm::fmat4x3) != 48; Error += sizeof(glm::fmat4x4) != 64; Error += sizeof(glm::f32mat2) != 16; Error += sizeof(glm::f32mat3) != 36; Error += sizeof(glm::f32mat4) != 64; Error += sizeof(glm::f32mat2x2) != 16; Error += sizeof(glm::f32mat2x3) != 24; Error += sizeof(glm::f32mat2x4) != 32; Error += sizeof(glm::f32mat3x2) != 24; Error += sizeof(glm::f32mat3x3) != 36; Error += sizeof(glm::f32mat3x4) != 48; Error += sizeof(glm::f32mat4x2) != 32; Error += sizeof(glm::f32mat4x3) != 48; Error += sizeof(glm::f32mat4x4) != 64; Error += sizeof(glm::lowp_mat2) != 16; Error += sizeof(glm::lowp_mat3) != 36; Error += sizeof(glm::lowp_mat4) != 64; Error += sizeof(glm::lowp_mat2x2) != 16; Error += sizeof(glm::lowp_mat2x3) != 24; Error += sizeof(glm::lowp_mat2x4) != 32; Error += sizeof(glm::lowp_mat3x2) != 24; Error += sizeof(glm::lowp_mat3x3) != 36; Error += sizeof(glm::lowp_mat3x4) != 48; Error += sizeof(glm::lowp_mat4x2) != 32; Error += sizeof(glm::lowp_mat4x3) != 48; Error += sizeof(glm::lowp_mat4x4) != 64; Error += sizeof(glm::lowp_fmat2) != 16; Error += sizeof(glm::lowp_fmat3) != 36; Error += sizeof(glm::lowp_fmat4) != 64; Error += sizeof(glm::lowp_fmat2x2) != 16; Error += sizeof(glm::lowp_fmat2x3) != 24; Error += sizeof(glm::lowp_fmat2x4) != 32; Error += sizeof(glm::lowp_fmat3x2) != 24; Error += sizeof(glm::lowp_fmat3x3) != 36; Error += sizeof(glm::lowp_fmat3x4) != 48; Error += sizeof(glm::lowp_fmat4x2) != 32; Error += sizeof(glm::lowp_fmat4x3) != 48; Error += sizeof(glm::lowp_fmat4x4) != 64; Error += sizeof(glm::lowp_f32mat2) != 16; Error += sizeof(glm::lowp_f32mat3) != 36; Error += sizeof(glm::lowp_f32mat4) != 64; Error += sizeof(glm::lowp_f32mat2x2) != 16; Error += sizeof(glm::lowp_f32mat2x3) != 24; Error += sizeof(glm::lowp_f32mat2x4) != 32; Error += sizeof(glm::lowp_f32mat3x2) != 24; Error += sizeof(glm::lowp_f32mat3x3) != 36; Error += sizeof(glm::lowp_f32mat3x4) != 48; Error += sizeof(glm::lowp_f32mat4x2) != 32; Error += sizeof(glm::lowp_f32mat4x3) != 48; Error += sizeof(glm::lowp_f32mat4x4) != 64; Error += sizeof(glm::mediump_mat2) != 16; Error += sizeof(glm::mediump_mat3) != 36; Error += sizeof(glm::mediump_mat4) != 64; Error += sizeof(glm::mediump_mat2x2) != 16; Error += sizeof(glm::mediump_mat2x3) != 24; Error += sizeof(glm::mediump_mat2x4) != 32; Error += sizeof(glm::mediump_mat3x2) != 24; Error += sizeof(glm::mediump_mat3x3) != 36; Error += sizeof(glm::mediump_mat3x4) != 48; Error += sizeof(glm::mediump_mat4x2) != 32; Error += sizeof(glm::mediump_mat4x3) != 48; Error += sizeof(glm::mediump_mat4x4) != 64; Error += sizeof(glm::mediump_fmat2) != 16; Error += sizeof(glm::mediump_fmat3) != 36; Error += sizeof(glm::mediump_fmat4) != 64; Error += sizeof(glm::mediump_fmat2x2) != 16; Error += sizeof(glm::mediump_fmat2x3) != 24; Error += sizeof(glm::mediump_fmat2x4) != 32; Error += sizeof(glm::mediump_fmat3x2) != 24; Error += sizeof(glm::mediump_fmat3x3) != 36; Error += sizeof(glm::mediump_fmat3x4) != 48; Error += sizeof(glm::mediump_fmat4x2) != 32; Error += sizeof(glm::mediump_fmat4x3) != 48; Error += sizeof(glm::mediump_fmat4x4) != 64; Error += sizeof(glm::mediump_f32mat2) != 16; Error += sizeof(glm::mediump_f32mat3) != 36; Error += sizeof(glm::mediump_f32mat4) != 64; Error += sizeof(glm::mediump_f32mat2x2) != 16; Error += sizeof(glm::mediump_f32mat2x3) != 24; Error += sizeof(glm::mediump_f32mat2x4) != 32; Error += sizeof(glm::mediump_f32mat3x2) != 24; Error += sizeof(glm::mediump_f32mat3x3) != 36; Error += sizeof(glm::mediump_f32mat3x4) != 48; Error += sizeof(glm::mediump_f32mat4x2) != 32; Error += sizeof(glm::mediump_f32mat4x3) != 48; Error += sizeof(glm::mediump_f32mat4x4) != 64; Error += sizeof(glm::highp_mat2) != 16; Error += sizeof(glm::highp_mat3) != 36; Error += sizeof(glm::highp_mat4) != 64; Error += sizeof(glm::highp_mat2x2) != 16; Error += sizeof(glm::highp_mat2x3) != 24; Error += sizeof(glm::highp_mat2x4) != 32; Error += sizeof(glm::highp_mat3x2) != 24; Error += sizeof(glm::highp_mat3x3) != 36; Error += sizeof(glm::highp_mat3x4) != 48; Error += sizeof(glm::highp_mat4x2) != 32; Error += sizeof(glm::highp_mat4x3) != 48; Error += sizeof(glm::highp_mat4x4) != 64; Error += sizeof(glm::highp_fmat2) != 16; Error += sizeof(glm::highp_fmat3) != 36; Error += sizeof(glm::highp_fmat4) != 64; Error += sizeof(glm::highp_fmat2x2) != 16; Error += sizeof(glm::highp_fmat2x3) != 24; Error += sizeof(glm::highp_fmat2x4) != 32; Error += sizeof(glm::highp_fmat3x2) != 24; Error += sizeof(glm::highp_fmat3x3) != 36; Error += sizeof(glm::highp_fmat3x4) != 48; Error += sizeof(glm::highp_fmat4x2) != 32; Error += sizeof(glm::highp_fmat4x3) != 48; Error += sizeof(glm::highp_fmat4x4) != 64; Error += sizeof(glm::highp_f32mat2) != 16; Error += sizeof(glm::highp_f32mat3) != 36; Error += sizeof(glm::highp_f32mat4) != 64; Error += sizeof(glm::highp_f32mat2x2) != 16; Error += sizeof(glm::highp_f32mat2x3) != 24; Error += sizeof(glm::highp_f32mat2x4) != 32; Error += sizeof(glm::highp_f32mat3x2) != 24; Error += sizeof(glm::highp_f32mat3x3) != 36; Error += sizeof(glm::highp_f32mat3x4) != 48; Error += sizeof(glm::highp_f32mat4x2) != 32; Error += sizeof(glm::highp_f32mat4x3) != 48; Error += sizeof(glm::highp_f32mat4x4) != 64; return Error; } static int test_dmat_size() { int Error(0); Error += sizeof(glm::f64mat2) != 32; Error += sizeof(glm::f64mat3) != 72; Error += sizeof(glm::f64mat4) != 128; Error += sizeof(glm::f64mat2x2) != 32; Error += sizeof(glm::f64mat2x3) != 48; Error += sizeof(glm::f64mat2x4) != 64; Error += sizeof(glm::f64mat3x2) != 48; Error += sizeof(glm::f64mat3x3) != 72; Error += sizeof(glm::f64mat3x4) != 96; Error += sizeof(glm::f64mat4x2) != 64; Error += sizeof(glm::f64mat4x3) != 96; Error += sizeof(glm::f64mat4x4) != 128; Error += sizeof(glm::lowp_f64mat2) != 32; Error += sizeof(glm::lowp_f64mat3) != 72; Error += sizeof(glm::lowp_f64mat4) != 128; Error += sizeof(glm::lowp_f64mat2x2) != 32; Error += sizeof(glm::lowp_f64mat2x3) != 48; Error += sizeof(glm::lowp_f64mat2x4) != 64; Error += sizeof(glm::lowp_f64mat3x2) != 48; Error += sizeof(glm::lowp_f64mat3x3) != 72; Error += sizeof(glm::lowp_f64mat3x4) != 96; Error += sizeof(glm::lowp_f64mat4x2) != 64; Error += sizeof(glm::lowp_f64mat4x3) != 96; Error += sizeof(glm::lowp_f64mat4x4) != 128; Error += sizeof(glm::mediump_f64mat2) != 32; Error += sizeof(glm::mediump_f64mat3) != 72; Error += sizeof(glm::mediump_f64mat4) != 128; Error += sizeof(glm::mediump_f64mat2x2) != 32; Error += sizeof(glm::mediump_f64mat2x3) != 48; Error += sizeof(glm::mediump_f64mat2x4) != 64; Error += sizeof(glm::mediump_f64mat3x2) != 48; Error += sizeof(glm::mediump_f64mat3x3) != 72; Error += sizeof(glm::mediump_f64mat3x4) != 96; Error += sizeof(glm::mediump_f64mat4x2) != 64; Error += sizeof(glm::mediump_f64mat4x3) != 96; Error += sizeof(glm::mediump_f64mat4x4) != 128; Error += sizeof(glm::highp_f64mat2) != 32; Error += sizeof(glm::highp_f64mat3) != 72; Error += sizeof(glm::highp_f64mat4) != 128; Error += sizeof(glm::highp_f64mat2x2) != 32; Error += sizeof(glm::highp_f64mat2x3) != 48; Error += sizeof(glm::highp_f64mat2x4) != 64; Error += sizeof(glm::highp_f64mat3x2) != 48; Error += sizeof(glm::highp_f64mat3x3) != 72; Error += sizeof(glm::highp_f64mat3x4) != 96; Error += sizeof(glm::highp_f64mat4x2) != 64; Error += sizeof(glm::highp_f64mat4x3) != 96; Error += sizeof(glm::highp_f64mat4x4) != 128; return Error; } static int test_quat_size() { int Error = 0; Error += sizeof(glm::f32quat) != 16; Error += sizeof(glm::f64quat) != 32; Error += sizeof(glm::lowp_f32quat) != 16; Error += sizeof(glm::lowp_f64quat) != 32; Error += sizeof(glm::mediump_f32quat) != 16; Error += sizeof(glm::mediump_f64quat) != 32; Error += sizeof(glm::highp_f32quat) != 16; Error += sizeof(glm::highp_f64quat) != 32; return Error; } static int test_quat_precision() { int Error(0); { glm::f32quat q1; glm::lowp_f32quat qA(q1); glm::mediump_f32quat qB(q1); glm::highp_f32quat qC(q1); glm::f32quat q2(qA); glm::f32quat q3(qB); glm::f32quat q4(qC); Error += glm::all(glm::equal(q1, q2)) ? 0 : 1; Error += glm::all(glm::equal(q1, q3)) ? 0 : 1; Error += glm::all(glm::equal(q1, q4)) ? 0 : 1; } return Error; } static int test_fvec_conversion() { int Error(0); { glm::highp_vec4 a = glm::vec4(1, 2, 3, 4); glm::mediump_vec4 b = glm::vec4(1, 2, 3, 4); glm::lowp_vec4 c = b; glm::mediump_vec4 d = c; glm::lowp_ivec4 e = glm::ivec4(d); glm::lowp_ivec3 f = glm::ivec3(e); Error += glm::all(glm::equal(b, d)) ? 0 : 1; } return Error; } static int test_openmp() { std::vector VectorA(1000); std::vector VectorB(1000); std::vector VectorC(1000); for (std::size_t i = 0; i < VectorA.size(); ++i) { VectorA[i] = glm::u8vec3(1, 1, 1); VectorB[i] = glm::u8vec3(1, 1, 1); } #pragma omp parallel for default(none) shared(VectorA, VectorB, VectorC) for (int i = 0; i < VectorC.size(); ++i) { VectorC[i] = VectorA[i] + VectorB[i]; } return 0; } int main() { int Error(0); Error += test_openmp(); Error += test_scalar_size(); Error += test_fvec_size(); Error += test_fvec_precision(); Error += test_fvec_conversion(); Error += test_dvec_precision(); Error += test_ivec_size(); Error += test_ivec_precision(); Error += test_uvec_size(); Error += test_uvec_precision(); Error += test_fmat_size(); Error += test_dmat_size(); Error += test_quat_size(); Error += test_quat_precision(); return Error; } glm/test/gtc/gtc_round.cpp0000644000000000000000000002165712605253634014600 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_round.cpp /// @date 2014-11-03 / 2014-11-03 /// @author Christophe Riccio /// /// @see core (dependence) /// @see gtc_round (dependence) /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include namespace isPowerOfTwo { template struct type { genType Value; bool Return; }; int test_int16() { type const Data[] = { {0x0001, true}, {0x0002, true}, {0x0004, true}, {0x0080, true}, {0x0000, true}, {0x0003, false} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { bool Result = glm::isPowerOfTwo(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } return Error; } int test_uint16() { type const Data[] = { {0x0001, true}, {0x0002, true}, {0x0004, true}, {0x0000, true}, {0x0000, true}, {0x0003, false} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { bool Result = glm::isPowerOfTwo(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } return Error; } int test_int32() { type const Data[] = { {0x00000001, true}, {0x00000002, true}, {0x00000004, true}, {0x0000000f, false}, {0x00000000, true}, {0x00000003, false} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { bool Result = glm::isPowerOfTwo(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::bvec1 Result = glm::isPowerOfTwo(glm::ivec1(Data[i].Value)); Error += glm::all(glm::equal(glm::bvec1(Data[i].Return), Result)) ? 0 : 1; } for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::bvec2 Result = glm::isPowerOfTwo(glm::ivec2(Data[i].Value)); Error += glm::all(glm::equal(glm::bvec2(Data[i].Return), Result)) ? 0 : 1; } for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::bvec3 Result = glm::isPowerOfTwo(glm::ivec3(Data[i].Value)); Error += glm::all(glm::equal(glm::bvec3(Data[i].Return), Result)) ? 0 : 1; } for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::bvec4 Result = glm::isPowerOfTwo(glm::ivec4(Data[i].Value)); Error += glm::all(glm::equal(glm::bvec4(Data[i].Return), Result)) ? 0 : 1; } return Error; } int test_uint32() { type const Data[] = { {0x00000001, true}, {0x00000002, true}, {0x00000004, true}, {0x80000000, true}, {0x00000000, true}, {0x00000003, false} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { bool Result = glm::isPowerOfTwo(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } return Error; } int test() { int Error(0); Error += test_int16(); Error += test_uint16(); Error += test_int32(); Error += test_uint32(); return Error; } }//isPowerOfTwo namespace ceilPowerOfTwo { template GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value) { genIUType tmp = Value; genIUType result = genIUType(0); while(tmp) { result = (tmp & (~tmp + 1)); // grab lowest bit tmp &= ~result; // clear lowest bit } return result; } template GLM_FUNC_QUALIFIER genType ceilPowerOfTwo_loop(genType value) { return glm::isPowerOfTwo(value) ? value : highestBitValue(value) << 1; } template struct type { genType Value; genType Return; }; int test_int32() { type const Data[] = { {0x0000ffff, 0x00010000}, {-3, -4}, {-8, -8}, {0x00000001, 0x00000001}, {0x00000002, 0x00000002}, {0x00000004, 0x00000004}, {0x00000007, 0x00000008}, {0x0000fff0, 0x00010000}, {0x0000f000, 0x00010000}, {0x08000000, 0x08000000}, {0x00000000, 0x00000000}, {0x00000003, 0x00000004} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::int32 Result = glm::ceilPowerOfTwo(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } return Error; } int test_uint32() { type const Data[] = { {0x00000001, 0x00000001}, {0x00000002, 0x00000002}, {0x00000004, 0x00000004}, {0x00000007, 0x00000008}, {0x0000ffff, 0x00010000}, {0x0000fff0, 0x00010000}, {0x0000f000, 0x00010000}, {0x80000000, 0x80000000}, {0x00000000, 0x00000000}, {0x00000003, 0x00000004} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::uint32 Result = glm::ceilPowerOfTwo(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } return Error; } int perf() { int Error(0); std::vector v; v.resize(100000000); std::clock_t Timestramp0 = std::clock(); for(glm::uint32 i = 0, n = static_cast(v.size()); i < n; ++i) v[i] = ceilPowerOfTwo_loop(i); std::clock_t Timestramp1 = std::clock(); for(glm::uint32 i = 0, n = static_cast(v.size()); i < n; ++i) v[i] = glm::ceilPowerOfTwo(i); std::clock_t Timestramp2 = std::clock(); std::printf("ceilPowerOfTwo_loop: %d clocks\n", static_cast(Timestramp1 - Timestramp0)); std::printf("glm::ceilPowerOfTwo: %d clocks\n", static_cast(Timestramp2 - Timestramp1)); return Error; } int test() { int Error(0); Error += test_int32(); Error += test_uint32(); return Error; } }//namespace ceilPowerOfTwo namespace floorMultiple { template struct type { genType Source; genType Multiple; genType Return; genType Epsilon; }; int test_float() { type const Data[] = { {3.4, 0.3, 3.3, 0.0001}, {-1.4, 0.3, -1.5, 0.0001}, }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::float64 Result = glm::floorMultiple(Data[i].Source, Data[i].Multiple); Error += glm::epsilonEqual(Data[i].Return, Result, Data[i].Epsilon) ? 0 : 1; } return Error; } int test() { int Error(0); Error += test_float(); return Error; } }//namespace floorMultiple namespace ceilMultiple { template struct type { genType Source; genType Multiple; genType Return; genType Epsilon; }; int test_float() { type const Data[] = { {3.4, 0.3, 3.6, 0.0001}, {-1.4, 0.3, -1.2, 0.0001}, }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::float64 Result = glm::ceilMultiple(Data[i].Source, Data[i].Multiple); Error += glm::epsilonEqual(Data[i].Return, Result, Data[i].Epsilon) ? 0 : 1; } return Error; } int test() { int Error(0); Error += test_float(); return Error; } }//namespace ceilMultiple int main() { int Error(0); Error += isPowerOfTwo::test(); Error += ceilPowerOfTwo::test(); # ifdef NDEBUG Error += ceilPowerOfTwo::perf(); # endif//NDEBUG Error += floorMultiple::test(); Error += ceilMultiple::test(); return Error; } glm/test/gtc/gtc_reciprocal.cpp0000644000000000000000000000326112470135714015561 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_reciprocal.cpp /// @date 2012-09-19 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int main() { return 0; } glm/test/gtc/gtc_random.cpp0000644000000000000000000002653112470135714014723 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_random.cpp /// @date 2011-09-19 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #if(GLM_LANG & GLM_LANG_CXX0X_FLAG) # include #endif int test_linearRand() { int Error = 0; glm::int32 const Min = 16; glm::int32 const Max = 32; { glm::u8vec2 AMin(std::numeric_limits::max()); glm::u8vec2 AMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::u8vec2 A = glm::linearRand(glm::u8vec2(Min), glm::u8vec2(Max)); AMin = glm::min(AMin, A); AMax = glm::max(AMax, A); if(!glm::all(glm::lessThanEqual(A, glm::u8vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(A, glm::u8vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(AMin, glm::u8vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(AMax, glm::u8vec2(Max))) ? 0 : 1; assert(!Error); } glm::u16vec2 BMin(std::numeric_limits::max()); glm::u16vec2 BMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::u16vec2 B = glm::linearRand(glm::u16vec2(Min), glm::u16vec2(Max)); BMin = glm::min(BMin, B); BMax = glm::max(BMax, B); if(!glm::all(glm::lessThanEqual(B, glm::u16vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(B, glm::u16vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(BMin, glm::u16vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(BMax, glm::u16vec2(Max))) ? 0 : 1; assert(!Error); } glm::u32vec2 CMin(std::numeric_limits::max()); glm::u32vec2 CMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::u32vec2 C = glm::linearRand(glm::u32vec2(Min), glm::u32vec2(Max)); CMin = glm::min(CMin, C); CMax = glm::max(CMax, C); if(!glm::all(glm::lessThanEqual(C, glm::u32vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(C, glm::u32vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(CMin, glm::u32vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(CMax, glm::u32vec2(Max))) ? 0 : 1; assert(!Error); } glm::u64vec2 DMin(std::numeric_limits::max()); glm::u64vec2 DMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::u64vec2 D = glm::linearRand(glm::u64vec2(Min), glm::u64vec2(Max)); DMin = glm::min(DMin, D); DMax = glm::max(DMax, D); if(!glm::all(glm::lessThanEqual(D, glm::u64vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(D, glm::u64vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(DMin, glm::u64vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(DMax, glm::u64vec2(Max))) ? 0 : 1; assert(!Error); } } { glm::i8vec2 AMin(std::numeric_limits::max()); glm::i8vec2 AMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::i8vec2 A = glm::linearRand(glm::i8vec2(Min), glm::i8vec2(Max)); AMin = glm::min(AMin, A); AMax = glm::max(AMax, A); if(!glm::all(glm::lessThanEqual(A, glm::i8vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(A, glm::i8vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(AMin, glm::i8vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(AMax, glm::i8vec2(Max))) ? 0 : 1; assert(!Error); } glm::i16vec2 BMin(std::numeric_limits::max()); glm::i16vec2 BMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::i16vec2 B = glm::linearRand(glm::i16vec2(Min), glm::i16vec2(Max)); BMin = glm::min(BMin, B); BMax = glm::max(BMax, B); if(!glm::all(glm::lessThanEqual(B, glm::i16vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(B, glm::i16vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(BMin, glm::i16vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(BMax, glm::i16vec2(Max))) ? 0 : 1; assert(!Error); } glm::i32vec2 CMin(std::numeric_limits::max()); glm::i32vec2 CMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::i32vec2 C = glm::linearRand(glm::i32vec2(Min), glm::i32vec2(Max)); CMin = glm::min(CMin, C); CMax = glm::max(CMax, C); if(!glm::all(glm::lessThanEqual(C, glm::i32vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(C, glm::i32vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(CMin, glm::i32vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(CMax, glm::i32vec2(Max))) ? 0 : 1; assert(!Error); } glm::i64vec2 DMin(std::numeric_limits::max()); glm::i64vec2 DMax(std::numeric_limits::min()); { for(std::size_t i = 0; i < 100000; ++i) { glm::i64vec2 D = glm::linearRand(glm::i64vec2(Min), glm::i64vec2(Max)); DMin = glm::min(DMin, D); DMax = glm::max(DMax, D); if(!glm::all(glm::lessThanEqual(D, glm::i64vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(D, glm::i64vec2(Min)))) ++Error; assert(!Error); } Error += glm::all(glm::equal(DMin, glm::i64vec2(Min))) ? 0 : 1; Error += glm::all(glm::equal(DMax, glm::i64vec2(Max))) ? 0 : 1; assert(!Error); } } for(std::size_t i = 0; i < 100000; ++i) { glm::f32vec2 const A(glm::linearRand(glm::f32vec2(static_cast(Min)), glm::f32vec2(static_cast(Max)))); if(!glm::all(glm::lessThanEqual(A, glm::f32vec2(static_cast(Max))))) ++Error; if(!glm::all(glm::greaterThanEqual(A, glm::f32vec2(static_cast(Min))))) ++Error; glm::f64vec2 const B(glm::linearRand(glm::f64vec2(Min), glm::f64vec2(Max))); if(!glm::all(glm::lessThanEqual(B, glm::f64vec2(Max)))) ++Error; if(!glm::all(glm::greaterThanEqual(B, glm::f64vec2(Min)))) ++Error; assert(!Error); } { float ResultFloat = 0.0f; double ResultDouble = 0.0f; for(std::size_t i = 0; i < 100000; ++i) { ResultFloat += glm::linearRand(-1.0f, 1.0f); ResultDouble += glm::linearRand(-1.0, 1.0); } Error += glm::epsilonEqual(ResultFloat, 0.0f, 0.0001f); Error += glm::epsilonEqual(ResultDouble, 0.0, 0.0001); assert(!Error); } return Error; } int test_circularRand() { int Error = 0; { std::size_t Max = 100000; float ResultFloat = 0.0f; double ResultDouble = 0.0f; double Radius = 2.0f; for(std::size_t i = 0; i < Max; ++i) { ResultFloat += glm::length(glm::circularRand(1.0f)); ResultDouble += glm::length(glm::circularRand(Radius)); } Error += glm::epsilonEqual(ResultFloat, float(Max), 0.01f) ? 0 : 1; Error += glm::epsilonEqual(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1; assert(!Error); } return Error; } int test_sphericalRand() { int Error = 0; { std::size_t Max = 100000; float ResultFloatA = 0.0f; float ResultFloatB = 0.0f; float ResultFloatC = 0.0f; double ResultDoubleA = 0.0f; double ResultDoubleB = 0.0f; double ResultDoubleC = 0.0f; for(std::size_t i = 0; i < Max; ++i) { ResultFloatA += glm::length(glm::sphericalRand(1.0f)); ResultDoubleA += glm::length(glm::sphericalRand(1.0)); ResultFloatB += glm::length(glm::sphericalRand(2.0f)); ResultDoubleB += glm::length(glm::sphericalRand(2.0)); ResultFloatC += glm::length(glm::sphericalRand(3.0f)); ResultDoubleC += glm::length(glm::sphericalRand(3.0)); } Error += glm::epsilonEqual(ResultFloatA, float(Max), 0.01f) ? 0 : 1; Error += glm::epsilonEqual(ResultDoubleA, double(Max), 0.0001) ? 0 : 1; Error += glm::epsilonEqual(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1; Error += glm::epsilonEqual(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1; Error += glm::epsilonEqual(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1; Error += glm::epsilonEqual(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1; assert(!Error); } return Error; } int test_diskRand() { int Error = 0; { float ResultFloat = 0.0f; double ResultDouble = 0.0f; for(std::size_t i = 0; i < 100000; ++i) { ResultFloat += glm::length(glm::diskRand(2.0f)); ResultDouble += glm::length(glm::diskRand(2.0)); } Error += ResultFloat < 200000.f ? 0 : 1; Error += ResultDouble < 200000.0 ? 0 : 1; assert(!Error); } return Error; } int test_ballRand() { int Error = 0; { float ResultFloat = 0.0f; double ResultDouble = 0.0f; for(std::size_t i = 0; i < 100000; ++i) { ResultFloat += glm::length(glm::ballRand(2.0f)); ResultDouble += glm::length(glm::ballRand(2.0)); } Error += ResultFloat < 200000.f ? 0 : 1; Error += ResultDouble < 200000.0 ? 0 : 1; assert(!Error); } return Error; } /* #if(GLM_LANG & GLM_LANG_CXX0X_FLAG) int test_grid() { int Error = 0; typedef std::array colors; typedef std::array grid; grid Grid; colors Colors; grid GridBest; colors ColorsBest; while(true) { for(std::size_t i = 0; i < Grid.size(); ++i) Grid[i] = int(glm::linearRand(0.0, 8.0 * 8.0 * 8.0 - 1.0) / 64.0); for(std::size_t i = 0; i < Grid.size(); ++i) ++Colors[Grid[i]]; bool Exit = true; for(std::size_t i = 0; i < Colors.size(); ++i) { if(Colors[i] == 8) continue; Exit = false; break; } if(Exit == true) break; } return Error; } #endif */ int main() { int Error = 0; Error += test_linearRand(); Error += test_circularRand(); Error += test_sphericalRand(); Error += test_diskRand(); Error += test_ballRand(); /* #if(GLM_LANG & GLM_LANG_CXX0X_FLAG) Error += test_grid(); #endif */ return Error; } glm/test/gtc/gtc_quaternion.cpp0000644000000000000000000002447412554773746015654 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_quaternion.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #define GLM_META_PROG_HELPERS #include #include #include #include int test_quat_angle() { int Error = 0; { glm::quat Q = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 1)); glm::quat N = glm::normalize(Q); float L = glm::length(N); Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1; float A = glm::angle(N); Error += glm::epsilonEqual(A, glm::pi() * 0.25f, 0.01f) ? 0 : 1; } { glm::quat Q = glm::angleAxis(glm::pi() * 0.25f, glm::normalize(glm::vec3(0, 1, 1))); glm::quat N = glm::normalize(Q); float L = glm::length(N); Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1; float A = glm::angle(N); Error += glm::epsilonEqual(A, glm::pi() * 0.25f, 0.01f) ? 0 : 1; } { glm::quat Q = glm::angleAxis(glm::pi() * 0.25f, glm::normalize(glm::vec3(1, 2, 3))); glm::quat N = glm::normalize(Q); float L = glm::length(N); Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1; float A = glm::angle(N); Error += glm::epsilonEqual(A, glm::pi() * 0.25f, 0.01f) ? 0 : 1; } return Error; } int test_quat_angleAxis() { int Error = 0; glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); glm::quat B = glm::angleAxis(glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::quat C = glm::mix(A, B, 0.5f); glm::quat D = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 1)); Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1; return Error; } int test_quat_mix() { int Error = 0; glm::quat A = glm::angleAxis(0.0f, glm::vec3(0, 0, 1)); glm::quat B = glm::angleAxis(glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::quat C = glm::mix(A, B, 0.5f); glm::quat D = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 1)); Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1; Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1; return Error; } int test_quat_precision() { int Error = 0; Error += sizeof(glm::lowp_quat) <= sizeof(glm::mediump_quat) ? 0 : 1; Error += sizeof(glm::mediump_quat) <= sizeof(glm::highp_quat) ? 0 : 1; return Error; } int test_quat_normalize() { int Error(0); { glm::quat Q = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 1)); glm::quat N = glm::normalize(Q); float L = glm::length(N); Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1; } { glm::quat Q = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(0, 0, 2)); glm::quat N = glm::normalize(Q); float L = glm::length(N); Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1; } { glm::quat Q = glm::angleAxis(glm::pi() * 0.25f, glm::vec3(1, 2, 3)); glm::quat N = glm::normalize(Q); float L = glm::length(N); Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1; } return Error; } int test_quat_euler() { int Error(0); { glm::quat q(1.0f, 0.0f, 0.0f, 1.0f); float Roll = glm::roll(q); float Pitch = glm::pitch(q); float Yaw = glm::yaw(q); glm::vec3 Angles = glm::eulerAngles(q); } { glm::dquat q(1.0f, 0.0f, 0.0f, 1.0f); double Roll = glm::roll(q); double Pitch = glm::pitch(q); double Yaw = glm::yaw(q); glm::dvec3 Angles = glm::eulerAngles(q); } return Error; } int test_quat_slerp() { int Error(0); float const Epsilon = 0.0001f;//glm::epsilon(); float sqrt2 = sqrt(2.0f)/2.0f; glm::quat id; glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f); glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f); // Testing a == 0 // Must be id glm::quat id2 = glm::slerp(id, Y90rot, 0.0f); Error += glm::all(glm::epsilonEqual(id, id2, Epsilon)) ? 0 : 1; // Testing a == 1 // Must be 90° rotation on Y : 0 0.7 0 0.7 glm::quat Y90rot2 = glm::slerp(id, Y90rot, 1.0f); Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot2, Epsilon)) ? 0 : 1; // Testing standard, easy case // Must be 45° rotation on Y : 0 0.38 0 0.92 glm::quat Y45rot1 = glm::slerp(id, Y90rot, 0.5f); // Testing reverse case // Must be 45° rotation on Y : 0 0.38 0 0.92 glm::quat Ym45rot2 = glm::slerp(Y90rot, id, 0.5f); // Testing against full circle around the sphere instead of shortest path // Must be 45° rotation on Y // certainly not a 135° rotation glm::quat Y45rot3 = glm::slerp(id , -Y90rot, 0.5f); float Y45angle3 = glm::angle(Y45rot3); Error += glm::epsilonEqual(Y45angle3, glm::pi() * 0.25f, Epsilon) ? 0 : 1; Error += glm::all(glm::epsilonEqual(Ym45rot2, Y45rot3, Epsilon)) ? 0 : 1; // Same, but inverted // Must also be 45° rotation on Y : 0 0.38 0 0.92 // -0 -0.38 -0 -0.92 is ok too glm::quat Y45rot4 = glm::slerp(-Y90rot, id, 0.5f); Error += glm::all(glm::epsilonEqual(Ym45rot2, -Y45rot4, Epsilon)) ? 0 : 1; // Testing q1 = q2 // Must be 90° rotation on Y : 0 0.7 0 0.7 glm::quat Y90rot3 = glm::slerp(Y90rot, Y90rot, 0.5f); Error += glm::all(glm::epsilonEqual(Y90rot, Y90rot3, Epsilon)) ? 0 : 1; // Testing 180° rotation // Must be 90° rotation on almost any axis that is on the XZ plane glm::quat XZ90rot = glm::slerp(id, -Y90rot, 0.5f); float XZ90angle = glm::angle(XZ90rot); // Must be PI/4 = 0.78; Error += glm::epsilonEqual(XZ90angle, glm::pi() * 0.25f, Epsilon) ? 0 : 1; // Testing almost equal quaternions (this test should pass through the linear interpolation) // Must be 0 0.00X 0 0.99999 glm::quat almostid = glm::slerp(id, glm::angleAxis(0.1f, glm::vec3(0.0f, 1.0f, 0.0f)), 0.5f); // Testing quaternions with opposite sign { glm::quat a(-1, 0, 0, 0); glm::quat result = glm::slerp(a, id, 0.5f); Error += glm::epsilonEqual(glm::pow(glm::dot(id, result), 2.f), 1.f, 0.01f) ? 0 : 1; } return Error; } int test_quat_mul() { int Error(0); glm::quat temp1 = glm::normalize(glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0))); glm::quat temp2 = glm::normalize(glm::quat(0.5f, glm::vec3(1.0, 0.0, 0.0))); glm::vec3 transformed0 = (temp1 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp1)); glm::vec3 temp4 = temp2 * transformed0 * glm::inverse(temp2); glm::quat temp5 = glm::normalize(temp1 * temp2); glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5); # ifndef GLM_FORCE_NO_CTOR_INIT { glm::quat temp7; temp7 *= temp5; temp7 *= glm::inverse(temp5); Error += temp7 != glm::quat(); } # endif return Error; } int test_quat_two_axis_ctr() { int Error(0); glm::quat q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0)); glm::vec3 v1 = q1 * glm::vec3(1, 0, 0); Error += glm::all(glm::epsilonEqual(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1; glm::quat q2 = q1 * q1; glm::vec3 v2 = q2 * glm::vec3(1, 0, 0); Error += glm::all(glm::epsilonEqual(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1; return Error; } int test_quat_type() { glm::quat A; glm::dquat B; return 0; } int test_quat_mul_vec() { int Error(0); glm::quat q = glm::angleAxis(glm::pi() * 0.5f, glm::vec3(0, 0, 1)); glm::vec3 v(1, 0, 0); glm::vec3 u(q * v); glm::vec3 w(u * q); Error += glm::all(glm::epsilonEqual(v, w, 0.01f)) ? 0 : 1; return Error; } int test_quat_ctr() { int Error(0); # if GLM_HAS_TRIVIAL_QUERIES // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_default_constructible::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; // Error += std::is_trivially_copy_assignable::value ? 0 : 1; Error += std::is_trivially_copyable::value ? 0 : 1; Error += std::is_trivially_copyable::value ? 0 : 1; Error += std::is_copy_constructible::value ? 0 : 1; Error += std::is_copy_constructible::value ? 0 : 1; # endif # if GLM_HAS_INITIALIZER_LISTS { glm::quat A{0, 1, 2, 3}; std::vector B{ {0, 1, 2, 3}, {0, 1, 2, 3}}; } # endif//GLM_HAS_INITIALIZER_LISTS return Error; } int main() { int Error(0); #ifdef GLM_META_PROG_HELPERS assert(glm::quat::components == 4); assert(glm::quat::components == glm::quat().length()); #endif Error += test_quat_ctr(); Error += test_quat_mul_vec(); Error += test_quat_two_axis_ctr(); Error += test_quat_mul(); Error += test_quat_precision(); Error += test_quat_type(); Error += test_quat_angle(); Error += test_quat_angleAxis(); Error += test_quat_mix(); Error += test_quat_normalize(); Error += test_quat_euler(); Error += test_quat_slerp(); return Error; } glm/test/gtc/gtc_packing.cpp0000644000000000000000000003111412642261004015041 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_packing.cpp /// @date 2013-08-09 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include void print_bits(float const & s) { union { float f; unsigned int i; } uif; uif.f = s; printf("f32: "); for(std::size_t j = sizeof(s) * 8; j > 0; --j) { if(j == 23 || j == 31) printf(" "); printf("%d", (uif.i & (1 << (j - 1))) ? 1 : 0); } } void print_10bits(glm::uint const & s) { printf("10b: "); for(std::size_t j = 10; j > 0; --j) { if(j == 5) printf(" "); printf("%d", (s & (1 << (j - 1))) ? 1 : 0); } } void print_11bits(glm::uint const & s) { printf("11b: "); for(std::size_t j = 11; j > 0; --j) { if(j == 6) printf(" "); printf("%d", (s & (1 << (j - 1))) ? 1 : 0); } } void print_value(float const & s) { printf("%2.5f, ", s); print_bits(s); printf(", "); // print_11bits(detail::floatTo11bit(s)); // printf(", "); // print_10bits(detail::floatTo10bit(s)); printf("\n"); } int test_Half1x16() { int Error = 0; std::vector Tests; Tests.push_back(0.0f); Tests.push_back(1.0f); Tests.push_back(-1.0f); Tests.push_back(2.0f); Tests.push_back(-2.0f); Tests.push_back(1.9f); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint32 p0 = glm::packHalf1x16(Tests[i]); float v0 = glm::unpackHalf1x16(p0); glm::uint32 p1 = glm::packHalf1x16(v0); float v1 = glm::unpackHalf1x16(p1); Error += (v0 == v1) ? 0 : 1; } return Error; } int test_Half4x16() { int Error = 0; std::vector Tests; Tests.push_back(glm::vec4(1.0f)); Tests.push_back(glm::vec4(0.0f)); Tests.push_back(glm::vec4(2.0f)); Tests.push_back(glm::vec4(0.1f)); Tests.push_back(glm::vec4(0.5f)); Tests.push_back(glm::vec4(-0.9f)); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint64 p0 = glm::packHalf4x16(Tests[i]); glm::vec4 v0 = glm::unpackHalf4x16(p0); glm::uint64 p1 = glm::packHalf4x16(v0); glm::vec4 v1 = glm::unpackHalf4x16(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } return Error; } int test_I3x10_1x2() { int Error = 0; std::vector Tests; Tests.push_back(glm::ivec4(0)); Tests.push_back(glm::ivec4(1)); Tests.push_back(glm::ivec4(-1)); Tests.push_back(glm::ivec4(2)); Tests.push_back(glm::ivec4(-2)); Tests.push_back(glm::ivec4(3)); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint32 p0 = glm::packI3x10_1x2(Tests[i]); glm::ivec4 v0 = glm::unpackI3x10_1x2(p0); glm::uint32 p1 = glm::packI3x10_1x2(v0); glm::ivec4 v1 = glm::unpackI3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } return Error; } int test_U3x10_1x2() { int Error = 0; std::vector Tests; Tests.push_back(glm::uvec4(0)); Tests.push_back(glm::uvec4(1)); Tests.push_back(glm::uvec4(2)); Tests.push_back(glm::uvec4(3)); Tests.push_back(glm::uvec4(4)); Tests.push_back(glm::uvec4(5)); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint32 p0 = glm::packU3x10_1x2(Tests[i]); glm::uvec4 v0 = glm::unpackU3x10_1x2(p0); glm::uint32 p1 = glm::packU3x10_1x2(v0); glm::uvec4 v1 = glm::unpackU3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } return Error; } int test_Snorm3x10_1x2() { int Error = 0; std::vector Tests; Tests.push_back(glm::vec4(1.0f)); Tests.push_back(glm::vec4(0.0f)); Tests.push_back(glm::vec4(2.0f)); Tests.push_back(glm::vec4(0.1f)); Tests.push_back(glm::vec4(0.5f)); Tests.push_back(glm::vec4(0.9f)); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint32 p0 = glm::packSnorm3x10_1x2(Tests[i]); glm::vec4 v0 = glm::unpackSnorm3x10_1x2(p0); glm::uint32 p1 = glm::packSnorm3x10_1x2(v0); glm::vec4 v1 = glm::unpackSnorm3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } return Error; } int test_Unorm3x10_1x2() { int Error = 0; std::vector Tests; Tests.push_back(glm::vec4(1.0f)); Tests.push_back(glm::vec4(0.0f)); Tests.push_back(glm::vec4(2.0f)); Tests.push_back(glm::vec4(0.1f)); Tests.push_back(glm::vec4(0.5f)); Tests.push_back(glm::vec4(0.9f)); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint32 p0 = glm::packUnorm3x10_1x2(Tests[i]); glm::vec4 v0 = glm::unpackUnorm3x10_1x2(p0); glm::uint32 p1 = glm::packUnorm3x10_1x2(v0); glm::vec4 v1 = glm::unpackUnorm3x10_1x2(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } return Error; } int test_F2x11_1x10() { int Error = 0; std::vector Tests; Tests.push_back(glm::vec3(1.0f)); Tests.push_back(glm::vec3(0.0f)); Tests.push_back(glm::vec3(2.0f)); Tests.push_back(glm::vec3(0.1f)); Tests.push_back(glm::vec3(0.5f)); Tests.push_back(glm::vec3(0.9f)); for(std::size_t i = 0; i < Tests.size(); ++i) { glm::uint32 p0 = glm::packF2x11_1x10(Tests[i]); glm::vec3 v0 = glm::unpackF2x11_1x10(p0); glm::uint32 p1 = glm::packF2x11_1x10(v0); glm::vec3 v1 = glm::unpackF2x11_1x10(p1); Error += glm::all(glm::equal(v0, v1)) ? 0 : 1; } return Error; } int test_packUnorm1x16() { int Error = 0; std::vector A; A.push_back(glm::vec1(1.0f)); A.push_back(glm::vec1(0.5f)); A.push_back(glm::vec1(0.1f)); A.push_back(glm::vec1(0.0f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec1 B(A[i]); glm::uint32 C = glm::packUnorm1x16(B.x); glm::vec1 D(glm::unpackUnorm1x16(C)); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1; assert(!Error); } return Error; } int test_packSnorm1x16() { int Error = 0; std::vector A; A.push_back(glm::vec1( 1.0f)); A.push_back(glm::vec1( 0.0f)); A.push_back(glm::vec1(-0.5f)); A.push_back(glm::vec1(-0.1f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec1 B(A[i]); glm::uint32 C = glm::packSnorm1x16(B.x); glm::vec1 D(glm::unpackSnorm1x16(C)); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1; } return Error; } int test_packUnorm2x16() { int Error = 0; std::vector A; A.push_back(glm::vec2(1.0f, 0.0f)); A.push_back(glm::vec2(0.5f, 0.7f)); A.push_back(glm::vec2(0.1f, 0.2f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec2 B(A[i]); glm::uint32 C = glm::packUnorm2x16(B); glm::vec2 D = glm::unpackUnorm2x16(C); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1; assert(!Error); } return Error; } int test_packSnorm2x16() { int Error = 0; std::vector A; A.push_back(glm::vec2( 1.0f, 0.0f)); A.push_back(glm::vec2(-0.5f,-0.7f)); A.push_back(glm::vec2(-0.1f, 0.1f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec2 B(A[i]); glm::uint32 C = glm::packSnorm2x16(B); glm::vec2 D = glm::unpackSnorm2x16(C); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1; assert(!Error); } return Error; } int test_packUnorm4x16() { int Error = 0; std::vector A; A.push_back(glm::vec4(1.0f)); A.push_back(glm::vec4(0.5f)); A.push_back(glm::vec4(0.1f)); A.push_back(glm::vec4(0.0f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec4 B(A[i]); glm::uint64 C = glm::packUnorm4x16(B); glm::vec4 D(glm::unpackUnorm4x16(C)); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1; assert(!Error); } return Error; } int test_packSnorm4x16() { int Error = 0; std::vector A; A.push_back(glm::vec4( 1.0f, 0.0f, -0.5f, 0.5f)); A.push_back(glm::vec4(-0.3f,-0.7f, 0.3f, 0.7f)); A.push_back(glm::vec4(-0.1f, 0.1f, -0.2f, 0.2f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec4 B(A[i]); glm::uint64 C = glm::packSnorm4x16(B); glm::vec4 D(glm::unpackSnorm4x16(C)); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1; assert(!Error); } return Error; } int test_packUnorm1x8() { int Error = 0; std::vector A; A.push_back(glm::vec1(1.0f)); A.push_back(glm::vec1(0.5f)); A.push_back(glm::vec1(0.0f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec1 B(A[i]); glm::uint8 C = glm::packUnorm1x8(B.x); glm::vec1 D(glm::unpackUnorm1x8(C)); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1; assert(!Error); } return Error; } int test_packSnorm1x8() { int Error = 0; std::vector A; A.push_back(glm::vec1( 1.0f)); A.push_back(glm::vec1(-0.7f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec1 B(A[i]); glm::uint8 C = glm::packSnorm1x8(B.x); glm::vec1 D(glm::unpackSnorm1x8(C)); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1; } return Error; } int test_packUnorm2x8() { int Error = 0; std::vector A; A.push_back(glm::vec2(1.0f, 0.7f)); A.push_back(glm::vec2(0.5f, 0.1f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec2 B(A[i]); glm::uint16 C = glm::packUnorm2x8(B); glm::vec2 D = glm::unpackUnorm2x8(C); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1; assert(!Error); } return Error; } int test_packSnorm2x8() { int Error = 0; std::vector A; A.push_back(glm::vec2( 1.0f, 0.0f)); A.push_back(glm::vec2(-0.7f,-0.1f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec2 B(A[i]); glm::uint16 C = glm::packSnorm2x8(B); glm::vec2 D = glm::unpackSnorm2x8(C); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1; } return Error; } int test_packUnorm4x8() { int Error = 0; std::vector A; A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f)); A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec4 B(A[i]); glm::uint32 C = glm::packUnorm4x8(B); glm::vec4 D = glm::unpackUnorm4x8(C); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1; assert(!Error); } return Error; } int test_packSnorm4x8() { int Error = 0; std::vector A; A.push_back(glm::vec4( 1.0f, 0.0f,-0.5f,-1.0f)); A.push_back(glm::vec4(-0.7f,-0.1f, 0.1f, 0.7f)); for(std::size_t i = 0; i < A.size(); ++i) { glm::vec4 B(A[i]); glm::uint32 C = glm::packSnorm4x8(B); glm::vec4 D = glm::unpackSnorm4x8(C); Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1; assert(!Error); } return Error; } int main() { int Error(0); Error += test_packSnorm1x16(); Error += test_packSnorm2x16(); Error += test_packSnorm4x16(); Error += test_packSnorm1x8(); Error += test_packSnorm2x8(); Error += test_packSnorm4x8(); Error += test_packUnorm1x16(); Error += test_packUnorm2x16(); Error += test_packUnorm4x16(); Error += test_packUnorm1x8(); Error += test_packUnorm2x8(); Error += test_packUnorm4x8(); Error += test_F2x11_1x10(); Error += test_Snorm3x10_1x2(); Error += test_Unorm3x10_1x2(); Error += test_I3x10_1x2(); Error += test_U3x10_1x2(); Error += test_Half1x16(); Error += test_U3x10_1x2(); return Error; } glm/test/gtc/gtc_noise.cpp0000644000000000000000000001733712470135714014564 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_noise.cpp /// @date 2011-04-21 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include int test_simplex() { std::size_t const Size = 256; { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_simplex2d_256.dds"); } { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_simplex3d_256.dds"); } { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_simplex4d_256.dds"); } return 0; } int test_perlin() { std::size_t const Size = 256; { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_perlin2d_256.dds"); } { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_perlin3d_256.dds"); } { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_perlin4d_256.dds"); } return 0; } int test_perlin_pedioric() { std::size_t const Size = 256; { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec2(x / 64.f, y / 64.f), glm::vec2(2.0f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_perlin_pedioric_2d_256.dds"); } { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec3(x / 64.f, y / 64.f, 0.5f), glm::vec3(2.0f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_perlin_pedioric_3d_256.dds"); } { std::vector ImageData(Size * Size * 3); for(std::size_t y = 0; y < Size; ++y) for(std::size_t x = 0; x < Size; ++x) { ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::perlin(glm::vec4(x / 64.f, y / 64.f, 0.5f, 0.5f), glm::vec4(2.0f)) * 128.f + 127.f); ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0]; ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0]; } gli::texture2D Texture(1); Texture[0] = gli::image2D(glm::uvec2(Size), gli::RGB8U); memcpy(Texture[0].data(), &ImageData[0], ImageData.size()); gli::saveDDS9(Texture, "texture_perlin_pedioric_4d_256.dds"); } return 0; } int main() { int Error = 0; Error += test_simplex(); Error += test_perlin(); Error += test_perlin_pedioric(); return Error; } glm/test/gtc/gtc_matrix_transform.cpp0000644000000000000000000000511712470135714017037 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_matrix_transform.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int test_perspective() { int Error = 0; glm::mat4 Projection = glm::perspective(glm::pi() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); return Error; } int test_pick() { int Error = 0; glm::mat4 Pick = glm::pickMatrix(glm::vec2(1, 2), glm::vec2(3, 4), glm::ivec4(0, 0, 320, 240)); return Error; } int test_tweakedInfinitePerspective() { int Error = 0; glm::mat4 ProjectionA = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f); glm::mat4 ProjectionB = glm::tweakedInfinitePerspective(45.f, 640.f/480.f, 1.0f, 0.001f); return Error; } int test_translate() { int Error = 0; glm::lowp_vec3 v(1.0); glm::lowp_mat4 m(0); glm::lowp_mat4 t = glm::translate(m, v); return Error; } int main() { int Error = 0; Error += test_translate(); Error += test_tweakedInfinitePerspective(); Error += test_pick(); Error += test_perspective(); return Error; } glm/test/gtc/gtc_matrix_inverse.cpp0000644000000000000000000000524712605254252016502 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_matrix_inverse.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include int test_affine() { int Error = 0; { glm::mat3 const M( 2.f, 0.f, 0.f, 0.f, 2.f, 0.f, 0.f, 0.f, 1.f); glm::mat3 const A = glm::affineInverse(M); glm::mat3 const I = glm::inverse(M); glm::mat3 const R = glm::affineInverse(A); for(glm::length_t i = 0; i < A.length(); ++i) { Error += glm::all(glm::epsilonEqual(M[i], R[i], 0.01f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(A[i], I[i], 0.01f)) ? 0 : 1; } } { glm::mat4 const M( 2.f, 0.f, 0.f, 0.f, 0.f, 2.f, 0.f, 0.f, 0.f, 0.f, 2.f, 0.f, 0.f, 0.f, 0.f, 1.f); glm::mat4 const A = glm::affineInverse(M); glm::mat4 const I = glm::inverse(M); glm::mat4 const R = glm::affineInverse(A); for(glm::length_t i = 0; i < A.length(); ++i) { Error += glm::all(glm::epsilonEqual(M[i], R[i], 0.01f)) ? 0 : 1; Error += glm::all(glm::epsilonEqual(A[i], I[i], 0.01f)) ? 0 : 1; } } return Error; } int main() { int Error = 0; Error += test_affine(); return Error; } glm/test/gtc/gtc_matrix_integer.cpp0000644000000000000000000000327412470135714016463 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_matrix_integer.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int main() { int Error = 0; return Error; } glm/test/gtc/gtc_matrix_access.cpp0000644000000000000000000002542112470135714016265 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_matrix_access.cpp /// @date 2010-09-16 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include int test_mat2x2_row_set() { int Error = 0; glm::mat2x2 m(1); m = glm::row(m, 0, glm::vec2( 0, 1)); m = glm::row(m, 1, glm::vec2( 4, 5)); Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1; Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1; return Error; } int test_mat2x2_col_set() { int Error = 0; glm::mat2x2 m(1); m = glm::column(m, 0, glm::vec2( 0, 1)); m = glm::column(m, 1, glm::vec2( 4, 5)); Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1; Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1; return Error; } int test_mat2x3_row_set() { int Error = 0; glm::mat2x3 m(1); m = glm::row(m, 0, glm::vec2( 0, 1)); m = glm::row(m, 1, glm::vec2( 4, 5)); m = glm::row(m, 2, glm::vec2( 8, 9)); Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1; Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1; Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1; return Error; } int test_mat2x3_col_set() { int Error = 0; glm::mat2x3 m(1); m = glm::column(m, 0, glm::vec3( 0, 1, 2)); m = glm::column(m, 1, glm::vec3( 4, 5, 6)); Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1; Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1; return Error; } int test_mat2x4_row_set() { int Error = 0; glm::mat2x4 m(1); m = glm::row(m, 0, glm::vec2( 0, 1)); m = glm::row(m, 1, glm::vec2( 4, 5)); m = glm::row(m, 2, glm::vec2( 8, 9)); m = glm::row(m, 3, glm::vec2(12, 13)); Error += glm::row(m, 0) == glm::vec2( 0, 1) ? 0 : 1; Error += glm::row(m, 1) == glm::vec2( 4, 5) ? 0 : 1; Error += glm::row(m, 2) == glm::vec2( 8, 9) ? 0 : 1; Error += glm::row(m, 3) == glm::vec2(12, 13) ? 0 : 1; return Error; } int test_mat2x4_col_set() { int Error = 0; glm::mat2x4 m(1); m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3)); m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7)); Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1; Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1; return Error; } int test_mat3x2_row_set() { int Error = 0; glm::mat3x2 m(1); m = glm::row(m, 0, glm::vec3( 0, 1, 2)); m = glm::row(m, 1, glm::vec3( 4, 5, 6)); Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1; Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1; return Error; } int test_mat3x2_col_set() { int Error = 0; glm::mat3x2 m(1); m = glm::column(m, 0, glm::vec2( 0, 1)); m = glm::column(m, 1, glm::vec2( 4, 5)); m = glm::column(m, 2, glm::vec2( 8, 9)); Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1; Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1; Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1; return Error; } int test_mat3x3_row_set() { int Error = 0; glm::mat3x3 m(1); m = glm::row(m, 0, glm::vec3( 0, 1, 2)); m = glm::row(m, 1, glm::vec3( 4, 5, 6)); m = glm::row(m, 2, glm::vec3( 8, 9, 10)); Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1; Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1; Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1; return Error; } int test_mat3x3_col_set() { int Error = 0; glm::mat3x3 m(1); m = glm::column(m, 0, glm::vec3( 0, 1, 2)); m = glm::column(m, 1, glm::vec3( 4, 5, 6)); m = glm::column(m, 2, glm::vec3( 8, 9, 10)); Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1; Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1; Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1; return Error; } int test_mat3x4_row_set() { int Error = 0; glm::mat3x4 m(1); m = glm::row(m, 0, glm::vec3( 0, 1, 2)); m = glm::row(m, 1, glm::vec3( 4, 5, 6)); m = glm::row(m, 2, glm::vec3( 8, 9, 10)); m = glm::row(m, 3, glm::vec3(12, 13, 14)); Error += glm::row(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1; Error += glm::row(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1; Error += glm::row(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1; Error += glm::row(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1; return Error; } int test_mat3x4_col_set() { int Error = 0; glm::mat3x4 m(1); m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3)); m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7)); m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11)); Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1; Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1; Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1; return Error; } int test_mat4x2_row_set() { int Error = 0; glm::mat4x2 m(1); m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3)); m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7)); Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1; Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1; return Error; } int test_mat4x2_col_set() { int Error = 0; glm::mat4x2 m(1); m = glm::column(m, 0, glm::vec2( 0, 1)); m = glm::column(m, 1, glm::vec2( 4, 5)); m = glm::column(m, 2, glm::vec2( 8, 9)); m = glm::column(m, 3, glm::vec2(12, 13)); Error += glm::column(m, 0) == glm::vec2( 0, 1) ? 0 : 1; Error += glm::column(m, 1) == glm::vec2( 4, 5) ? 0 : 1; Error += glm::column(m, 2) == glm::vec2( 8, 9) ? 0 : 1; Error += glm::column(m, 3) == glm::vec2(12, 13) ? 0 : 1; return Error; } int test_mat4x3_row_set() { int Error = 0; glm::mat4x3 m(1); m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3)); m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7)); m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11)); Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1; Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1; Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1; return Error; } int test_mat4x3_col_set() { int Error = 0; glm::mat4x3 m(1); m = glm::column(m, 0, glm::vec3( 0, 1, 2)); m = glm::column(m, 1, glm::vec3( 4, 5, 6)); m = glm::column(m, 2, glm::vec3( 8, 9, 10)); m = glm::column(m, 3, glm::vec3(12, 13, 14)); Error += glm::column(m, 0) == glm::vec3( 0, 1, 2) ? 0 : 1; Error += glm::column(m, 1) == glm::vec3( 4, 5, 6) ? 0 : 1; Error += glm::column(m, 2) == glm::vec3( 8, 9, 10) ? 0 : 1; Error += glm::column(m, 3) == glm::vec3(12, 13, 14) ? 0 : 1; return Error; } int test_mat4x4_row_set() { int Error = 0; glm::mat4 m(1); m = glm::row(m, 0, glm::vec4( 0, 1, 2, 3)); m = glm::row(m, 1, glm::vec4( 4, 5, 6, 7)); m = glm::row(m, 2, glm::vec4( 8, 9, 10, 11)); m = glm::row(m, 3, glm::vec4(12, 13, 14, 15)); Error += glm::row(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1; Error += glm::row(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1; Error += glm::row(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1; Error += glm::row(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1; return Error; } int test_mat4x4_col_set() { int Error = 0; glm::mat4 m(1); m = glm::column(m, 0, glm::vec4( 0, 1, 2, 3)); m = glm::column(m, 1, glm::vec4( 4, 5, 6, 7)); m = glm::column(m, 2, glm::vec4( 8, 9, 10, 11)); m = glm::column(m, 3, glm::vec4(12, 13, 14, 15)); Error += glm::column(m, 0) == glm::vec4( 0, 1, 2, 3) ? 0 : 1; Error += glm::column(m, 1) == glm::vec4( 4, 5, 6, 7) ? 0 : 1; Error += glm::column(m, 2) == glm::vec4( 8, 9, 10, 11) ? 0 : 1; Error += glm::column(m, 3) == glm::vec4(12, 13, 14, 15) ? 0 : 1; return Error; } int test_mat4x4_row_get() { int Error = 0; glm::mat4 m(1); glm::vec4 A = glm::row(m, 0); Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1; glm::vec4 B = glm::row(m, 1); Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1; glm::vec4 C = glm::row(m, 2); Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1; glm::vec4 D = glm::row(m, 3); Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1; return Error; } int test_mat4x4_col_get() { int Error = 0; glm::mat4 m(1); glm::vec4 A = glm::column(m, 0); Error += A == glm::vec4(1, 0, 0, 0) ? 0 : 1; glm::vec4 B = glm::column(m, 1); Error += B == glm::vec4(0, 1, 0, 0) ? 0 : 1; glm::vec4 C = glm::column(m, 2); Error += C == glm::vec4(0, 0, 1, 0) ? 0 : 1; glm::vec4 D = glm::column(m, 3); Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1; return Error; } int main() { int Error = 0; Error += test_mat2x2_row_set(); Error += test_mat2x2_col_set(); Error += test_mat2x3_row_set(); Error += test_mat2x3_col_set(); Error += test_mat2x4_row_set(); Error += test_mat2x4_col_set(); Error += test_mat3x2_row_set(); Error += test_mat3x2_col_set(); Error += test_mat3x3_row_set(); Error += test_mat3x3_col_set(); Error += test_mat3x4_row_set(); Error += test_mat3x4_col_set(); Error += test_mat4x2_row_set(); Error += test_mat4x2_col_set(); Error += test_mat4x3_row_set(); Error += test_mat4x3_col_set(); Error += test_mat4x4_row_set(); Error += test_mat4x4_col_set(); Error += test_mat4x4_row_get(); Error += test_mat4x4_col_get(); return Error; } glm/test/gtc/gtc_integer.cpp0000644000000000000000000001441012573110716015070 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_integer.cpp /// @date 2014-11-17 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #define GLM_FORCE_INLINE #include #include #include #include #include #include #include #include #include #include #include #include #include namespace log2_ { int test() { int Error = 0; int A0 = static_cast(glm::log2(16.f)); glm::ivec1 B0(glm::log2(glm::vec1(16.f))); glm::ivec2 C0(glm::log2(glm::vec2(16.f))); glm::ivec3 D0(glm::log2(glm::vec3(16.f))); glm::ivec4 E0(glm::log2(glm::vec4(16.f))); int A1 = glm::log2(int(16)); glm::ivec1 B1 = glm::log2(glm::ivec1(16)); glm::ivec2 C1 = glm::log2(glm::ivec2(16)); glm::ivec3 D1 = glm::log2(glm::ivec3(16)); glm::ivec4 E1 = glm::log2(glm::ivec4(16)); Error += A0 == A1 ? 0 : 1; Error += glm::all(glm::equal(B0, B1)) ? 0 : 1; Error += glm::all(glm::equal(C0, C1)) ? 0 : 1; Error += glm::all(glm::equal(D0, D1)) ? 0 : 1; Error += glm::all(glm::equal(E0, E1)) ? 0 : 1; glm::uint64 A2 = glm::log2(glm::uint64(16)); glm::u64vec1 B2 = glm::log2(glm::u64vec1(16)); glm::u64vec2 C2 = glm::log2(glm::u64vec2(16)); glm::u64vec3 D2 = glm::log2(glm::u64vec3(16)); glm::u64vec4 E2 = glm::log2(glm::u64vec4(16)); Error += A2 == glm::uint64(4) ? 0 : 1; Error += glm::all(glm::equal(B2, glm::u64vec1(4))) ? 0 : 1; Error += glm::all(glm::equal(C2, glm::u64vec2(4))) ? 0 : 1; Error += glm::all(glm::equal(D2, glm::u64vec3(4))) ? 0 : 1; Error += glm::all(glm::equal(E2, glm::u64vec4(4))) ? 0 : 1; return Error; } int perf(std::size_t Count) { int Error = 0; { std::vector Result; Result.resize(Count); std::clock_t Begin = clock(); for(int i = 0; i < static_cast(Count); ++i) Result[i] = glm::log2(static_cast(i)); std::clock_t End = clock(); printf("glm::log2: %ld clocks\n", End - Begin); } { std::vector Result; Result.resize(Count); std::clock_t Begin = clock(); for(int i = 0; i < static_cast(Count); ++i) Result[i] = glm::log2(glm::ivec4(i)); std::clock_t End = clock(); printf("glm::log2: %ld clocks\n", End - Begin); } # if GLM_HAS_BITSCAN_WINDOWS { std::vector Result; Result.resize(Count); std::clock_t Begin = clock(); for(std::size_t i = 0; i < Count; ++i) { glm::tvec4 Tmp(glm::uninitialize); _BitScanReverse(&Tmp.x, i); _BitScanReverse(&Tmp.y, i); _BitScanReverse(&Tmp.z, i); _BitScanReverse(&Tmp.w, i); Result[i] = glm::ivec4(Tmp); } std::clock_t End = clock(); printf("glm::log2 inlined: %ld clocks\n", End - Begin); } { std::vector > Result; Result.resize(Count); std::clock_t Begin = clock(); for(std::size_t i = 0; i < Count; ++i) { _BitScanReverse(&Result[i].x, i); _BitScanReverse(&Result[i].y, i); _BitScanReverse(&Result[i].z, i); _BitScanReverse(&Result[i].w, i); } std::clock_t End = clock(); printf("glm::log2 inlined no cast: %ld clocks\n", End - Begin); } { std::vector Result; Result.resize(Count); std::clock_t Begin = clock(); for(std::size_t i = 0; i < Count; ++i) { _BitScanReverse(reinterpret_cast(&Result[i].x), i); _BitScanReverse(reinterpret_cast(&Result[i].y), i); _BitScanReverse(reinterpret_cast(&Result[i].z), i); _BitScanReverse(reinterpret_cast(&Result[i].w), i); } std::clock_t End = clock(); printf("glm::log2 reinterpret: %ld clocks\n", End - Begin); } # endif//GLM_HAS_BITSCAN_WINDOWS { std::vector Result; Result.resize(Count); std::clock_t Begin = clock(); for(std::size_t i = 0; i < Count; ++i) Result[i] = glm::log2(static_cast(i)); std::clock_t End = clock(); printf("glm::log2: %ld clocks\n", End - Begin); } { std::vector Result; Result.resize(Count); std::clock_t Begin = clock(); for(int i = 0; i < static_cast(Count); ++i) Result[i] = glm::log2(glm::vec4(i)); std::clock_t End = clock(); printf("glm::log2: %ld clocks\n", End - Begin); } return Error; } }//namespace log2_ int main() { int Error(0); Error += ::log2_::test(); # ifdef NDEBUG std::size_t const Samples(1000); Error += ::log2_::perf(Samples); # endif//NDEBUG return Error; } glm/test/gtc/gtc_epsilon.cpp0000644000000000000000000000673412470135714015117 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_epsilon.cpp /// @date 2012-09-19 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include int test_defined() { glm::epsilonEqual(glm::vec2(), glm::vec2(), glm::vec2()); glm::epsilonEqual(glm::vec3(), glm::vec3(), glm::vec3()); glm::epsilonEqual(glm::vec4(), glm::vec4(), glm::vec4()); glm::epsilonNotEqual(glm::vec2(), glm::vec2(), glm::vec2()); glm::epsilonNotEqual(glm::vec3(), glm::vec3(), glm::vec3()); glm::epsilonNotEqual(glm::vec4(), glm::vec4(), glm::vec4()); glm::epsilonEqual(glm::vec2(), glm::vec2(), 0.0f); glm::epsilonEqual(glm::vec3(), glm::vec3(), 0.0f); glm::epsilonEqual(glm::vec4(), glm::vec4(), 0.0f); glm::epsilonEqual(glm::quat(), glm::quat(), 0.0f); glm::epsilonNotEqual(glm::vec2(), glm::vec2(), 0.0f); glm::epsilonNotEqual(glm::vec3(), glm::vec3(), 0.0f); glm::epsilonNotEqual(glm::vec4(), glm::vec4(), 0.0f); glm::epsilonNotEqual(glm::quat(), glm::quat(), 0.0f); return 0; } template int test_equal() { int Error(0); { T A = glm::epsilon(); T B = glm::epsilon(); Error += glm::epsilonEqual(A, B, glm::epsilon() * T(2)) ? 0 : 1; } { T A(0); T B = static_cast(0) + glm::epsilon(); Error += glm::epsilonEqual(A, B, glm::epsilon() * T(2)) ? 0 : 1; } { T A(0); T B = static_cast(0) - glm::epsilon(); Error += glm::epsilonEqual(A, B, glm::epsilon() * T(2)) ? 0 : 1; } { T A = static_cast(0) + glm::epsilon(); T B = static_cast(0); Error += glm::epsilonEqual(A, B, glm::epsilon() * T(2)) ? 0 : 1; } { T A = static_cast(0) - glm::epsilon(); T B = static_cast(0); Error += glm::epsilonEqual(A, B, glm::epsilon() * T(2)) ? 0 : 1; } return Error; } int main() { int Error(0); Error += test_defined(); Error += test_equal(); Error += test_equal(); return Error; } glm/test/gtc/gtc_constants.cpp0000644000000000000000000000376412470135714015462 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_constants.cpp /// @date 2012-09-19 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include int test_epsilon() { int Error(0); { float Test = glm::epsilon(); } { double Test = glm::epsilon(); } return Error; } int main() { int Error(0); //float MinHalf = 0.0f; //while (glm::half(MinHalf) == glm::half(0.0f)) // MinHalf += std::numeric_limits::epsilon(); Error += test_epsilon(); return Error; } glm/test/gtc/gtc_color_space.cpp0000644000000000000000000000566712557212370015743 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_color.cpp /// @date 2015-02-10 / 2015-02-10 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include namespace srgb { int test() { int Error(0); glm::vec3 const ColorSourceRGB(1.0, 0.5, 0.0); { glm::vec3 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGB); glm::vec3 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB); Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1; } { glm::vec3 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGB, 2.8f); glm::vec3 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB, 2.8f); Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1; } glm::vec4 const ColorSourceRGBA(1.0, 0.5, 0.0, 1.0); { glm::vec4 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGBA); glm::vec4 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB); Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1; } { glm::vec4 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGBA, 2.8f); glm::vec4 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB, 2.8f); Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1; } return Error; } }//namespace srgb int main() { int Error(0); Error += srgb::test(); return Error; } glm/test/gtc/gtc_bitfield.cpp0000644000000000000000000004635712543534356015243 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2015 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// Restrictions: /// By making use of the Software for military purposes, you choose to make /// a Bunny unhappy. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @file test/gtc/gtc_bitfield.cpp /// @date 2014-10-25 / 2014-11-25 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// #include #include #include #if GLM_ARCH != GLM_ARCH_PURE # include #endif #include #include #include namespace mask { template struct type { genType Value; genType Return; }; inline int mask_zero(int Bits) { return ~((~0) << Bits); } inline int mask_mix(int Bits) { return Bits >= sizeof(int) * 8 ? 0xffffffff : (static_cast(1) << Bits) - static_cast(1); } inline int mask_half(int Bits) { // We do the shift in two steps because 1 << 32 on an int is undefined. int const Half = Bits >> 1; int const Fill = ~0; int const ShiftHaft = (Fill << Half); int const Rest = Bits - Half; int const Reversed = ShiftHaft << Rest; return ~Reversed; } inline int mask_loop(int Bits) { int Mask = 0; for(int Bit = 0; Bit < Bits; ++Bit) Mask |= (static_cast(1) << Bit); return Mask; } int perf() { int const Count = 100000000; std::clock_t Timestamp1 = std::clock(); { std::vector Mask; Mask.resize(Count); for(int i = 0; i < Count; ++i) Mask[i] = mask_mix(i % 32); } std::clock_t Timestamp2 = std::clock(); { std::vector Mask; Mask.resize(Count); for(int i = 0; i < Count; ++i) Mask[i] = mask_loop(i % 32); } std::clock_t Timestamp3 = std::clock(); { std::vector Mask; Mask.resize(Count); for(int i = 0; i < Count; ++i) Mask[i] = glm::mask(i % 32); } std::clock_t Timestamp4 = std::clock(); { std::vector Mask; Mask.resize(Count); for(int i = 0; i < Count; ++i) Mask[i] = mask_zero(i % 32); } std::clock_t Timestamp5 = std::clock(); { std::vector Mask; Mask.resize(Count); for(int i = 0; i < Count; ++i) Mask[i] = mask_half(i % 32); } std::clock_t Timestamp6 = std::clock(); std::clock_t TimeMix = Timestamp2 - Timestamp1; std::clock_t TimeLoop = Timestamp3 - Timestamp2; std::clock_t TimeDefault = Timestamp4 - Timestamp3; std::clock_t TimeZero = Timestamp5 - Timestamp4; std::clock_t TimeHalf = Timestamp6 - Timestamp5; printf("mask[mix]: %d\n", static_cast(TimeMix)); printf("mask[loop]: %d\n", static_cast(TimeLoop)); printf("mask[default]: %d\n", static_cast(TimeDefault)); printf("mask[zero]: %d\n", static_cast(TimeZero)); printf("mask[half]: %d\n", static_cast(TimeHalf)); return TimeDefault < TimeLoop ? 0 : 1; } int test_uint() { type const Data[] = { { 0, 0x00000000}, { 1, 0x00000001}, { 2, 0x00000003}, { 3, 0x00000007}, {31, 0x7fffffff}, {32, 0xffffffff} }; int Error(0); /* mask_zero is sadly not a correct code for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { int Result = mask_zero(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } */ for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { int Result = mask_mix(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { int Result = mask_half(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { int Result = mask_loop(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) { int Result = glm::mask(Data[i].Value); Error += Data[i].Return == Result ? 0 : 1; } return Error; } int test_uvec4() { type const Data[] = { {glm::ivec4( 0), glm::ivec4(0x00000000)}, {glm::ivec4( 1), glm::ivec4(0x00000001)}, {glm::ivec4( 2), glm::ivec4(0x00000003)}, {glm::ivec4( 3), glm::ivec4(0x00000007)}, {glm::ivec4(31), glm::ivec4(0x7fffffff)}, {glm::ivec4(32), glm::ivec4(0xffffffff)} }; int Error(0); for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) { glm::ivec4 Result = glm::mask(Data[i].Value); Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1; } return Error; } int test() { int Error(0); Error += test_uint(); Error += test_uvec4(); return Error; } }//namespace mask namespace bitfieldInterleave3 { template inline RET refBitfieldInterleave(PARAM x, PARAM y, PARAM z) { RET Result = 0; for(RET i = 0; i < sizeof(PARAM) * 8; ++i) { Result |= ((RET(x) & (RET(1U) << i)) << ((i << 1) + 0)); Result |= ((RET(y) & (RET(1U) << i)) << ((i << 1) + 1)); Result |= ((RET(z) & (RET(1U) << i)) << ((i << 1) + 2)); } return Result; } int test() { int Error(0); glm::uint16 x_max = 1 << 11; glm::uint16 y_max = 1 << 11; glm::uint16 z_max = 1 << 11; for(glm::uint16 z = 0; z < z_max; z += 27) for(glm::uint16 y = 0; y < y_max; y += 27) for(glm::uint16 x = 0; x < x_max; x += 27) { glm::uint64 ResultA = refBitfieldInterleave(x, y, z); glm::uint64 ResultB = glm::bitfieldInterleave(x, y, z); Error += ResultA == ResultB ? 0 : 1; } return Error; } } namespace bitfieldInterleave4 { template inline RET loopBitfieldInterleave(PARAM x, PARAM y, PARAM z, PARAM w) { RET const v[4] = {x, y, z, w}; RET Result = 0; for(RET i = 0; i < sizeof(PARAM) * 8; i++) { Result |= ((((v[0] >> i) & 1U)) << ((i << 2) + 0)); Result |= ((((v[1] >> i) & 1U)) << ((i << 2) + 1)); Result |= ((((v[2] >> i) & 1U)) << ((i << 2) + 2)); Result |= ((((v[3] >> i) & 1U)) << ((i << 2) + 3)); } return Result; } int test() { int Error(0); glm::uint16 x_max = 1 << 11; glm::uint16 y_max = 1 << 11; glm::uint16 z_max = 1 << 11; glm::uint16 w_max = 1 << 11; for(glm::uint16 w = 0; w < w_max; w += 27) for(glm::uint16 z = 0; z < z_max; z += 27) for(glm::uint16 y = 0; y < y_max; y += 27) for(glm::uint16 x = 0; x < x_max; x += 27) { glm::uint64 ResultA = loopBitfieldInterleave(x, y, z, w); glm::uint64 ResultB = glm::bitfieldInterleave(x, y, z, w); Error += ResultA == ResultB ? 0 : 1; } return Error; } } namespace bitfieldInterleave { inline glm::uint64 fastBitfieldInterleave(glm::uint32 x, glm::uint32 y) { glm::uint64 REG1; glm::uint64 REG2; REG1 = x; REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF); REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF); REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F); REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333); REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555); REG2 = y; REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF); REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF); REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F); REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333); REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555); return REG1 | (REG2 << 1); } inline glm::uint64 interleaveBitfieldInterleave(glm::uint32 x, glm::uint32 y) { glm::uint64 REG1; glm::uint64 REG2; REG1 = x; REG2 = y; REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF); REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF); REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF); REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF); REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F); REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F); REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333); REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333); REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555); REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555); return REG1 | (REG2 << 1); } inline glm::uint64 loopBitfieldInterleave(glm::uint32 x, glm::uint32 y) { static glm::uint64 const Mask[5] = { 0x5555555555555555, 0x3333333333333333, 0x0F0F0F0F0F0F0F0F, 0x00FF00FF00FF00FF, 0x0000FFFF0000FFFF }; glm::uint64 REG1 = x; glm::uint64 REG2 = y; for(int i = 4; i >= 0; --i) { REG1 = ((REG1 << (1 << i)) | REG1) & Mask[i]; REG2 = ((REG2 << (1 << i)) | REG2) & Mask[i]; } return REG1 | (REG2 << 1); } #if(GLM_ARCH != GLM_ARCH_PURE) inline glm::uint64 sseBitfieldInterleave(glm::uint32 x, glm::uint32 y) { GLM_ALIGN(16) glm::uint32 const Array[4] = {x, 0, y, 0}; __m128i const Mask4 = _mm_set1_epi32(0x0000FFFF); __m128i const Mask3 = _mm_set1_epi32(0x00FF00FF); __m128i const Mask2 = _mm_set1_epi32(0x0F0F0F0F); __m128i const Mask1 = _mm_set1_epi32(0x33333333); __m128i const Mask0 = _mm_set1_epi32(0x55555555); __m128i Reg1; __m128i Reg2; // REG1 = x; // REG2 = y; Reg1 = _mm_load_si128((__m128i*)Array); //REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF); //REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF); Reg2 = _mm_slli_si128(Reg1, 2); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask4); //REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF); //REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF); Reg2 = _mm_slli_si128(Reg1, 1); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask3); //REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F); //REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F); Reg2 = _mm_slli_epi32(Reg1, 4); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask2); //REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333); //REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333); Reg2 = _mm_slli_epi32(Reg1, 2); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask1); //REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555); //REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555); Reg2 = _mm_slli_epi32(Reg1, 1); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask0); //return REG1 | (REG2 << 1); Reg2 = _mm_slli_epi32(Reg1, 1); Reg2 = _mm_srli_si128(Reg2, 8); Reg1 = _mm_or_si128(Reg1, Reg2); GLM_ALIGN(16) glm::uint64 Result[2]; _mm_store_si128((__m128i*)Result, Reg1); return Result[0]; } inline glm::uint64 sseUnalignedBitfieldInterleave(glm::uint32 x, glm::uint32 y) { glm::uint32 const Array[4] = {x, 0, y, 0}; __m128i const Mask4 = _mm_set1_epi32(0x0000FFFF); __m128i const Mask3 = _mm_set1_epi32(0x00FF00FF); __m128i const Mask2 = _mm_set1_epi32(0x0F0F0F0F); __m128i const Mask1 = _mm_set1_epi32(0x33333333); __m128i const Mask0 = _mm_set1_epi32(0x55555555); __m128i Reg1; __m128i Reg2; // REG1 = x; // REG2 = y; Reg1 = _mm_loadu_si128((__m128i*)Array); //REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF); //REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF); Reg2 = _mm_slli_si128(Reg1, 2); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask4); //REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF); //REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF); Reg2 = _mm_slli_si128(Reg1, 1); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask3); //REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F); //REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F); Reg2 = _mm_slli_epi32(Reg1, 4); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask2); //REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333); //REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333); Reg2 = _mm_slli_epi32(Reg1, 2); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask1); //REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555); //REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555); Reg2 = _mm_slli_epi32(Reg1, 1); Reg1 = _mm_or_si128(Reg2, Reg1); Reg1 = _mm_and_si128(Reg1, Mask0); //return REG1 | (REG2 << 1); Reg2 = _mm_slli_epi32(Reg1, 1); Reg2 = _mm_srli_si128(Reg2, 8); Reg1 = _mm_or_si128(Reg1, Reg2); glm::uint64 Result[2]; _mm_storeu_si128((__m128i*)Result, Reg1); return Result[0]; } #endif//(GLM_ARCH != GLM_ARCH_PURE) int test() { { for(glm::uint32 y = 0; y < (1 << 10); ++y) for(glm::uint32 x = 0; x < (1 << 10); ++x) { glm::uint64 A = glm::bitfieldInterleave(x, y); glm::uint64 B = fastBitfieldInterleave(x, y); glm::uint64 C = loopBitfieldInterleave(x, y); glm::uint64 D = interleaveBitfieldInterleave(x, y); assert(A == B); assert(A == C); assert(A == D); # if(GLM_ARCH != GLM_ARCH_PURE) glm::uint64 E = sseBitfieldInterleave(x, y); glm::uint64 F = sseUnalignedBitfieldInterleave(x, y); assert(A == E); assert(A == F); __m128i G = glm::detail::_mm_bit_interleave_si128(_mm_set_epi32(0, y, 0, x)); glm::uint64 Result[2]; _mm_storeu_si128((__m128i*)Result, G); assert(A == Result[0]); # endif//(GLM_ARCH != GLM_ARCH_PURE) } } { for(glm::uint8 y = 0; y < 127; ++y) for(glm::uint8 x = 0; x < 127; ++x) { glm::uint64 A(glm::bitfieldInterleave(glm::uint8(x), glm::uint8(y))); glm::uint64 B(glm::bitfieldInterleave(glm::uint16(x), glm::uint16(y))); glm::uint64 C(glm::bitfieldInterleave(glm::uint32(x), glm::uint32(y))); glm::int64 D(glm::bitfieldInterleave(glm::int8(x), glm::int8(y))); glm::int64 E(glm::bitfieldInterleave(glm::int16(x), glm::int16(y))); glm::int64 F(glm::bitfieldInterleave(glm::int32(x), glm::int32(y))); assert(D == E); assert(D == F); } } return 0; } int perf() { glm::uint32 x_max = 1 << 11; glm::uint32 y_max = 1 << 10; // ALU std::vector Data(x_max * y_max); std::vector Param(x_max * y_max); for(glm::uint32 i = 0; i < Param.size(); ++i) Param[i] = glm::u32vec2(i % x_max, i / y_max); { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = glm::bitfieldInterleave(Param[i].x, Param[i].y); std::clock_t Time = std::clock() - LastTime; std::printf("glm::bitfieldInterleave Time %d clocks\n", static_cast(Time)); } { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = fastBitfieldInterleave(Param[i].x, Param[i].y); std::clock_t Time = std::clock() - LastTime; std::printf("fastBitfieldInterleave Time %d clocks\n", static_cast(Time)); } { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = loopBitfieldInterleave(Param[i].x, Param[i].y); std::clock_t Time = std::clock() - LastTime; std::printf("loopBitfieldInterleave Time %d clocks\n", static_cast(Time)); } { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = interleaveBitfieldInterleave(Param[i].x, Param[i].y); std::clock_t Time = std::clock() - LastTime; std::printf("interleaveBitfieldInterleave Time %d clocks\n", static_cast(Time)); } # if(GLM_ARCH != GLM_ARCH_PURE) { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = sseBitfieldInterleave(Param[i].x, Param[i].y); std::clock_t Time = std::clock() - LastTime; std::printf("sseBitfieldInterleave Time %d clocks\n", static_cast(Time)); } { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = sseUnalignedBitfieldInterleave(Param[i].x, Param[i].y); std::clock_t Time = std::clock() - LastTime; std::printf("sseUnalignedBitfieldInterleave Time %d clocks\n", static_cast(Time)); } # endif//(GLM_ARCH != GLM_ARCH_PURE) { std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < Data.size(); ++i) Data[i] = glm::bitfieldInterleave(Param[i].x, Param[i].y, Param[i].x); std::clock_t Time = std::clock() - LastTime; std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", static_cast(Time)); } # if(GLM_ARCH != GLM_ARCH_PURE && !(GLM_COMPILER & GLM_COMPILER_GCC)) { // SIMD std::vector<__m128i> SimdData; SimdData.resize(x_max * y_max); std::vector<__m128i> SimdParam; SimdParam.resize(x_max * y_max); for(int i = 0; i < SimdParam.size(); ++i) SimdParam[i] = _mm_set_epi32(i % x_max, 0, i / y_max, 0); std::clock_t LastTime = std::clock(); for(std::size_t i = 0; i < SimdData.size(); ++i) SimdData[i] = glm::detail::_mm_bit_interleave_si128(SimdParam[i]); std::clock_t Time = std::clock() - LastTime; std::printf("_mm_bit_interleave_si128 Time %d clocks\n", static_cast(Time)); } # endif//(GLM_ARCH != GLM_ARCH_PURE) return 0; } }//namespace bitfieldInterleave int main() { int Error(0); Error += ::mask::test(); Error += ::bitfieldInterleave3::test(); Error += ::bitfieldInterleave4::test(); Error += ::bitfieldInterleave::test(); //Error += ::bitRevert::test(); # ifdef NDEBUG Error += ::mask::perf(); Error += ::bitfieldInterleave::perf(); # endif//NDEBUG return Error; } glm/test/gtc/CMakeLists.txt0000644000000000000000000000116312557211656014642 0ustar rootrootglmCreateTestGTC(gtc_bitfield) glmCreateTestGTC(gtc_color_space) glmCreateTestGTC(gtc_constants) glmCreateTestGTC(gtc_epsilon) glmCreateTestGTC(gtc_integer) glmCreateTestGTC(gtc_matrix_access) glmCreateTestGTC(gtc_matrix_integer) glmCreateTestGTC(gtc_matrix_inverse) glmCreateTestGTC(gtc_matrix_transform) glmCreateTestGTC(gtc_noise) glmCreateTestGTC(gtc_packing) glmCreateTestGTC(gtc_quaternion) glmCreateTestGTC(gtc_random) glmCreateTestGTC(gtc_round) glmCreateTestGTC(gtc_reciprocal) glmCreateTestGTC(gtc_type_precision) glmCreateTestGTC(gtc_type_ptr) glmCreateTestGTC(gtc_ulp) glmCreateTestGTC(gtc_vec1) glm/test/glm.cppcheck0000644000000000000000000000021612451741412013573 0ustar rootroot glm/test/external/0000755000000000000000000000000012642261102013130 5ustar rootrootglm/test/external/gli/0000755000000000000000000000000012642261102013703 5ustar rootrootglm/test/external/gli/gtx/0000755000000000000000000000000012642261102014505 5ustar rootrootglm/test/external/gli/gtx/wavelet.inl0000644000000000000000000000077612451741412016677 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 /////////////////////////////////////////////////////////////////////////////////////////////////// glm/test/external/gli/gtx/wavelet.hpp0000644000000000000000000000145012451741412016672 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gtx/loader_tga.inl0000644000000000000000000001215612470135714017327 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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(gli::B, gli::G, gli::R, gli::A); if(TexelSize == 32) Image.swizzle(gli::B, gli::G, gli::R, gli::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(gli::B, gli::G, gli::R, gli::A); if(TexelSize == 32) Image.swizzle(gli::B, gli::G, gli::R, gli::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 glm/test/external/gli/gtx/loader_tga.hpp0000644000000000000000000000200612451741412017322 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 #include 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 glm/test/external/gli/gtx/loader_dds9.inl0000644000000000000000000005730512451741412017421 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 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 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 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 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 glm/test/external/gli/gtx/loader_dds9.hpp0000644000000000000000000000214012451741412017411 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 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 glm/test/external/gli/gtx/loader_dds10.inl0000644000000000000000000006116012451741412017463 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 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 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 glm/test/external/gli/gtx/loader_dds10.hpp0000644000000000000000000000200712451741412017463 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 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 glm/test/external/gli/gtx/loader.inl0000644000000000000000000000236112451741412016466 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 ) { 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 glm/test/external/gli/gtx/loader.hpp0000644000000000000000000000206012451741412016467 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gtx/gradient.inl0000644000000000000000000000424212451741412017015 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gtx/gradient.hpp0000644000000000000000000000222612451741412017022 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gtx/gl_texture2d.inl0000644000000000000000000002675512451741412017645 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gtx/gl_texture2d.hpp0000644000000000000000000000206212451741412017633 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gtx/fetch.inl0000644000000000000000000000705112451741412016312 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 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(Data)[TexCoord.x + TexCoord.y * Dimensions.x]; } template 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(Data)[s_below + t_below * Dimensions.x]; genType Value2 = reinterpret_cast(Data)[s_above + t_below * Dimensions.x]; genType Value3 = reinterpret_cast(Data)[s_above + t_above * Dimensions.x]; genType Value4 = reinterpret_cast(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 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 glm/test/external/gli/gtx/fetch.hpp0000644000000000000000000000250512451741412016316 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 genType texelFetch( texture2D const & Texture, texture2D::dimensions_type const & Texcoord, texture2D::level_type const & Level); template genType textureLod( texture2D const & Texture, texture2D::texcoord_type const & Texcoord, texture2D::level_type const & Level); template 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 glm/test/external/gli/gtx/compression.inl0000644000000000000000000000100212451741412017550 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 /////////////////////////////////////////////////////////////////////////////////////////////////// glm/test/external/gli/gtx/compression.hpp0000644000000000000000000000151012451741412017561 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/gli.hpp0000644000000000000000000000201012451741412015165 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/core/0000755000000000000000000000000012642261102014633 5ustar rootrootglm/test/external/gli/core/texture_cube_array.inl0000644000000000000000000000343512451741412021245 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/core/texture_cube_array.hpp0000644000000000000000000000330012451741412021241 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 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 glm/test/external/gli/core/texture_cube.inl0000644000000000000000000000315712451741412020050 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/core/texture_cube.hpp0000644000000000000000000000320312451741412020045 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 Faces; }; }//namespace gli #include "texture_cube.inl" #endif//GLI_CORE_TEXTURE_CUBE_INCLUDED glm/test/external/gli/core/texture2d_array.inl0000644000000000000000000000370012451741412020470 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 glm/test/external/gli/core/texture2d_array.hpp0000644000000000000000000000325412451741412020501 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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::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 Arrays; }; }//namespace gli #include "texture2d_array.inl" #endif//GLI_CORE_TEXTURE2D_ARRAY_INCLUDED glm/test/external/gli/core/texture2d.inl0000644000000000000000000002053712470135714017304 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 inline void texture2D::swizzle(gli::comp X, gli::comp Y, gli::comp Z, gli::comp W) { for(texture2D::level_type Level = 0; Level < this->levels(); ++Level) { genType * Data = reinterpret_cast(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 inline T texture::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 inline T texture(const texture2D& Image2D, const glm::vec2& TexCoord) { texture2D::size_type s_below = texture2D::size_type(std::floor(TexCoord.s * (Image2D.width() - 1))); texture2D::size_type s_above = texture2D::size_type(std::ceil(TexCoord.s * (Image2D.width() - 1))); texture2D::size_type t_below = texture2D::size_type(std::floor(TexCoord.t * (Image2D.height() - 1))); texture2D::size_type t_above = texture2D::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 inline T textureNearest(const texture2D& Image2D, const glm::vec2& TexCoord) { texture2D::size_type s = texture2D::size_type(glm::roundGTX(TexCoord.s * (Image2D.width() - 1))); texture2D::size_type t = texture2D::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 class surface > typename texture2D::value_type & texture2D::image_impl::operator() ( coordType const & Coord ) { } */ /* // template < typename coordType > template < typename genType, template class surface > typename texture2D::value_type const & texture2D::image_impl::operator() ( coordType const & Coord ) const { return value_type(0); } */ /* // template < typename coordType > template < typename genType, template class surface > void texture2D::image_impl::operator() ( coordType const & Coord ) const { } */ //// //template //< // typename genType, // template class surface //> //template //< // typename coordType //> //typename texture2D::value_type const & //texture2D::image_impl::operator() //( // coordType const & Coord //) const //{ // return value_type(0); //} ////////////////// //// texture2D //// //template //< // typename genType, // template class surface //> //typename texture2D::level_type texture2D::levels() const //{ // return this->Mipmaps.size(); //} //// //template //< // typename genType, // template class surface //> //typename texture2D::image & texture2D::operator[] //( // typename texture2D::level_type Level //) //{ // return this->Mipmaps[Level]; //} //// //template //< // typename genType, // template class surface //> //typename texture2D::image const & texture2D::operator[] //( // typename texture2D::level_type Level //) const //{ // return this->Mipmaps[Level]; //} }//namespace wip }//namespace gli glm/test/external/gli/core/texture2d.hpp0000644000000000000000000000527712470135714017315 0ustar rootroot/////////////////////////////////////////////////////////////////////////////////////////////////// // 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 { enum comp { X = 0, R = 0, S = 0, Y = 1, G = 1, T = 1, Z = 2, B = 2, P = 2, W = 3, A = 3, Q = 3 }; //template