2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 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.
24 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.
26 ===========================================================================
34 ===============================================================================
36 idLib contains stateless support classes and concrete types. Some classes
37 do have static variables, but such variables are initialized once and
38 read-only after initialization (they do not maintain a modifiable state).
40 The interface pointers idSys, idCommon, idCVarSystem and idFileSystem
41 should be set before using idLib. The pointers stored here should not
42 be used by any part of the engine except for idLib.
44 The frameNumber should be continuously set to the number of the current
45 frame if frame base memory logging is required.
47 ===============================================================================
52 static class idSys * sys;
53 static class idCommon * common;
54 static class idCVarSystem * cvarSystem;
55 static class idFileSystem * fileSystem;
56 static int frameNumber;
58 static void Init( void );
59 static void ShutDown( void );
61 // wrapper to idCommon functions
62 static void Error( const char *fmt, ... );
63 static void Warning( const char *fmt, ... );
68 ===============================================================================
70 Types and defines used throughout the engine.
72 ===============================================================================
75 typedef unsigned char byte; // 8 bits
76 typedef unsigned short word; // 16 bits
77 typedef unsigned int dword; // 32 bits
78 typedef unsigned int uint;
79 typedef unsigned long ulong;
81 typedef int qhandle_t;
88 #define NULL ((void *)0)
92 #define BIT( num ) ( 1 << ( num ) )
95 #define MAX_STRING_CHARS 1024 // max length of a string
98 #define MAX_WORLD_COORD ( 128 * 1024 )
99 #define MIN_WORLD_COORD ( -128 * 1024 )
100 #define MAX_WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
103 extern idVec4 colorBlack;
104 extern idVec4 colorWhite;
105 extern idVec4 colorRed;
106 extern idVec4 colorGreen;
107 extern idVec4 colorBlue;
108 extern idVec4 colorYellow;
109 extern idVec4 colorMagenta;
110 extern idVec4 colorCyan;
111 extern idVec4 colorOrange;
112 extern idVec4 colorPurple;
113 extern idVec4 colorPink;
114 extern idVec4 colorBrown;
115 extern idVec4 colorLtGrey;
116 extern idVec4 colorMdGrey;
117 extern idVec4 colorDkGrey;
119 // packs color floats in the range [0,1] into an integer
120 dword PackColor( const idVec3 &color );
121 void UnpackColor( const dword color, idVec3 &unpackedColor );
122 dword PackColor( const idVec4 &color );
123 void UnpackColor( const dword color, idVec4 &unpackedColor );
125 // little/big endian conversion
126 short BigShort( short l );
127 short LittleShort( short l );
128 int BigLong( int l );
129 int LittleLong( int l );
130 float BigFloat( float l );
131 float LittleFloat( float l );
132 void BigRevBytes( void *bp, int elsize, int elcount );
133 void LittleRevBytes( void *bp, int elsize, int elcount );
134 void LittleBitField( void *bp, int elsize );
135 void Swap_Init( void );
137 bool Swap_IsBigEndian( void );
140 void SixtetsForInt( byte *out, int src);
141 int IntForSixtets( byte *in );
145 void AssertFailed( const char *file, int line, const char *expression );
147 #define assert( X ) if ( X ) { } else AssertFailed( __FILE__, __LINE__, #X )
152 char error[MAX_STRING_CHARS];
154 idException( const char *text = "" ) { strcpy( error, text ); }
157 // move from Math.h to keep gcc happy
158 template<class T> ID_INLINE T Max( T x, T y ) { return ( x > y ) ? x : y; }
159 template<class T> ID_INLINE T Min( T x, T y ) { return ( x < y ) ? x : y; }
162 ===============================================================================
166 ===============================================================================
169 // memory management and arrays
171 #include "containers/List.h"
174 #include "math/Simd.h"
175 #include "math/Math.h"
176 #include "math/Random.h"
177 #include "math/Complex.h"
178 #include "math/Vector.h"
179 #include "math/Matrix.h"
180 #include "math/Angles.h"
181 #include "math/Quat.h"
182 #include "math/Rotation.h"
183 #include "math/Plane.h"
184 #include "math/Pluecker.h"
185 #include "math/Polynomial.h"
186 #include "math/Extrapolate.h"
187 #include "math/Interpolate.h"
188 #include "math/Curve.h"
189 #include "math/Ode.h"
190 #include "math/Lcp.h"
193 #include "bv/Sphere.h"
194 #include "bv/Bounds.h"
196 #include "bv/Frustum.h"
199 #include "geometry/DrawVert.h"
200 #include "geometry/JointTransform.h"
201 #include "geometry/Winding.h"
202 #include "geometry/Winding2D.h"
203 #include "geometry/Surface.h"
204 #include "geometry/Surface_Patch.h"
205 #include "geometry/Surface_Polytope.h"
206 #include "geometry/Surface_SweptSpline.h"
207 #include "geometry/TraceModel.h"
218 #include "containers/BTree.h"
219 #include "containers/BinSearch.h"
220 #include "containers/HashIndex.h"
221 #include "containers/HashTable.h"
222 #include "containers/StaticList.h"
223 #include "containers/LinkList.h"
224 #include "containers/Hierarchy.h"
225 #include "containers/Queue.h"
226 #include "containers/Stack.h"
227 #include "containers/StrList.h"
228 #include "containers/StrPool.h"
229 #include "containers/VectorSet.h"
230 #include "containers/PlaneSet.h"
233 #include "hashing/CRC32.h"
234 #include "hashing/MD4.h"
235 #include "hashing/MD5.h"
239 #include "LangDict.h"
244 #endif /* !__LIB_H__ */