Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

procutil.h

Go to the documentation of this file.
00001 #ifndef PROCUTIL_H
00002 #define PROCUTIL_H
00003 
00004 #include "basetype.h"
00005 #include "bitmap.h"
00006 #include <math.h>
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012 #ifdef PI
00013 #undef PI
00014 #endif
00015 #ifdef TWO_PI
00016 #undef TWO_PI
00017 #endif
00018 
00019 #define PI                                                      (3.14159265359f)
00020 #define PI_OVER_2                                       (1.570796326795f)
00021 #define TWO_PI                                          (6.28318530718f)
00022 #define PI_OVER_180                                     (0.01745329251994f)
00023 #define RAD_TO_DEG                                      (57.29577951308f)       //180_over_pi
00024 #define ONE_OVER_360                            (0.002777777777778f)
00025 
00026 #define ProcUtil_Deg2Rad(a)     ((a) * PI_OVER_180)
00027 #define ProcUtil_Rad2Deg(a) ((a) * RAD_TO_DEG)
00028 
00029 #define TABLE_SHIFT                                     (10)
00030 #define TABLE_SIZE                                      ((1UL)<<TABLE_SHIFT)
00031 #define TABLE_MASK                                      (TABLE_SIZE - 1)
00032 
00033 #define TABLE_SIZE_OVER_TWO_PI          ((float)TABLE_SIZE / TWO_PI)
00034 
00035 /****** you must call _Init before using ProcUtil functions ***/
00036 
00037 void ProcUtil_Init(void);
00038 
00039 /****** Stuff ***/
00040 
00041 geBoolean ProcUtil_SetPaletteFromString(geBitmap * Bitmap,char ** pParams);
00042 
00043 /*** fast Rand() utilities *****/
00044 
00045 extern void             ProcUtil_Randomize( void );
00046 extern uint32   ProcUtil_Rand( uint32 max );
00047 
00048 #define ProcUtil_RandSigned(max)                        ( ProcUtil_Rand(max+max+1) - (max) )
00049 #define ProcUtil_RandUnitFloat()                        ( ProcUtil_Rand(13729) * (1.0f/13729.0f))
00050 #define ProcUtil_RandFloat(max)                         ( max * ProcUtil_RandUnitFloat())
00051 #define ProcUtil_RandSignedUnitFloat()          ( ProcUtil_RandSigned(13729) * (1.0f/13729.0f))
00052 #define ProcUtil_RandSignedFloat(max)           ( max * ProcUtil_RandSignedUnitFloat())
00053 
00054 /*** fast Sin/Cos with tables *****/
00055 
00056 extern float ProcUtil_SinTable[];
00057 extern float ProcUtil_CosTable[];
00058 extern int   ProcUtil_ByteSinTable[];
00059 extern int   ProcUtil_ByteCosTable[];
00060 
00061 #define ProcUtil_Sin(a) ( ProcUtil_SinTable[((int)((a) * TABLE_SIZE_OVER_TWO_PI) + (1UL<<20)) & TABLE_MASK] )
00062 #define ProcUtil_Cos(a) ( ProcUtil_CosTable[((int)((a) * TABLE_SIZE_OVER_TWO_PI) + (1UL<<20)) & TABLE_MASK] )
00063 
00066 #define ProcUtil_ByteSin(a)     ( ProcUtil_ByteSinTable[(int)((a) + (1UL<<20)) & 0xFF] )
00067 #define ProcUtil_ByteCos(a)     ( ProcUtil_ByteCosTable[(int)((a) + (1UL<<20)) & 0xFF] )
00068 
00069 /******* __inline functions ****************/
00070 
00071 float __inline ProcUtil_Sqrt(float val)
00072 {
00073         __asm {
00074                 FLD val
00075                 FSQRT
00076                 FSTP val
00077         }
00078 return val;
00079 }
00080 
00081 #ifdef __cplusplus
00082 }
00083 #endif
00084 
00085 #endif

Generated on Tue Sep 30 12:36:13 2003 for GTestAndEngine by doxygen 1.3.2