Lib.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __LIB_H__
  21. #define __LIB_H__
  22. /*
  23. ===============================================================================
  24. idLib contains stateless support classes and concrete types. Some classes
  25. do have static variables, but such variables are initialized once and
  26. read-only after initialization (they do not maintain a modifiable state).
  27. The interface pointers idSys, idCommon, idCVarSystem and idFileSystem
  28. should be set before using idLib. The pointers stored here should not
  29. be used by any part of the engine except for idLib.
  30. The frameNumber should be continuously set to the number of the current
  31. frame if frame base memory logging is required.
  32. ===============================================================================
  33. */
  34. class idLib {
  35. public:
  36. static class idSys * sys;
  37. static class idCommon * common;
  38. static class idCVarSystem * cvarSystem;
  39. static class idFileSystem * fileSystem;
  40. static int frameNumber;
  41. static void Init( void );
  42. static void ShutDown( void );
  43. // wrapper to idCommon functions
  44. static void Error( const char *fmt, ... );
  45. static void Warning( const char *fmt, ... );
  46. };
  47. /*
  48. ===============================================================================
  49. Types and defines used throughout the engine.
  50. ===============================================================================
  51. */
  52. typedef unsigned char byte; // 8 bits
  53. typedef unsigned short word; // 16 bits
  54. typedef unsigned int dword; // 32 bits
  55. typedef unsigned int uint;
  56. typedef unsigned long ulong;
  57. typedef int qhandle_t;
  58. class idFile;
  59. class idVec3;
  60. class idVec4;
  61. #ifndef NULL
  62. #define NULL ((void *)0)
  63. #endif
  64. #ifndef BIT
  65. #define BIT( num ) ( 1 << ( num ) )
  66. #endif
  67. #define MAX_STRING_CHARS 1024 // max length of a string
  68. // maximum world size
  69. #define MAX_WORLD_COORD ( 128 * 1024 )
  70. #define MIN_WORLD_COORD ( -128 * 1024 )
  71. #define MAX_WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
  72. // basic colors
  73. extern idVec4 colorBlack;
  74. extern idVec4 colorWhite;
  75. extern idVec4 colorRed;
  76. extern idVec4 colorGreen;
  77. extern idVec4 colorBlue;
  78. extern idVec4 colorYellow;
  79. extern idVec4 colorMagenta;
  80. extern idVec4 colorCyan;
  81. extern idVec4 colorOrange;
  82. extern idVec4 colorPurple;
  83. extern idVec4 colorPink;
  84. extern idVec4 colorBrown;
  85. extern idVec4 colorLtGrey;
  86. extern idVec4 colorMdGrey;
  87. extern idVec4 colorDkGrey;
  88. // packs color floats in the range [0,1] into an integer
  89. dword PackColor( const idVec3 &color );
  90. void UnpackColor( const dword color, idVec3 &unpackedColor );
  91. dword PackColor( const idVec4 &color );
  92. void UnpackColor( const dword color, idVec4 &unpackedColor );
  93. // little/big endian conversion
  94. short BigShort( short l );
  95. short LittleShort( short l );
  96. int BigLong( int l );
  97. int LittleLong( int l );
  98. float BigFloat( float l );
  99. float LittleFloat( float l );
  100. void BigRevBytes( void *bp, int elsize, int elcount );
  101. void LittleRevBytes( void *bp, int elsize, int elcount );
  102. void LittleBitField( void *bp, int elsize );
  103. void Swap_Init( void );
  104. bool Swap_IsBigEndian( void );
  105. // for base64
  106. void SixtetsForInt( byte *out, int src);
  107. int IntForSixtets( byte *in );
  108. #ifdef _DEBUG
  109. void AssertFailed( const char *file, int line, const char *expression );
  110. #undef assert
  111. #define assert( X ) if ( X ) { } else AssertFailed( __FILE__, __LINE__, #X )
  112. #endif
  113. class idException {
  114. public:
  115. char error[MAX_STRING_CHARS];
  116. idException( const char *text = "" ) { strcpy( error, text ); }
  117. };
  118. // move from Math.h to keep gcc happy
  119. template<class T> ID_INLINE T Max( T x, T y ) { return ( x > y ) ? x : y; }
  120. template<class T> ID_INLINE T Min( T x, T y ) { return ( x < y ) ? x : y; }
  121. /*
  122. ===============================================================================
  123. idLib headers.
  124. ===============================================================================
  125. */
  126. // memory management and arrays
  127. #include "Heap.h"
  128. #include "containers/List.h"
  129. // math
  130. #include "math/Simd.h"
  131. #include "math/Math.h"
  132. #include "math/Random.h"
  133. #include "math/Complex.h"
  134. #include "math/Vector.h"
  135. #include "math/Matrix.h"
  136. #include "math/Angles.h"
  137. #include "math/Quat.h"
  138. #include "math/Rotation.h"
  139. #include "math/Plane.h"
  140. #include "math/Pluecker.h"
  141. #include "math/Polynomial.h"
  142. #include "math/Extrapolate.h"
  143. #include "math/Interpolate.h"
  144. #include "math/Curve.h"
  145. #include "math/Ode.h"
  146. #include "math/Lcp.h"
  147. // bounding volumes
  148. #include "bv/Sphere.h"
  149. #include "bv/Bounds.h"
  150. #include "bv/Box.h"
  151. #include "bv/Frustum.h"
  152. // geometry
  153. #include "geometry/DrawVert.h"
  154. #include "geometry/JointTransform.h"
  155. #include "geometry/Winding.h"
  156. #include "geometry/Winding2D.h"
  157. #include "geometry/Surface.h"
  158. #include "geometry/Surface_Patch.h"
  159. #include "geometry/Surface_Polytope.h"
  160. #include "geometry/Surface_SweptSpline.h"
  161. #include "geometry/TraceModel.h"
  162. // text manipulation
  163. #include "Str.h"
  164. #include "Token.h"
  165. #include "Lexer.h"
  166. #include "Parser.h"
  167. #include "Base64.h"
  168. #include "CmdArgs.h"
  169. // containers
  170. #include "containers/BTree.h"
  171. #include "containers/BinSearch.h"
  172. #include "containers/HashIndex.h"
  173. #include "containers/HashTable.h"
  174. #include "containers/StaticList.h"
  175. #include "containers/LinkList.h"
  176. #include "containers/Hierarchy.h"
  177. #include "containers/Queue.h"
  178. #include "containers/Stack.h"
  179. #include "containers/StrList.h"
  180. #include "containers/StrPool.h"
  181. #include "containers/VectorSet.h"
  182. #include "containers/PlaneSet.h"
  183. // hashing
  184. #include "hashing/CRC32.h"
  185. #include "hashing/MD4.h"
  186. #include "hashing/MD5.h"
  187. // misc
  188. #include "Dict.h"
  189. #include "LangDict.h"
  190. #include "BitMsg.h"
  191. #include "MapFile.h"
  192. #include "Timer.h"
  193. #endif /* !__LIB_H__ */