home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / idlib / Lib.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  8KB  |  297 lines

  1. #ifndef __LIB_H__
  2. #define __LIB_H__
  3.  
  4.  
  5. /*
  6. ===============================================================================
  7.  
  8.     idLib contains stateless support classes and concrete types. Some classes
  9.     do have static variables, but such variables are initialized once and
  10.     read-only after initialization (they do not maintain a modifiable state).
  11.  
  12.     The interface pointers idSys, idCommon, idCVarSystem and idFileSystem
  13.     should be set before using idLib. The pointers stored here should not
  14.     be used by any part of the engine except for idLib.
  15.  
  16.     The frameNumber should be continuously set to the number of the current
  17.     frame if frame base memory logging is required.
  18.  
  19. ===============================================================================
  20. */
  21.  
  22. class idLib {
  23. public:
  24.     static class idSys *        sys;
  25.     static class idCommon *        common;
  26.     static class idCVarSystem *    cvarSystem;
  27.     static class idFileSystem *    fileSystem;
  28.     static int                    frameNumber;
  29.  
  30.     static void                    Init( void );
  31.     static void                    ShutDown( void );
  32. };
  33.  
  34.  
  35. /*
  36. ===============================================================================
  37.  
  38.     Asserts and Exceptions
  39.  
  40. ===============================================================================
  41. */
  42.  
  43. /*
  44. The verify(x) macro just returns true or false in release mode, but breaks
  45. in debug mode.  That way the code can take a non-fatal path in release mode
  46. if something that's not supposed to happen happens.
  47.  
  48. if ( !verify(game) ) {
  49.     // This should never happen!
  50.     return;
  51. }
  52. */
  53.  
  54. #ifdef _DEBUG
  55. void AssertFailed( const char *file, int line, const char *expression );
  56. #undef assert
  57. #define assert( x )        if ( x ) { } else AssertFailed( __FILE__, __LINE__, #x )
  58. #define verify( x )        ( ( x ) ? true : ( AssertFailed( __FILE__, __LINE__, #x ), false ) )
  59. #else
  60. #define verify( x )        ( ( x ) ? true : false )
  61. #endif
  62.  
  63. #define assert_8_byte_aligned( pointer )        assert( (((UINT_PTR)(pointer))&7) == 0 );
  64. #define assert_16_byte_aligned( pointer )        assert( (((UINT_PTR)(pointer))&15) == 0 );
  65. #define assert_32_byte_aligned( pointer )        assert( (((UINT_PTR)(pointer))&31) == 0 );
  66.  
  67. #ifndef __TYPE_INFO_GEN__
  68. #define compile_time_assert( x )                { typedef int compile_time_assert_failed[(x) ? 1 : -1]; }
  69. #define file_scoped_compile_time_assert( x )    extern int compile_time_assert_failed[(x) ? 1 : -1]
  70. #define assert_sizeof( type, size )                file_scoped_compile_time_assert( sizeof( type ) == size )
  71. #define assert_offsetof( type, field, offset )    file_scoped_compile_time_assert( offsetof( type, field ) == offset )
  72. #define assert_sizeof_8_byte_multiple( type )    file_scoped_compile_time_assert( ( sizeof( type ) & 8 ) == 0 )
  73. #define assert_sizeof_16_byte_multiple( type )    file_scoped_compile_time_assert( ( sizeof( type ) & 15 ) == 0 )
  74. #define assert_sizeof_32_byte_multiple( type )    file_scoped_compile_time_assert( ( sizeof( type ) & 31 ) == 0 )
  75. #else
  76. #define compile_time_assert( x )
  77. #define file_scoped_compile_time_assert( x )
  78. #define assert_sizeof( type, size )
  79. #define assert_offsetof( type, field, offset )
  80. #define assert_sizeof_16_byte_multiple( type )
  81. #endif
  82.  
  83. class idException {
  84. public:
  85.     char error[2048];
  86.  
  87.     idException( const char *text = "" ) { strcpy( error, text ); }
  88. };
  89.  
  90.  
  91. /*
  92. ===============================================================================
  93.  
  94.     Types and defines used throughout the engine.
  95.  
  96. ===============================================================================
  97. */
  98.  
  99. typedef unsigned char            byte;        // 8 bits
  100. typedef unsigned short            word;        // 16 bits
  101. typedef unsigned int            dword;        // 32 bits
  102. typedef unsigned int            uint;
  103. typedef unsigned long            ulong;
  104.  
  105. typedef int                        qhandle_t;
  106.  
  107. class idFile;
  108. class idVec3;
  109. #ifdef _XENON
  110. #define ID_VEC4_ALIGN __declspec(align(16))
  111. #else
  112. #define ID_VEC4_ALIGN
  113. #endif
  114. class ID_VEC4_ALIGN idVec4;
  115.  
  116. #ifndef NULL
  117. #define NULL                    ((void *)0)
  118. #endif
  119.  
  120. #ifndef BIT
  121. #define BIT( num )                ( 1 << ( num ) )
  122. #endif
  123.  
  124. #define    MAX_STRING_CHARS        1024        // max length of a string
  125.  
  126. // maximum world size
  127. #define MAX_WORLD_COORD            ( 128 * 1024 )
  128. #define MIN_WORLD_COORD            ( -128 * 1024 )
  129. #define MAX_WORLD_SIZE            ( MAX_WORLD_COORD - MIN_WORLD_COORD )
  130.  
  131. // basic colors
  132. extern    ID_VEC4_ALIGN idVec4 colorBlack;
  133. extern    ID_VEC4_ALIGN idVec4 colorWhite;
  134. extern    ID_VEC4_ALIGN idVec4 colorRed;
  135. extern    ID_VEC4_ALIGN idVec4 colorGreen;
  136. extern    ID_VEC4_ALIGN idVec4 colorBlue;
  137. extern    ID_VEC4_ALIGN idVec4 colorYellow;
  138. extern    ID_VEC4_ALIGN idVec4 colorMagenta;
  139. extern    ID_VEC4_ALIGN idVec4 colorCyan;
  140. extern    ID_VEC4_ALIGN idVec4 colorOrange;
  141. extern    ID_VEC4_ALIGN idVec4 colorPurple;
  142. extern    ID_VEC4_ALIGN idVec4 colorPink;
  143. extern    ID_VEC4_ALIGN idVec4 colorBrown;
  144. extern    ID_VEC4_ALIGN idVec4 colorLtGrey;
  145. extern    ID_VEC4_ALIGN idVec4 colorMdGrey;
  146. extern    ID_VEC4_ALIGN idVec4 colorDkGrey;
  147.  
  148. // packs color floats in the range [0,1] into an integer
  149. dword    PackColor( const idVec3 &color );
  150. void    UnpackColor( const dword color, idVec3 &unpackedColor );
  151. dword    PackColor( const idVec4 &color );
  152. void    UnpackColor( const dword color, idVec4 &unpackedColor );
  153.  
  154. // little/big endian conversion
  155. short    BigShort( short l );
  156. short    LittleShort( short l );
  157. int        BigLong( int l );
  158. int        LittleLong( int l );
  159. float    BigFloat( float l );
  160. float    LittleFloat( float l );
  161. void    BigRevBytes( void *bp, int elsize, int elcount );
  162. void    LittleRevBytes( void *bp, int elsize, int elcount );
  163. void    Swap_Init( void );
  164.  
  165. bool    Swap_IsBigEndian( void );
  166.  
  167. // for base64
  168. void    SixtetsForInt( byte *out, int src);
  169. int        IntForSixtets( byte *in );
  170.  
  171.  
  172. /*
  173. ===============================================================================
  174.  
  175.     idLib headers.
  176.  
  177. ===============================================================================
  178. */
  179.  
  180. // memory management and arrays
  181. #include "Heap.h"
  182.  
  183. // RAVEN BEGIN
  184. // dluetscher: added includes for new heap/memory management system
  185. #ifdef _RV_MEM_SYS_SUPPORT
  186. #include "rvHeapArena.h"
  187. #include "rvHeap.h"
  188. #include "rvMemSys.h"
  189. #endif
  190. // RAVEN END
  191.  
  192. #include "containers/List.h"
  193.  
  194. // math
  195. #include "math/Simd.h"
  196. #include "math/Math.h"
  197. #include "math/Random.h"
  198. #include "math/Complex.h"
  199. #include "math/Vector.h"
  200. #include "math/Matrix.h"
  201. #include "math/Mat3x4.h"
  202. #include "math/Angles.h"
  203. #include "math/Quat.h"
  204. #include "math/Rotation.h"
  205. #include "math/Plane.h"
  206. #include "math/Pluecker.h"
  207. #include "math/Polynomial.h"
  208. #include "math/Extrapolate.h"
  209. #include "math/Interpolate.h"
  210. #include "math/Curve.h"
  211. #include "math/Ode.h"
  212. #include "math/Lcp.h"
  213. // RAVEN BEGIN
  214. #include "math/Radians.h"
  215. #include "math/FFT.h"
  216. // RAVEN END
  217.  
  218. // bounding volumes
  219. #include "bv/Sphere.h"
  220. #include "bv/Bounds.h"
  221. #include "bv/Box.h"
  222. #include "bv/Frustum.h"
  223.  
  224. // geometry
  225. #include "geometry/DrawVert.h"
  226. #include "geometry/JointTransform.h"
  227. #include "geometry/Winding.h"
  228. #include "geometry/Winding2D.h"
  229. #include "geometry/Surface.h"
  230. #include "geometry/Surface_Patch.h"
  231. #include "geometry/Surface_Polytope.h"
  232. #include "geometry/Surface_SweptSpline.h"
  233. #include "geometry/TraceModel.h"
  234.  
  235. // RAVEN BEGIN
  236. // dluetscher: added some headers for new vertex formats
  237. #ifdef _MD5R_SUPPORT
  238. #include "geometry/rvVertex.h"
  239. #endif
  240. // RAVEN END
  241.  
  242. // text manipulation
  243. #include "Str.h"
  244. #include "Token.h"
  245. #include "Lexer.h"
  246. #include "Parser.h"
  247. #include "Base64.h"
  248. #include "CmdArgs.h"
  249.  
  250. // containers
  251. #include "containers/BTree.h"
  252. #include "containers/BinSearch.h"
  253. #include "containers/HashIndex.h"
  254. #include "containers/HashTable.h"
  255. #include "containers/StaticList.h"
  256. #include "containers/LinkList.h"
  257. #include "containers/Hierarchy.h"
  258. #include "containers/Queue.h"
  259. #include "containers/Stack.h"
  260. #include "containers/StrList.h"
  261. #include "containers/StrPool.h"
  262. #include "containers/VectorSet.h"
  263. #include "containers/PlaneSet.h"
  264. #include "containers/rvBlockPool.h"
  265. // RAVEN BEGIN
  266. // ddynerman: a pair
  267. #include "containers/Pair.h"
  268. // ddynerman: algorithms
  269. #include "algorithms/MultifieldSort.h"
  270. // RAVEN END
  271.  
  272. // hashing
  273. #include "hashing/CRC8.h"
  274. #include "hashing/CRC16.h"
  275. #include "hashing/CRC32.h"
  276. #include "hashing/Honeyman.h"
  277. #include "hashing/MD4.h"
  278. #include "hashing/MD5.h"
  279.  
  280. // misc
  281. #include "Dict.h"
  282. #include "LangDict.h"
  283. #include "BitMsg.h"
  284. #include "MapFile.h"
  285. #include "Timer.h"
  286. // RAVEN BEGIN
  287. // jsinger: xenon needs these because the simd class is no longer virtual
  288. #ifdef _XENON
  289. #include "math/Simd_generic.h"
  290. #include "math/Simd_Xenon.h"
  291. #include "Threads/ThreadEventManager.h"
  292. #include "Threads/WorkerThreadManager.h"
  293. #endif
  294. // RAVEN END
  295.  
  296. #endif    /* !__LIB_H__ */
  297.