PVRTGlobal_8h-source.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  3. <title>PowerVR SDK</title>
  4. <link href="doxygen.css" rel="stylesheet" type="text/css">
  5. <link href="tabs.css" rel="stylesheet" type="text/css">
  6. <table width="100%">
  7. <tr>
  8. <td width="33%">
  9. <p align="left">&nbsp;<a href="http://www.imgtec.com"><img border="0" src="IMGLogo.jpg" width="200" height="30"></a></p>
  10. </td>
  11. <td width="33%">
  12. <p align="center"><font color="#808080" face="Arial" size="2">PowerVR Software Development Kit</a></font></p>
  13. </td>
  14. <td width="34%">
  15. <p align="right"><a href="http://www.powervr.com"><img border="0" src="PVRlogo.jpg" width="200" height="27"></a></p>
  16. </td>
  17. </tr>
  18. </table>
  19. <hr>
  20. </head><body>
  21. <!-- Generated by Doxygen 1.3.6 -->
  22. <div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
  23. <h1>PVRTGlobal.h</h1><a href="PVRTGlobal_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/******************************************************************************</span>
  24. 00002 <span class="comment"></span>
  25. 00003 <span class="comment"> @File PVRTGlobal.h</span>
  26. 00004 <span class="comment"></span>
  27. 00005 <span class="comment"> @Title PVRTGlobal</span>
  28. 00006 <span class="comment"></span>
  29. 00007 <span class="comment"> @Version </span>
  30. 00008 <span class="comment"></span>
  31. 00009 <span class="comment"> @Copyright Copyright (C) Imagination Technologies Limited.</span>
  32. 00010 <span class="comment"></span>
  33. 00011 <span class="comment"> @Platform ANSI compatible</span>
  34. 00012 <span class="comment"></span>
  35. 00013 <span class="comment"> @Description Global defines and typedefs for PVRTools</span>
  36. 00014 <span class="comment"></span>
  37. 00015 <span class="comment">******************************************************************************/</span>
  38. 00016 <span class="preprocessor">#ifndef _PVRTGLOBAL_H_</span>
  39. 00017 <span class="preprocessor"></span><span class="preprocessor">#define _PVRTGLOBAL_H_</span>
  40. 00018 <span class="preprocessor"></span>
  41. 00019 <span class="comment">/*!***************************************************************************</span>
  42. 00020 <span class="comment"> Macros</span>
  43. 00021 <span class="comment">*****************************************************************************/</span>
  44. 00022 <span class="preprocessor">#define PVRT_MIN(a,b) (((a) &lt; (b)) ? (a) : (b))</span>
  45. 00023 <span class="preprocessor"></span><span class="preprocessor">#define PVRT_MAX(a,b) (((a) &gt; (b)) ? (a) : (b))</span>
  46. 00024 <span class="preprocessor"></span><span class="preprocessor">#define PVRT_CLAMP(x, l, h) (PVRT_MIN((h), PVRT_MAX((x), (l))))</span>
  47. 00025 <span class="preprocessor"></span>
  48. <a name="l00026"></a><a class="code" href="PVRTGlobal_8h.html#a0">00026</a> <span class="comment">// avoid warning about unused parameter</span>
  49. <a name="l00027"></a><a class="code" href="PVRTGlobal_8h.html#a1">00027</a> <span class="preprocessor">#define PVRT_UNREFERENCED_PARAMETER(x) ((void) x)</span>
  50. <a name="l00028"></a><a class="code" href="PVRTGlobal_8h.html#a2">00028</a> <span class="preprocessor"></span>
  51. 00029 <span class="preprocessor">#if defined(_WIN32) &amp;&amp; !defined(UNDER_CE) &amp;&amp; !defined(__SYMBIAN32__) &amp;&amp; !defined(__BADA__) &amp;&amp; !defined(__QT__) </span><span class="comment">/* Windows desktop */</span>
  52. 00030 <span class="preprocessor"> #define _CRTDBG_MAP_ALLOC</span>
  53. <a name="l00031"></a><a class="code" href="PVRTGlobal_8h.html#a3">00031</a> <span class="preprocessor"></span><span class="preprocessor"> #include &lt;windows.h&gt;</span>
  54. 00032 <span class="preprocessor"> #include &lt;crtdbg.h&gt;</span>
  55. 00033 <span class="preprocessor"> #include &lt;tchar.h&gt;</span>
  56. 00034 <span class="preprocessor">#endif</span>
  57. 00035 <span class="preprocessor"></span>
  58. 00036 <span class="preprocessor">#if defined(UNDER_CE)</span>
  59. 00037 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;windows.h&gt;</span>
  60. 00038
  61. 00039 <span class="preprocessor">#ifndef _ASSERT</span>
  62. 00040 <span class="preprocessor"></span><span class="preprocessor"> #ifdef _DEBUG</span>
  63. 00041 <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERT(X) { (X) ? 0 : DebugBreak(); }</span>
  64. 00042 <span class="preprocessor"></span><span class="preprocessor"> #else</span>
  65. 00043 <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERT(X)</span>
  66. 00044 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  67. 00045 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  68. 00046 <span class="preprocessor"></span>
  69. 00047 <span class="preprocessor">#ifndef _ASSERTE</span>
  70. 00048 <span class="preprocessor"></span><span class="preprocessor"> #ifdef _DEBUG</span>
  71. 00049 <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERTE _ASSERT</span>
  72. 00050 <span class="preprocessor"></span><span class="preprocessor"> #else</span>
  73. 00051 <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERTE(X)</span>
  74. 00052 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  75. 00053 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  76. 00054 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT0(a,b)</span>
  77. 00055 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT1(a,b,c)</span>
  78. 00056 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT2(a,b,c,d)</span>
  79. 00057 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT3(a,b,c,d,e)</span>
  80. 00058 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT4(a,b,c,d,e,f)</span>
  81. 00059 <span class="preprocessor"></span><span class="preprocessor">#else</span>
  82. 00060 <span class="preprocessor"></span>
  83. 00061 <span class="preprocessor">#if defined(_WIN32) &amp;&amp; !defined(__WINSCW__) &amp;&amp; !defined(__BADA__) &amp;&amp; !defined(__QT__)</span>
  84. 00062 <span class="preprocessor"></span>
  85. 00063 <span class="preprocessor">#else</span>
  86. 00064 <span class="preprocessor"></span><span class="preprocessor">#if defined(__linux__) || defined(__APPLE__)</span>
  87. 00065 <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERT(a)((void)0)</span>
  88. 00066 <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERTE(a)((void)0)</span>
  89. 00067 <span class="preprocessor"></span><span class="preprocessor"> #ifdef _DEBUG</span>
  90. 00068 <span class="preprocessor"></span><span class="preprocessor"> #ifndef _RPT0</span>
  91. 00069 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT0(a,b) printf(b)</span>
  92. 00070 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  93. 00071 <span class="preprocessor"></span><span class="preprocessor"> #ifndef _RPT1</span>
  94. 00072 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT1(a,b,c) printf(b,c)</span>
  95. 00073 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  96. 00074 <span class="preprocessor"></span><span class="preprocessor"> #else</span>
  97. 00075 <span class="preprocessor"></span><span class="preprocessor"> #ifndef _RPT0</span>
  98. 00076 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT0(a,b)((void)0)</span>
  99. 00077 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  100. 00078 <span class="preprocessor"></span><span class="preprocessor"> #ifndef _RPT1</span>
  101. 00079 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT1(a,b,c)((void)0)</span>
  102. 00080 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  103. 00081 <span class="preprocessor"></span><span class="preprocessor"> #endif</span>
  104. 00082 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT2(a,b,c,d)((void)0)</span>
  105. 00083 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT3(a,b,c,d,e)((void)0)</span>
  106. 00084 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT4(a,b,c,d,e,f)((void)0)</span>
  107. 00085 <span class="preprocessor"></span><span class="preprocessor"> #include &lt;stdlib.h&gt;</span>
  108. 00086 <span class="preprocessor"> #include &lt;string.h&gt;</span>
  109. 00087 <span class="preprocessor"> #define BYTE unsigned char</span>
  110. 00088 <span class="preprocessor"></span><span class="preprocessor"> #define WORD unsigned short</span>
  111. 00089 <span class="preprocessor"></span><span class="preprocessor"> #define DWORD unsigned long</span>
  112. 00090 <span class="preprocessor"></span> <span class="keyword">typedef</span> <span class="keyword">struct </span>tagRGBQUAD {
  113. 00091 BYTE rgbBlue;
  114. 00092 BYTE rgbGreen;
  115. 00093 BYTE rgbRed;
  116. 00094 BYTE rgbReserved;
  117. 00095 } RGBQUAD;
  118. 00096 <span class="preprocessor"> #define BOOL int</span>
  119. 00097 <span class="preprocessor"></span><span class="preprocessor"> #define TRUE 1</span>
  120. 00098 <span class="preprocessor"></span><span class="preprocessor"> #define FALSE 0</span>
  121. 00099 <span class="preprocessor"></span><span class="preprocessor">#else</span>
  122. 00100 <span class="preprocessor"></span><span class="preprocessor"> #define _CRT_WARN 0</span>
  123. 00101 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT0(a,b)</span>
  124. 00102 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT1(a,b,c)</span>
  125. 00103 <span class="preprocessor"></span><span class="preprocessor"> #define _RPT2(a,b,c,d)</span>
  126. <a name="l00104"></a><a class="code" href="PVRTGlobal_8h.html#a4">00104</a> <span class="preprocessor"></span><span class="preprocessor"> #define _RPT3(a,b,c,d,e)</span>
  127. <a name="l00105"></a><a class="code" href="PVRTGlobal_8h.html#a5">00105</a> <span class="preprocessor"></span><span class="preprocessor"> #define _RPT4(a,b,c,d,e,f)</span>
  128. <a name="l00106"></a><a class="code" href="PVRTGlobal_8h.html#a6">00106</a> <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERT(X)</span>
  129. <a name="l00107"></a><a class="code" href="PVRTGlobal_8h.html#a7">00107</a> <span class="preprocessor"></span><span class="preprocessor"> #define _ASSERTE(X)</span>
  130. <a name="l00108"></a><a class="code" href="PVRTGlobal_8h.html#a8">00108</a> <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  131. <a name="l00109"></a><a class="code" href="PVRTGlobal_8h.html#a9">00109</a> <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  132. <a name="l00110"></a><a class="code" href="PVRTGlobal_8h.html#a10">00110</a> <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  133. <a name="l00111"></a><a class="code" href="PVRTGlobal_8h.html#a11">00111</a> <span class="preprocessor"></span>
  134. 00112 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
  135. 00113
  136. 00114 <span class="preprocessor">#define FREE(X) { if(X) { free(X); (X) = 0; } }</span>
  137. 00115 <span class="preprocessor"></span>
  138. 00116 <span class="comment">// This macro is used to check at compile time that types are of a certain size</span>
  139. 00117 <span class="comment">// If the size does not equal the expected size, this typedefs an array of size 0</span>
  140. <a name="l00118"></a><a class="code" href="PVRTGlobal_8h.html#a12">00118</a> <span class="comment">// which causes a compile error</span>
  141. 00119 <span class="preprocessor">#define PVRTSIZEASSERT(T, size) typedef int (sizeof_##T)[sizeof(T) == (size)]</span>
  142. 00120 <span class="preprocessor"></span>
  143. 00121
  144. 00122 <span class="comment">/****************************************************************************</span>
  145. <a name="l00123"></a><a class="code" href="PVRTGlobal_8h.html#a13">00123</a> <span class="comment">** Integer types</span>
  146. 00124 <span class="comment">****************************************************************************/</span>
  147. 00125
  148. 00126 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">char</span> <a class="code" href="PVRTGlobal_8h.html#a14">PVRTint8</a>;
  149. 00127 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">short</span> <a class="code" href="PVRTGlobal_8h.html#a15">PVRTint16</a>;
  150. 00128 <span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">int</span> <a class="code" href="PVRTGlobal_8h.html#a16">PVRTint32</a>;
  151. 00129 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="PVRTGlobal_8h.html#a17">PVRTuint8</a>;
  152. <a name="l00130"></a><a class="code" href="PVRTGlobal_8h.html#a14">00130</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="PVRTGlobal_8h.html#a18">PVRTuint16</a>;
  153. <a name="l00131"></a><a class="code" href="PVRTGlobal_8h.html#a15">00131</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="PVRTGlobal_8h.html#a19">PVRTuint32</a>;
  154. <a name="l00132"></a><a class="code" href="PVRTGlobal_8h.html#a16">00132</a>
  155. <a name="l00133"></a><a class="code" href="PVRTGlobal_8h.html#a17">00133</a> <span class="preprocessor">#if !defined(__BADA__) &amp;&amp; (defined(__int64) || defined(_WIN32))</span>
  156. <a name="l00134"></a><a class="code" href="PVRTGlobal_8h.html#a18">00134</a> <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">signed</span> __int64 <a class="code" href="PVRTGlobal_8h.html#a20">PVRTint64</a>;
  157. <a name="l00135"></a><a class="code" href="PVRTGlobal_8h.html#a19">00135</a> <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> __int64 <a class="code" href="PVRTGlobal_8h.html#a21">PVRTuint64</a>;
  158. 00136 <span class="preprocessor">#elif defined(TInt64)</span>
  159. 00137 <span class="preprocessor"></span><span class="keyword">typedef</span> TInt64 <a class="code" href="PVRTGlobal_8h.html#a20">PVRTint64</a>;
  160. 00138 <span class="keyword">typedef</span> TUInt64 <a class="code" href="PVRTGlobal_8h.html#a21">PVRTuint64</a>;
  161. 00139 <span class="preprocessor">#else</span>
  162. 00140 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">signed</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="PVRTGlobal_8h.html#a20">PVRTint64</a>;
  163. 00141 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="PVRTGlobal_8h.html#a21">PVRTuint64</a>;
  164. 00142 <span class="preprocessor">#endif</span>
  165. 00143 <span class="preprocessor"></span>
  166. <a name="l00144"></a><a class="code" href="PVRTGlobal_8h.html#a20">00144</a> <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTint8, 1);
  167. <a name="l00145"></a><a class="code" href="PVRTGlobal_8h.html#a21">00145</a> <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTuint8, 1);
  168. 00146 <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTint16, 2);
  169. 00147 <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTuint16, 2);
  170. 00148 <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTint32, 4);
  171. 00149 <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTuint32, 4);
  172. 00150 <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTint64, 8);
  173. 00151 <a class="code" href="PVRTGlobal_8h.html#a13">PVRTSIZEASSERT</a>(PVRTuint64, 8);
  174. 00152
  175. 00153 <span class="comment">/****************************************************************************</span>
  176. 00154 <span class="comment">** swap template function</span>
  177. 00155 <span class="comment">****************************************************************************/</span>
  178. 00156 <span class="comment">/*!***************************************************************************</span>
  179. 00157 <span class="comment"> @Function PVRTswap</span>
  180. 00158 <span class="comment"> @Input a Type a</span>
  181. 00159 <span class="comment"> @Input b Type b</span>
  182. 00160 <span class="comment"> @Description A swap template function that swaps a and b</span>
  183. 00161 <span class="comment">*****************************************************************************/</span>
  184. 00162
  185. 00163 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
  186. 00164 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="PVRTGlobal_8h.html#a30">PVRTswap</a>(T&amp; a, T&amp; b)
  187. 00165 {
  188. 00166 T temp = a;
  189. 00167 a = b;
  190. 00168 b = temp;
  191. <a name="l00169"></a><a class="code" href="PVRTGlobal_8h.html#a30">00169</a> }
  192. 00170
  193. 00171 <span class="preprocessor">#ifdef _UITRON_</span>
  194. 00172 <span class="preprocessor"></span><span class="keyword">template</span> <span class="keywordtype">void</span> PVRTswap&lt;unsigned char&gt;(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>&amp; a, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>&amp; b);
  195. 00173 <span class="preprocessor">#endif</span>
  196. 00174 <span class="preprocessor"></span>
  197. 00175 <span class="comment">/*!***************************************************************************</span>
  198. 00176 <span class="comment"> @Function PVRTByteSwap</span>
  199. 00177 <span class="comment"> @Input pBytes A number</span>
  200. 00178 <span class="comment"> @Input i32ByteNo Number of bytes in pBytes</span>
  201. 00179 <span class="comment"> @Description Swaps the endianness of pBytes in place</span>
  202. 00180 <span class="comment">*****************************************************************************/</span>
  203. 00181 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="PVRTGlobal_8h.html#a31">PVRTByteSwap</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>* pBytes, <span class="keywordtype">int</span> i32ByteNo)
  204. 00182 {
  205. 00183 <span class="keywordtype">int</span> i = 0, j = i32ByteNo - 1;
  206. 00184
  207. 00185 <span class="keywordflow">while</span>(i &lt; j)
  208. 00186 PVRTswap&lt;unsigned char&gt;(pBytes[i++], pBytes[j--]);
  209. <a name="l00187"></a><a class="code" href="PVRTGlobal_8h.html#a31">00187</a> }
  210. 00188
  211. 00189 <span class="comment">/*!***************************************************************************</span>
  212. 00190 <span class="comment"> @Function PVRTByteSwap32</span>
  213. 00191 <span class="comment"> @Input ui32Long A number</span>
  214. 00192 <span class="comment"> @Returns ui32Long with its endianness changed</span>
  215. 00193 <span class="comment"> @Description Converts the endianness of an unsigned long</span>
  216. 00194 <span class="comment">*****************************************************************************/</span>
  217. 00195 <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="PVRTGlobal_8h.html#a32">PVRTByteSwap32</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> ui32Long)
  218. 00196 {
  219. 00197 <span class="keywordflow">return</span> ((ui32Long&amp;0x000000FF)&lt;&lt;24) + ((ui32Long&amp;0x0000FF00)&lt;&lt;8) + ((ui32Long&amp;0x00FF0000)&gt;&gt;8) + ((ui32Long&amp;0xFF000000) &gt;&gt; 24);
  220. 00198 }
  221. 00199
  222. 00200 <span class="comment">/*!***************************************************************************</span>
  223. 00201 <span class="comment"> @Function PVRTByteSwap16</span>
  224. <a name="l00202"></a><a class="code" href="PVRTGlobal_8h.html#a32">00202</a> <span class="comment"> @Input ui16Short A number</span>
  225. 00203 <span class="comment"> @Returns ui16Short with its endianness changed</span>
  226. 00204 <span class="comment"> @Description Converts the endianness of a unsigned short</span>
  227. 00205 <span class="comment">*****************************************************************************/</span>
  228. 00206 <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="PVRTGlobal_8h.html#a33">PVRTByteSwap16</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> ui16Short)
  229. 00207 {
  230. 00208 <span class="keywordflow">return</span> (ui16Short&gt;&gt;8) | (ui16Short&lt;&lt;8);
  231. 00209 }
  232. 00210
  233. 00211 <span class="comment">/*!***************************************************************************</span>
  234. 00212 <span class="comment"> @Function PVRTIsLittleEndian</span>
  235. 00213 <span class="comment"> @Returns True if the platform the code is ran on is little endian</span>
  236. <a name="l00214"></a><a class="code" href="PVRTGlobal_8h.html#a33">00214</a> <span class="comment"> @Description Returns true if the platform the code is ran on is little endian</span>
  237. 00215 <span class="comment">*****************************************************************************/</span>
  238. 00216 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="PVRTGlobal_8h.html#a34">PVRTIsLittleEndian</a>()
  239. 00217 {
  240. 00218 <span class="keyword">static</span> <span class="keywordtype">bool</span> bLittleEndian;
  241. 00219 <span class="keyword">static</span> <span class="keywordtype">bool</span> bIsInit = <span class="keyword">false</span>;
  242. 00220
  243. 00221 <span class="keywordflow">if</span>(!bIsInit)
  244. 00222 {
  245. 00223 <span class="keywordtype">short</span> <span class="keywordtype">int</span> word = 0x0001;
  246. 00224 <span class="keywordtype">char</span> *byte = (<span class="keywordtype">char</span>*) &amp;word;
  247. <a name="l00225"></a><a class="code" href="PVRTGlobal_8h.html#a34">00225</a> bLittleEndian = byte[0] ? <span class="keyword">true</span> : <span class="keyword">false</span>;
  248. 00226 bIsInit = <span class="keyword">true</span>;
  249. 00227 }
  250. 00228
  251. 00229 <span class="keywordflow">return</span> bLittleEndian;
  252. 00230 }
  253. 00231
  254. 00232 <span class="preprocessor">#endif // _PVRTGLOBAL_H_</span>
  255. 00233 <span class="preprocessor"></span>
  256. 00234 <span class="comment">/*****************************************************************************</span>
  257. 00235 <span class="comment"> End of file (Tools.h)</span>
  258. 00236 <span class="comment">*****************************************************************************/</span>
  259. 00237
  260. </pre></div><br>
  261. <br>
  262. <P align=left><FONT size=2><STRONG><A
  263. href="http://www.imgtec.com/powervr/insider/legal/index.asp">Copyright</A> ©
  264. 1999-2008, Imagination Technologies Ltd.</STRONG></FONT></P>
  265. <hr>
  266. <address style="align: left;"><small><FONT color=f0f>
  267. Generated by <a href="http://www.doxygen.org/index.html">DOXYGEN</a> 1.3.6</small></address>
  268. </body>
  269. </html>