codemp/cgame/tr_types.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2000 Id Software, Inc.
00002 //
00003 #ifndef __TR_TYPES_H
00004 #define __TR_TYPES_H
00005 
00006 
00007 #define MAX_DLIGHTS             32                      // can't be increased, because bit flags are used on surfaces
00008 #ifdef _XBOX
00009 #define MAX_ENTITIES    1024            // 11 bits, can't be increased without changing drawsurf bit packing (QSORT_ENTITYNUM_SHIFT)
00010 #else
00011 #define MAX_ENTITIES    2048            // 11 bits, can't be increased without changing drawsurf bit packing (QSORT_ENTITYNUM_SHIFT)
00012 #endif
00013 #define MAX_MINI_ENTITIES       1024            
00014 
00015 #define TR_WORLDENT             (MAX_ENTITIES-1)
00016 
00017 // renderfx flags
00018 #define RF_MINLIGHT                     0x00001 // allways have some light (viewmodel, some items)
00019 #define RF_THIRD_PERSON         0x00002 // don't draw through eyes, only mirrors (player bodies, chat sprites)
00020 #define RF_FIRST_PERSON         0x00004 // only draw through eyes (view weapon, damage blood blob)
00021 #define RF_DEPTHHACK            0x00008 // for view weapon Z crunching
00022 #define RF_NODEPTH                      0x00010 // No depth at all (seeing through walls)
00023 
00024 #define RF_VOLUMETRIC           0x00020 // fake volumetric shading
00025 
00026 #define RF_NOSHADOW                     0x00040 // don't add stencil shadows
00027 
00028 #define RF_LIGHTING_ORIGIN      0x00080 // use refEntity->lightingOrigin instead of refEntity->origin
00029                                                                         // for lighting.  This allows entities to sink into the floor
00030                                                                         // with their origin going solid, and allows all parts of a
00031                                                                         // player to get the same lighting
00032 #define RF_SHADOW_PLANE         0x00100 // use refEntity->shadowPlane
00033 #define RF_WRAP_FRAMES          0x00200 // mod the model frames by the maxframes to allow continuous
00034                                                                                 // animation without needing to know the frame count
00035 
00036 #define RF_FORCE_ENT_ALPHA      0x00400 // override shader alpha settings
00037 #define RF_RGB_TINT                     0x00800 // override shader rgb settings
00038 
00039 #define RF_SHADOW_ONLY          0x01000 //add surfs for shadowing but don't draw them -rww
00040 
00041 #define RF_DISTORTION           0x02000 //area distortion effect -rww
00042 
00043 #define RF_FORKED                       0x04000 // override lightning to have forks
00044 #define RF_TAPERED                      0x08000 // lightning tapers
00045 #define RF_GROW                         0x10000 // lightning grows from start to end during its life
00046 
00047 #define RF_DISINTEGRATE1        0x20000 // does a procedural hole-ripping thing.
00048 #define RF_DISINTEGRATE2        0x40000 // does a procedural hole-ripping thing with scaling at the ripping point
00049 
00050 #define RF_SETANIMINDEX         0x80000 //use backEnd.currentEntity->e.skinNum for R_BindAnimatedImage
00051 
00052 #define RF_ALPHA_DEPTH          0x100000 //depth write on alpha model
00053 
00054 #define RF_FORCEPOST            0x200000 //force it to post-render -rww
00055 
00056 // refdef flags
00057 #define RDF_NOWORLDMODEL        1               // used for player configuration screen
00058 #define RDF_HYPERSPACE          4               // teleportation effect
00059 
00060 #define RDF_SKYBOXPORTAL        8
00061 #define RDF_DRAWSKYBOX          16              // the above marks a scene as being a 'portal sky'.  this flag says to draw it or not
00062 
00063 #define RDF_AUTOMAP                     32              //means this scene is to draw the automap -rww
00064 #define RDF_NOFOG                       64              //no global fog in this scene (but still brush fog) -rww
00065 
00066 extern int      skyboxportal;
00067 extern int      drawskyboxportal;
00068 
00069 typedef byte color4ub_t[4];
00070 
00071 typedef struct {
00072         vec3_t          xyz;
00073         float           st[2];
00074         byte            modulate[4];
00075 } polyVert_t;
00076 
00077 typedef struct poly_s {
00078         qhandle_t                       hShader;
00079         int                                     numVerts;
00080         polyVert_t                      *verts;
00081 } poly_t;
00082 
00083 typedef enum {
00084         RT_MODEL,
00085         RT_POLY,
00086         RT_SPRITE,
00087         RT_ORIENTED_QUAD,
00088         RT_BEAM,
00089         RT_SABER_GLOW,
00090         RT_ELECTRICITY,
00091         RT_PORTALSURFACE,               // doesn't draw anything, just info for portals
00092         RT_LINE,
00093         RT_ORIENTEDLINE,
00094         RT_CYLINDER,
00095         RT_ENT_CHAIN,
00096 
00097         RT_MAX_REF_ENTITY_TYPE
00098 } refEntityType_t;
00099 
00100 typedef struct miniRefEntity_s 
00101 {
00102         refEntityType_t         reType;
00103         int                                     renderfx;
00104 
00105         qhandle_t                       hModel;                         // opaque type outside refresh
00106 
00107         // most recent data
00108         vec3_t                          axis[3];                        // rotation vectors
00109         qboolean                        nonNormalizedAxes;      // axis are not normalized, i.e. they have scale
00110         vec3_t                          origin;                         // also used as MODEL_BEAM's "from"
00111 
00112         // previous data for frame interpolation
00113         vec3_t                          oldorigin;                      // also used as MODEL_BEAM's "to"
00114 
00115         // texturing
00116         qhandle_t                       customShader;           // use one image for the entire thing
00117 
00118         // misc
00119         byte                            shaderRGBA[4];          // colors used by rgbgen entity shaders
00120         vec2_t                          shaderTexCoord;         // texture coordinates used by tcMod entity modifiers
00121 
00122         // extra sprite information
00123         float                           radius;
00124         float                           rotation;                       // size 2 for RT_CYLINDER or number of verts in RT_ELECTRICITY
00125 
00126         // misc
00127         float           shaderTime;                     // subtracted from refdef time to control effect start times
00128         int                     frame;                          // also used as MODEL_BEAM's diameter
00129 
00130 } miniRefEntity_t;
00131 
00132 #pragma warning (disable : 4201 )
00133 typedef struct {
00134         // this stucture must remain identical as the miniRefEntity_t
00135         //
00136         //
00137         refEntityType_t         reType;
00138         int                                     renderfx;
00139 
00140         qhandle_t                       hModel;                         // opaque type outside refresh
00141 
00142         // most recent data
00143         vec3_t                          axis[3];                        // rotation vectors
00144         qboolean                        nonNormalizedAxes;      // axis are not normalized, i.e. they have scale
00145         vec3_t                          origin;                         // also used as MODEL_BEAM's "from"
00146 
00147         // previous data for frame interpolation
00148         vec3_t                          oldorigin;                      // also used as MODEL_BEAM's "to"
00149 
00150         // texturing
00151         qhandle_t                       customShader;           // use one image for the entire thing
00152 
00153         // misc
00154         byte                            shaderRGBA[4];          // colors used by rgbgen entity shaders
00155         vec2_t                          shaderTexCoord;         // texture coordinates used by tcMod entity modifiers
00156 
00157         // extra sprite information
00158         float                           radius;
00159         float                           rotation;
00160 
00161         // misc
00162         float           shaderTime;                     // subtracted from refdef time to control effect start times
00163         int                     frame;                          // also used as MODEL_BEAM's diameter
00164         //
00165         //
00166         // end miniRefEntity_t
00167 
00168         //
00169         //
00170         // specific full refEntity_t data
00171         //
00172         //
00173 
00174         // most recent data
00175         vec3_t          lightingOrigin;         // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
00176         float           shadowPlane;            // projection shadows go here, stencils go slightly lower
00177 
00178         // previous data for frame interpolation
00179         int                     oldframe;
00180         float           backlerp;                       // 0.0 = current, 1.0 = old
00181 
00182         // texturing
00183         int                     skinNum;                        // inline skin index
00184         qhandle_t       customSkin;                     // NULL for default skin
00185 
00186         // texturing
00187         union   
00188         {
00189 //              int                     skinNum;                // inline skin index
00190 //              ivec3_t         terxelCoords;   // coords of patch for RT_TERXELS       
00191                 struct
00192                 {
00193                         int             miniStart;
00194                         int             miniCount;
00195                 } uMini;
00196         } uRefEnt;
00197 
00198         // extra sprite information
00199         union {
00200                 struct 
00201                 {
00202                         float rotation;
00203                         float radius;
00204                         byte  vertRGBA[4][4];
00205                 } sprite;
00206                 struct 
00207                 {
00208                         float width;
00209                         float width2;
00210                         float stscale;
00211                 } line;
00212                 struct  // that whole put-the-opening-brace-on-the-same-line-as-the-beginning-of-the-definition coding style is fecal
00213                 {
00214                         float   width;
00215                         vec3_t  control1;
00216                         vec3_t  control2;
00217                 } bezier;
00218                 struct
00219                 {
00220                         float width;
00221                         float width2;
00222                         float stscale;
00223                         float height;
00224                         float bias;
00225                         qboolean wrap;
00226                 } cylinder;
00227                 struct 
00228                 {
00229                         float width;
00230                         float deviation;
00231                         float stscale;
00232                         qboolean wrap;
00233                         qboolean taper;
00234                 } electricity;
00235         } data;
00236 
00237         float           endTime;
00238         float           saberLength;
00239 
00240 /*
00241 Ghoul2 Insert Start
00242 */
00243         vec3_t          angles;                         // rotation angles - used for Ghoul2
00244 
00245         vec3_t          modelScale;                     // axis scale for models
00246 //      CGhoul2Info_v   *ghoul2;                // has to be at the end of the ref-ent in order for it to be created properly
00247         void            *ghoul2;                // has to be at the end of the ref-ent in order for it to be created properly
00248 /*
00249 Ghoul2 Insert End
00250 */
00251 } refEntity_t;
00252 
00253 
00254 #define MAX_RENDER_STRINGS                      8
00255 #define MAX_RENDER_STRING_LENGTH        32
00256 
00257 typedef struct {
00258         int                     x, y, width, height;
00259         float           fov_x, fov_y;
00260         vec3_t          vieworg;
00261         vec3_t          viewangles;
00262         vec3_t          viewaxis[3];            // transformation matrix
00263         int                     viewContents;           // world contents at vieworg
00264 
00265         // time in milliseconds for shader effects and other time dependent rendering issues
00266         int                     time;
00267 
00268         int                     rdflags;                        // RDF_NOWORLDMODEL, etc
00269 
00270         // 1 bits will prevent the associated area from rendering at all
00271         byte            areamask[MAX_MAP_AREA_BYTES];
00272 
00273         // text messages for deform text shaders
00274         char            text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];
00275 } refdef_t;
00276 
00277 
00278 typedef enum {
00279         STEREO_CENTER,
00280         STEREO_LEFT,
00281         STEREO_RIGHT
00282 };
00283 typedef int stereoFrame_t;
00284 
00285 
00286 /*
00287 ** glconfig_t
00288 **
00289 ** Contains variables specific to the OpenGL configuration
00290 ** being run right now.  These are constant once the OpenGL
00291 ** subsystem is initialized.
00292 */
00293 typedef enum {
00294         TC_NONE,
00295         TC_S3TC,
00296         TC_S3TC_DXT
00297 } textureCompression_t;
00298 
00299 typedef struct {
00300         const char                              *renderer_string;
00301         const char                              *vendor_string;
00302         const char                              *version_string;
00303         const char                              *extensions_string;
00304 
00305         int                                             maxTextureSize;                 // queried from GL
00306         int                                             maxActiveTextures;              // multitexture ability
00307         float                                   maxTextureFilterAnisotropy;
00308 
00309         int                                             colorBits, depthBits, stencilBits;
00310 
00311         qboolean                                deviceSupportsGamma;
00312         textureCompression_t    textureCompression;
00313         qboolean                                textureEnvAddAvailable;
00314         qboolean                                clampToEdgeAvailable;
00315 
00316         int                                             vidWidth, vidHeight;
00317 
00318         int                                             displayFrequency;
00319 
00320         // synonymous with "does rendering consume the entire screen?", therefore
00321         // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that
00322         // used CDS.
00323         qboolean                                isFullscreen;
00324         qboolean                                stereoEnabled;
00325 } glconfig_t;
00326 
00327 
00328 #if !defined _WIN32
00329 
00330 #define OPENGL_DRIVER_NAME      "libGL.so"
00331 
00332 #else
00333 
00334 #define OPENGL_DRIVER_NAME      "opengl32"
00335 
00336 #endif  // !defined _WIN32
00337 
00338 
00339 #endif  // __TR_TYPES_H