mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-21 20:21:19 +00:00
143 lines
4.7 KiB
C++
143 lines
4.7 KiB
C++
/*
|
|
===========================================================================
|
|
|
|
Doom 3 GPL Source Code
|
|
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
|
|
|
|
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
|
|
|
|
Doom 3 Source Code is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Doom 3 Source Code is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
===========================================================================
|
|
*/
|
|
|
|
#ifndef __LIB_H__
|
|
#define __LIB_H__
|
|
|
|
/*
|
|
===============================================================================
|
|
|
|
idLib contains stateless support classes and concrete types. Some classes
|
|
do have static variables, but such variables are initialized once and
|
|
read-only after initialization (they do not maintain a modifiable state).
|
|
|
|
The interface pointers idSys, idCommon, idCVarSystem and idFileSystem
|
|
should be set before using idLib. The pointers stored here should not
|
|
be used by any part of the engine except for idLib.
|
|
|
|
The frameNumber should be continuously set to the number of the current
|
|
frame if frame base memory logging is required.
|
|
|
|
===============================================================================
|
|
*/
|
|
|
|
class idSys;
|
|
class idCommon;
|
|
class idCVarSystem;
|
|
class idFileSystem;
|
|
|
|
class idLib {
|
|
public:
|
|
static class idSys * sys;
|
|
static class idCommon * common;
|
|
static class idCVarSystem * cvarSystem;
|
|
static class idFileSystem * fileSystem;
|
|
static int frameNumber;
|
|
|
|
static void Init( void );
|
|
static void ShutDown( void );
|
|
|
|
// wrapper to idCommon functions
|
|
static void Error( const char *fmt, ... );
|
|
static void Warning( const char *fmt, ... );
|
|
};
|
|
|
|
|
|
/*
|
|
===============================================================================
|
|
|
|
Types and defines used throughout the engine.
|
|
|
|
===============================================================================
|
|
*/
|
|
|
|
class idFile;
|
|
class idVec3;
|
|
class idVec4;
|
|
|
|
// basic colors
|
|
extern idVec4 colorBlack;
|
|
extern idVec4 colorWhite;
|
|
extern idVec4 colorRed;
|
|
extern idVec4 colorGreen;
|
|
extern idVec4 colorBlue;
|
|
extern idVec4 colorYellow;
|
|
extern idVec4 colorMagenta;
|
|
extern idVec4 colorCyan;
|
|
extern idVec4 colorOrange;
|
|
extern idVec4 colorPurple;
|
|
extern idVec4 colorPink;
|
|
extern idVec4 colorBrown;
|
|
extern idVec4 colorLtGrey;
|
|
extern idVec4 colorMdGrey;
|
|
extern idVec4 colorDkGrey;
|
|
|
|
// packs color floats in the range [0,1] into an integer
|
|
dword PackColor( const idVec3 &color );
|
|
void UnpackColor( const dword color, idVec3 &unpackedColor );
|
|
dword PackColor( const idVec4 &color );
|
|
void UnpackColor( const dword color, idVec4 &unpackedColor );
|
|
|
|
// little/big endian conversion
|
|
short BigShort( short l );
|
|
short LittleShort( short l );
|
|
int BigInt( int l );
|
|
int LittleInt( int l );
|
|
float BigFloat( float l );
|
|
float LittleFloat( float l );
|
|
void BigRevBytes( void *bp, int elsize, int elcount );
|
|
void LittleRevBytes( void *bp, int elsize, int elcount );
|
|
void LittleBitField( void *bp, int elsize );
|
|
void Swap_Init( void );
|
|
|
|
bool Swap_IsBigEndian( void );
|
|
|
|
// for base64
|
|
void SixtetsForInt( byte *out, int src);
|
|
int IntForSixtets( byte *in );
|
|
|
|
|
|
#ifdef _DEBUG
|
|
void AssertFailed( const char *file, int line, const char *expression );
|
|
#undef assert
|
|
// DG: change assert to use ?: so I can use it in _alloca()/_alloca16() (MSVC didn't like if() in there)
|
|
#define assert( X ) (X) ? 1 : (AssertFailed( __FILE__, __LINE__, #X ), 0)
|
|
#endif
|
|
|
|
class idException {
|
|
public:
|
|
char error[MAX_STRING_CHARS];
|
|
|
|
idException( const char *text = "" ) { strcpy( error, text ); }
|
|
};
|
|
|
|
// move from Math.h to keep gcc happy
|
|
template<class T> ID_INLINE T Max( T x, T y ) { return ( x > y ) ? x : y; }
|
|
template<class T> ID_INLINE T Min( T x, T y ) { return ( x < y ) ? x : y; }
|
|
|
|
#endif /* !__LIB_H__ */
|