1 /* 2 =========================================================================== 3 4 Return to Castle Wolfenstein single player GPL Source Code 5 Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Return to Castle Wolfenstein single player GPL Source Code (RTCW SP Source Code). 8 9 RTCW SP 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. 13 14 RTCW SP 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. 18 19 You should have received a copy of the GNU General Public License 20 along with RTCW SP Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the RTCW SP 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 RTCW SP Source Code. If not, please request a copy in writing from id Software at the address below. 23 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. 25 26 =========================================================================== 27 */ 28 29 30 #ifndef TR_LOCAL_H 31 #define TR_LOCAL_H 32 33 #include "../qcommon/q_shared.h" 34 #include "../qcommon/qfiles.h" 35 #include "../qcommon/qcommon.h" 36 #include "tr_public.h" 37 #include "qgl.h" 38 #include "iqm.h" 39 40 #define GLE(ret, name, ...) extern name##proc * qgl##name; 41 QGL_1_1_PROCS; 42 QGL_1_1_FIXED_FUNCTION_PROCS; 43 QGL_DESKTOP_1_1_PROCS; 44 QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS; 45 QGL_3_0_PROCS; 46 #undef GLE 47 48 #ifdef USE_OPENGLES 49 #ifdef USE_LOCAL_HEADERS 50 # include "GLES/glext.h" 51 #else 52 # include <GLES/glext.h> 53 #endif 54 #define GL_RGBA4 0x8056 55 #define GL_RGB5 0x8050 56 #define GL_INDEX_TYPE GL_UNSIGNED_SHORT 57 typedef unsigned short glIndex_t; 58 #else 59 #define GL_INDEX_TYPE GL_UNSIGNED_INT 60 typedef unsigned int glIndex_t; 61 #endif 62 63 // 11 bits 64 // can't be increased without changing bit packing for drawsurfs 65 // see QSORT_SHADERNUM_SHIFT 66 67 #define SHADERNUM_BITS 11 68 #define MAX_SHADERS (1<<SHADERNUM_BITS) 69 70 // a trRefEntity_t has all the information passed in by 71 // the client game, as well as some locally derived info 72 typedef struct { 73 refEntity_t e; 74 75 float axisLength; // compensate for non-normalized axis 76 77 qboolean needDlights; // true for bmodels that touch a dlight 78 qboolean lightingCalculated; 79 vec3_t lightDir; // normalized direction towards light 80 vec3_t ambientLight; // color normalized to 0-255 81 vec3_t directedLight; 82 float brightness; 83 } trRefEntity_t; 84 85 typedef struct { 86 vec3_t origin; // in world coordinates 87 vec3_t axis[3]; // orientation in world 88 vec3_t viewOrigin; // viewParms->or.origin in local coordinates 89 float modelMatrix[16]; 90 } orientationr_t; 91 92 typedef enum 93 { 94 IMGTYPE_COLORALPHA, // for color, lightmap, diffuse, and specular 95 IMGTYPE_NORMAL, 96 IMGTYPE_NORMALHEIGHT, 97 IMGTYPE_DELUXE, // normals are swizzled, deluxe are not 98 } imgType_t; 99 100 typedef enum 101 { 102 IMGFLAG_NONE = 0x0000, 103 IMGFLAG_MIPMAP = 0x0001, 104 IMGFLAG_PICMIP = 0x0002, 105 IMGFLAG_CUBEMAP = 0x0004, 106 IMGFLAG_NO_COMPRESSION = 0x0010, 107 IMGFLAG_NOLIGHTSCALE = 0x0020, 108 IMGFLAG_CLAMPTOEDGE = 0x0040, 109 IMGFLAG_GENNORMALMAP = 0x0080, 110 } imgFlags_t; 111 112 typedef struct image_s { 113 char imgName[MAX_QPATH]; // game path, including extension 114 int width, height; // source image 115 int uploadWidth, uploadHeight; // after power of two and picmip but not including clamp to MAX_TEXTURE_SIZE 116 GLuint texnum; // gl texture binding 117 118 int frameUsed; // for texture usage in frame statistics 119 120 int internalFormat; 121 int TMU; // only needed for voodoo2 122 123 imgType_t type; 124 imgFlags_t flags; 125 126 qboolean characterMIP; // independant 'character' mip scale ----(SA) added 127 128 int hash; // for fast building of the backupHash 129 130 struct image_s* next; 131 } image_t; 132 133 //=============================================================================== 134 135 typedef enum { 136 SS_BAD, 137 SS_PORTAL, // mirrors, portals, viewscreens 138 SS_ENVIRONMENT, // sky box 139 SS_OPAQUE, // opaque 140 141 SS_DECAL, // scorch marks, etc. 142 SS_SEE_THROUGH, // ladders, grates, grills that may have small blended edges 143 // in addition to alpha test 144 SS_BANNER, 145 146 SS_FOG, 147 148 SS_UNDERWATER, // for items that should be drawn in front of the water plane 149 150 SS_BLEND0, // regular transparency and filters 151 SS_BLEND1, // generally only used for additive type effects 152 SS_BLEND2, 153 SS_BLEND3, 154 155 SS_BLEND6, 156 SS_STENCIL_SHADOW, 157 SS_ALMOST_NEAREST, // gun smoke puffs 158 159 SS_NEAREST // blood blobs 160 } shaderSort_t; 161 162 163 #define MAX_SHADER_STAGES 8 164 165 typedef enum { 166 GF_NONE, 167 168 GF_SIN, 169 GF_SQUARE, 170 GF_TRIANGLE, 171 GF_SAWTOOTH, 172 GF_INVERSE_SAWTOOTH, 173 174 GF_NOISE 175 176 } genFunc_t; 177 178 179 typedef enum { 180 DEFORM_NONE, 181 DEFORM_WAVE, 182 DEFORM_NORMALS, 183 DEFORM_BULGE, 184 DEFORM_MOVE, 185 DEFORM_PROJECTION_SHADOW, 186 DEFORM_AUTOSPRITE, 187 DEFORM_AUTOSPRITE2, 188 DEFORM_TEXT0, 189 DEFORM_TEXT1, 190 DEFORM_TEXT2, 191 DEFORM_TEXT3, 192 DEFORM_TEXT4, 193 DEFORM_TEXT5, 194 DEFORM_TEXT6, 195 DEFORM_TEXT7 196 } deform_t; 197 198 typedef enum { 199 AGEN_IDENTITY, 200 AGEN_SKIP, 201 AGEN_ENTITY, 202 AGEN_ONE_MINUS_ENTITY, 203 AGEN_NORMALZFADE, // Ridah 204 AGEN_VERTEX, 205 AGEN_ONE_MINUS_VERTEX, 206 AGEN_LIGHTING_SPECULAR, 207 AGEN_WAVEFORM, 208 AGEN_PORTAL, 209 AGEN_CONST 210 } alphaGen_t; 211 212 typedef enum { 213 CGEN_BAD, 214 CGEN_IDENTITY_LIGHTING, // tr.identityLight 215 CGEN_IDENTITY, // always (1,1,1,1) 216 CGEN_ENTITY, // grabbed from entity's modulate field 217 CGEN_ONE_MINUS_ENTITY, // grabbed from 1 - entity.modulate 218 CGEN_EXACT_VERTEX, // tess.vertexColors 219 CGEN_VERTEX, // tess.vertexColors * tr.identityLight 220 CGEN_ONE_MINUS_VERTEX, 221 CGEN_WAVEFORM, // programmatically generated 222 CGEN_LIGHTING_DIFFUSE, 223 CGEN_FOG, // standard fog 224 CGEN_CONST // fixed color 225 } colorGen_t; 226 227 typedef enum { 228 TCGEN_BAD, 229 TCGEN_IDENTITY, // clear to 0,0 230 TCGEN_LIGHTMAP, 231 TCGEN_TEXTURE, 232 TCGEN_ENVIRONMENT_MAPPED, 233 TCGEN_FIRERISEENV_MAPPED, 234 TCGEN_FOG, 235 TCGEN_VECTOR // S and T from world coordinates 236 } texCoordGen_t; 237 238 typedef enum { 239 ACFF_NONE, 240 ACFF_MODULATE_RGB, 241 ACFF_MODULATE_RGBA, 242 ACFF_MODULATE_ALPHA 243 } acff_t; 244 245 typedef struct { 246 genFunc_t func; 247 248 float base; 249 float amplitude; 250 float phase; 251 float frequency; 252 } waveForm_t; 253 254 #define TR_MAX_TEXMODS 4 255 256 typedef enum { 257 TMOD_NONE, 258 TMOD_TRANSFORM, 259 TMOD_TURBULENT, 260 TMOD_SCROLL, 261 TMOD_SCALE, 262 TMOD_STRETCH, 263 TMOD_ROTATE, 264 TMOD_ENTITY_TRANSLATE, 265 TMOD_SWAP 266 } texMod_t; 267 268 #define MAX_SHADER_DEFORMS 3 269 typedef struct { 270 deform_t deformation; // vertex coordinate modification type 271 272 vec3_t moveVector; 273 waveForm_t deformationWave; 274 float deformationSpread; 275 276 float bulgeWidth; 277 float bulgeHeight; 278 float bulgeSpeed; 279 } deformStage_t; 280 281 282 typedef struct { 283 texMod_t type; 284 285 // used for TMOD_TURBULENT and TMOD_STRETCH 286 waveForm_t wave; 287 288 // used for TMOD_TRANSFORM 289 float matrix[2][2]; // s' = s * m[0][0] + t * m[1][0] + trans[0] 290 float translate[2]; // t' = s * m[0][1] + t * m[0][1] + trans[1] 291 292 // used for TMOD_SCALE 293 float scale[2]; // s *= scale[0] 294 // t *= scale[1] 295 296 // used for TMOD_SCROLL 297 float scroll[2]; // s' = s + scroll[0] * time 298 // t' = t + scroll[1] * time 299 300 // + = clockwise 301 // - = counterclockwise 302 float rotateSpeed; 303 304 } texModInfo_t; 305 306 307 // RF increased this for onfire animation 308 //#define MAX_IMAGE_ANIMATIONS 8 309 #define MAX_IMAGE_ANIMATIONS 16 310 311 typedef struct { 312 image_t *image[MAX_IMAGE_ANIMATIONS]; 313 int numImageAnimations; 314 float imageAnimationSpeed; 315 316 texCoordGen_t tcGen; 317 vec3_t tcGenVectors[2]; 318 319 int numTexMods; 320 texModInfo_t *texMods; 321 322 int videoMapHandle; 323 qboolean isLightmap; 324 qboolean isVideoMap; 325 } textureBundle_t; 326 327 #define NUM_TEXTURE_BUNDLES 2 328 329 typedef struct { 330 qboolean active; 331 332 textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; 333 334 waveForm_t rgbWave; 335 colorGen_t rgbGen; 336 337 waveForm_t alphaWave; 338 alphaGen_t alphaGen; 339 340 byte constantColor[4]; // for CGEN_CONST and AGEN_CONST 341 342 unsigned stateBits; // GLS_xxxx mask 343 344 acff_t adjustColorsForFog; 345 346 // Ridah 347 float zFadeBounds[2]; 348 349 qboolean isDetail; 350 qboolean isFogged; // used only for shaders that have fog disabled, so we can enable it for individual stages 351 } shaderStage_t; 352 353 struct shaderCommands_s; 354 355 // any change in the LIGHTMAP_* defines here MUST be reflected in 356 // R_FindShader() in tr_bsp.c 357 #define LIGHTMAP_2D -4 // shader is for 2D rendering 358 #define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models 359 #define LIGHTMAP_WHITEIMAGE -2 360 #define LIGHTMAP_NONE -1 361 362 typedef enum { 363 CT_FRONT_SIDED, 364 CT_BACK_SIDED, 365 CT_TWO_SIDED 366 } cullType_t; 367 368 typedef enum { 369 FP_NONE, // surface is translucent and will just be adjusted properly 370 FP_EQUAL, // surface is opaque but possibly alpha tested 371 FP_LE // surface is trnaslucent, but still needs a fog pass (fog surface) 372 } fogPass_t; 373 374 typedef struct { 375 float cloudHeight; 376 image_t *outerbox[6], *innerbox[6]; 377 } skyParms_t; 378 379 typedef struct { 380 vec3_t color; 381 float depthForOpaque; 382 } fogParms_t; 383 384 385 typedef struct shader_s { 386 char name[MAX_QPATH]; // game path, including extension 387 int lightmapIndex; // for a shader to match, both name and lightmapIndex must match 388 389 int index; // this shader == tr.shaders[index] 390 int sortedIndex; // this shader == tr.sortedShaders[sortedIndex] 391 392 float sort; // lower numbered shaders draw before higher numbered 393 394 qboolean defaultShader; // we want to return index 0 if the shader failed to 395 // load for some reason, but R_FindShader should 396 // still keep a name allocated for it, so if 397 // something calls RE_RegisterShader again with 398 // the same name, we don't try looking for it again 399 400 qboolean explicitlyDefined; // found in a .shader file 401 402 int surfaceFlags; // if explicitlyDefined, this will have SURF_* flags 403 int contentFlags; 404 405 qboolean entityMergable; // merge across entites optimizable (smoke, blood) 406 407 qboolean isSky; 408 skyParms_t sky; 409 fogParms_t fogParms; 410 411 float portalRange; // distance to fog out at 412 413 int multitextureEnv; // 0, GL_MODULATE, GL_ADD (FIXME: put in stage) 414 415 cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED 416 qboolean polygonOffset; // set for decals and other items that must be offset 417 qboolean noMipMaps; // for console fonts, 2D elements, etc. 418 qboolean noPicMip; // for images that must always be full resolution 419 qboolean characterMip; // use r_picmip2 rather than r_picmip 420 421 fogPass_t fogPass; // draw a blended pass, possibly with depth test equals 422 423 qboolean needsNormal; // not all shaders will need all data to be gathered 424 qboolean needsST1; 425 qboolean needsST2; 426 qboolean needsColor; 427 428 // Ridah 429 qboolean noFog; 430 431 int numDeforms; 432 deformStage_t deforms[MAX_SHADER_DEFORMS]; 433 434 int numUnfoggedPasses; 435 shaderStage_t *stages[MAX_SHADER_STAGES]; 436 437 void ( *optimalStageIteratorFunc )( void ); 438 439 double clampTime; // time this shader is clamped to 440 double timeOffset; // current time offset for this shader 441 442 struct shader_s *remappedShader; // current shader this one is remapped too 443 444 struct shader_s *next; 445 } shader_t; 446 447 typedef struct corona_s { 448 vec3_t origin; 449 vec3_t color; // range from 0.0 to 1.0, should be color normalized 450 vec3_t transformed; // origin in local coordinate system 451 float scale; // uses r_flaresize as the baseline (1.0) 452 int id; 453 int flags; // '1' is 'visible' 454 // still send the corona request, even if not visible, for proper fading 455 } corona_t; 456 457 typedef struct dlight_s { 458 vec3_t origin; 459 vec3_t color; // range from 0.0 to 1.0, should be color normalized 460 float radius; 461 462 vec3_t transformed; // origin in local coordinate system 463 464 // Ridah 465 int overdraw; 466 // done. 467 468 shader_t *dlshader; //----(SA) adding a shader to dlights, so, if desired, we can change the blend or texture of a dlight 469 470 qboolean forced; //----(SA) use this dlight when r_dynamiclight is either 1 or 2 (rather than just 1) for "important" gameplay lights (alarm lights, etc) 471 //done 472 473 } dlight_t; 474 475 // trRefdef_t holds everything that comes in refdef_t, 476 // as well as the locally generated scene information 477 typedef struct { 478 int x, y, width, height; 479 float fov_x, fov_y; 480 vec3_t vieworg; 481 vec3_t viewaxis[3]; // transformation matrix 482 483 stereoFrame_t stereoFrame; 484 485 int time; // time in milliseconds for shader effects and other time dependent rendering issues 486 int rdflags; // RDF_NOWORLDMODEL, etc 487 488 // 1 bits will prevent the associated area from rendering at all 489 byte areamask[MAX_MAP_AREA_BYTES]; 490 qboolean areamaskModified; // qtrue if areamask changed since last scene 491 492 double floatTime; // tr.refdef.time / 1000.0 493 494 // text messages for deform text shaders 495 char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; 496 497 int num_entities; 498 trRefEntity_t *entities; 499 500 int num_dlights; 501 struct dlight_s *dlights; 502 503 int num_coronas; 504 struct corona_s *coronas; 505 506 int numPolys; 507 struct srfPoly_s *polys; 508 509 int numDrawSurfs; 510 struct drawSurf_s *drawSurfs; 511 } trRefdef_t; 512 513 514 //================================================================================= 515 516 // max surfaces per-skin 517 // This is an arbitry limit. Vanilla Q3 only supported 32 surfaces in skins but failed to 518 // enforce the maximum limit when reading skin files. It was possile to use more than 32 519 // surfaces which accessed out of bounds memory past end of skin->surfaces hunk block. 520 #define MAX_SKIN_SURFACES 256 521 522 // skins allow models to be retextured without modifying the model file 523 typedef struct { 524 char name[MAX_QPATH]; 525 shader_t *shader; 526 } skinSurface_t; 527 528 //----(SA) modified 529 #define MAX_PART_MODELS 5 530 531 typedef struct { 532 char type[MAX_QPATH]; // md3_lower, md3_lbelt, md3_rbelt, etc. 533 char model[MAX_QPATH]; // lower.md3, belt1.md3, etc. 534 } skinModel_t; 535 536 typedef struct skin_s { 537 char name[MAX_QPATH]; // game path, including extension 538 int numSurfaces; 539 int numModels; 540 skinSurface_t *surfaces; // dynamically allocated array of surfaces 541 skinModel_t *models[MAX_PART_MODELS]; 542 vec3_t scale; //----(SA) added 543 } skin_t; 544 //----(SA) end 545 546 typedef struct { 547 int originalBrushNumber; 548 vec3_t bounds[2]; 549 550 unsigned colorInt; // in packed byte format 551 float tcScale; // texture coordinate vector scales 552 fogParms_t parms; 553 554 // for clipping distance in fog when outside 555 qboolean hasSurface; 556 float surface[4]; 557 } fog_t; 558 559 typedef struct { 560 orientationr_t or; 561 orientationr_t world; 562 vec3_t pvsOrigin; // may be different than or.origin for portals 563 qboolean isPortal; // true if this view is through a portal 564 qboolean isMirror; // the portal is a mirror, invert the face culling 565 int frameSceneNum; // copied from tr.frameSceneNum 566 int frameCount; // copied from tr.frameCount 567 cplane_t portalPlane; // clip anything behind this if mirroring 568 int viewportX, viewportY, viewportWidth, viewportHeight; 569 float fovX, fovY; 570 float projectionMatrix[16]; 571 cplane_t frustum[4]; 572 vec3_t visBounds[2]; 573 float zFar; 574 stereoFrame_t stereoFrame; 575 576 int dirty; 577 578 glfog_t glFog; // fog parameters //----(SA) added 579 580 } viewParms_t; 581 582 583 /* 584 ============================================================================== 585 586 SURFACES 587 588 ============================================================================== 589 */ 590 591 // any changes in surfaceType must be mirrored in rb_surfaceTable[] 592 // NOTE: also mirror changes to max2skl.c 593 typedef enum { 594 SF_BAD, 595 SF_SKIP, // ignore 596 SF_FACE, 597 SF_GRID, 598 SF_TRIANGLES, 599 SF_POLY, 600 SF_MD3, 601 SF_MDC, 602 SF_MDS, 603 SF_MDR, 604 SF_IQM, 605 SF_FLARE, 606 SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity 607 608 SF_NUM_SURFACE_TYPES, 609 SF_MAX = 0xffffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) 610 } surfaceType_t; 611 612 typedef struct drawSurf_s { 613 unsigned sort; // bit combination for fast compares 614 surfaceType_t *surface; // any of surface*_t 615 } drawSurf_t; 616 617 #define MAX_FACE_POINTS 64 618 619 #define MAX_PATCH_SIZE 32 // max dimensions of a patch mesh in map file 620 #define MAX_GRID_SIZE 65 // max dimensions of a grid mesh in memory 621 622 // when cgame directly specifies a polygon, it becomes a srfPoly_t 623 // as soon as it is called 624 typedef struct srfPoly_s { 625 surfaceType_t surfaceType; 626 qhandle_t hShader; 627 int fogIndex; 628 int numVerts; 629 polyVert_t *verts; 630 } srfPoly_t; 631 632 633 typedef struct srfFlare_s { 634 surfaceType_t surfaceType; 635 vec3_t origin; 636 vec3_t normal; 637 vec3_t color; 638 } srfFlare_t; 639 640 641 typedef struct srfGridMesh_s { 642 surfaceType_t surfaceType; 643 644 // dynamic lighting information 645 int dlightBits; 646 647 // culling information 648 vec3_t meshBounds[2]; 649 vec3_t localOrigin; 650 float meshRadius; 651 652 // lod information, which may be different 653 // than the culling information to allow for 654 // groups of curves that LOD as a unit 655 vec3_t lodOrigin; 656 float lodRadius; 657 int lodFixed; 658 int lodStitched; 659 660 // vertexes 661 int width, height; 662 float *widthLodError; 663 float *heightLodError; 664 drawVert_t verts[1]; // variable sized 665 } srfGridMesh_t; 666 667 668 #define VERTEXSIZE 8 669 typedef struct { 670 surfaceType_t surfaceType; 671 cplane_t plane; 672 673 // dynamic lighting information 674 int dlightBits; 675 676 // triangle definitions (no normals at points) 677 int numPoints; 678 int numIndices; 679 int ofsIndices; 680 float points[1][VERTEXSIZE]; // variable sized 681 // there is a variable length list of indices here also 682 } srfSurfaceFace_t; 683 684 685 // misc_models in maps are turned into direct geometry by q3map 686 typedef struct { 687 surfaceType_t surfaceType; 688 689 // dynamic lighting information 690 int dlightBits; 691 692 // culling information (FIXME: use this!) 693 vec3_t bounds[2]; 694 vec3_t localOrigin; 695 float radius; 696 697 // triangle definitions 698 int numIndexes; 699 int *indexes; 700 701 int numVerts; 702 drawVert_t *verts; 703 } srfTriangles_t; 704 705 // inter-quake-model 706 typedef struct { 707 int num_vertexes; 708 int num_triangles; 709 int num_frames; 710 int num_surfaces; 711 int num_joints; 712 int num_poses; 713 struct srfIQModel_s *surfaces; 714 715 int *triangles; 716 717 // vertex arrays 718 float *positions; 719 float *texcoords; 720 float *normals; 721 float *tangents; 722 byte *colors; 723 int *influences; // [num_vertexes] indexes into influenceBlendVertexes 724 // unique list of vertex blend indexes/weights for faster CPU vertex skinning 725 byte *influenceBlendIndexes; // [num_influences] 726 union { 727 float *f; 728 byte *b; 729 } influenceBlendWeights; // [num_influences] 730 731 // depending upon the exporter, blend indices and weights might be int/float 732 // as opposed to the recommended byte/byte, for example Noesis exports 733 // int/float whereas the official IQM tool exports byte/byte 734 int blendWeightsType; // IQM_UBYTE or IQM_FLOAT 735 736 char *jointNames; 737 int *jointParents; 738 float *jointMats; 739 float *poseMats; 740 float *bounds; 741 } iqmData_t; 742 743 // inter-quake-model surface 744 typedef struct srfIQModel_s { 745 surfaceType_t surfaceType; 746 char name[MAX_QPATH]; 747 shader_t *shader; 748 iqmData_t *data; 749 int first_vertex, num_vertexes; 750 int first_triangle, num_triangles; 751 int first_influence, num_influences; 752 } srfIQModel_t; 753 754 extern void( *rb_surfaceTable[SF_NUM_SURFACE_TYPES] ) ( void * ); 755 756 /* 757 ============================================================================== 758 759 BRUSH MODELS 760 761 ============================================================================== 762 */ 763 764 765 // 766 // in memory representation 767 // 768 769 #define SIDE_FRONT 0 770 #define SIDE_BACK 1 771 #define SIDE_ON 2 772 773 typedef struct msurface_s { 774 int viewCount; // if == tr.viewCount, already added 775 struct shader_s *shader; 776 int fogIndex; 777 778 surfaceType_t *data; // any of srf*_t 779 } msurface_t; 780 781 782 783 #define CONTENTS_NODE -1 784 typedef struct mnode_s { 785 // common with leaf and node 786 int contents; // -1 for nodes, to differentiate from leafs 787 int visframe; // node needs to be traversed if current 788 vec3_t mins, maxs; // for bounding box culling 789 struct mnode_s *parent; 790 791 // node specific 792 cplane_t *plane; 793 struct mnode_s *children[2]; 794 795 // leaf specific 796 int cluster; 797 int area; 798 799 msurface_t **firstmarksurface; 800 int nummarksurfaces; 801 } mnode_t; 802 803 typedef struct { 804 vec3_t bounds[2]; // for culling 805 msurface_t *firstSurface; 806 int numSurfaces; 807 } bmodel_t; 808 809 typedef struct { 810 char name[MAX_QPATH]; // ie: maps/tim_dm2.bsp 811 char baseName[MAX_QPATH]; // ie: tim_dm2 812 813 int dataSize; 814 815 int numShaders; 816 dshader_t *shaders; 817 818 bmodel_t *bmodels; 819 820 int numplanes; 821 cplane_t *planes; 822 823 int numnodes; // includes leafs 824 int numDecisionNodes; 825 mnode_t *nodes; 826 827 int numsurfaces; 828 msurface_t *surfaces; 829 830 int nummarksurfaces; 831 msurface_t **marksurfaces; 832 833 int numfogs; 834 fog_t *fogs; 835 836 vec3_t lightGridOrigin; 837 vec3_t lightGridSize; 838 vec3_t lightGridInverseSize; 839 int lightGridBounds[3]; 840 byte *lightGridData; 841 842 int numClusters; 843 int clusterBytes; 844 const byte *vis; // may be passed in by CM_LoadMap to save space 845 846 byte *novis; // clusterBytes of 0xff 847 848 char *entityString; 849 char *entityParsePoint; 850 } world_t; 851 852 //====================================================================== 853 854 typedef enum { 855 MOD_BAD, 856 MOD_BRUSH, 857 MOD_MESH, 858 MOD_MDS, 859 MOD_MDC, // Ridah 860 MOD_MDR, 861 MOD_IQM 862 } modtype_t; 863 864 typedef struct model_s { 865 char name[MAX_QPATH]; 866 modtype_t type; 867 int index; // model = tr.models[model->index] 868 869 int dataSize; // just for listing purposes 870 bmodel_t *bmodel; // only if type == MOD_BRUSH 871 md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH 872 mdsHeader_t *mds; // only if type == MOD_MDS 873 mdcHeader_t *mdc[MD3_MAX_LODS]; // only if type == MOD_MDC 874 void *modelData; // only if type == (MOD_MDR | MOD_IQM) 875 876 int numLods; 877 878 // GR - model tessellation capability flag 879 int ATI_tess; 880 } model_t; 881 882 883 #define MAX_MOD_KNOWN 2048 884 885 void R_ModelInit( void ); 886 model_t *R_GetModelByHandle( qhandle_t hModel ); 887 int R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagName, int startIndex ); 888 void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ); 889 890 void R_Modellist_f( void ); 891 892 //==================================================== 893 extern refimport_t ri; 894 895 #define MAX_DRAWIMAGES 2048 896 #define MAX_SKINS 1024 897 898 899 #define MAX_DRAWSURFS 0x10000 900 #define DRAWSURF_MASK ( MAX_DRAWSURFS - 1 ) 901 902 /* 903 904 the drawsurf sort data is packed into a single 32 bit value so it can be 905 compared quickly during the qsorting process 906 907 the bits are allocated as follows: 908 909 (SA) modified for Wolf (11 bits of entity num) 910 911 old: 912 913 22 - 31 : sorted shader index 914 12 - 21 : entity index 915 3 - 7 : fog index 916 2 : used to be clipped flag 917 0 - 1 : dlightmap index 918 919 #define QSORT_SHADERNUM_SHIFT 22 920 #define QSORT_ENTITYNUM_SHIFT 12 921 #define QSORT_FOGNUM_SHIFT 3 922 923 new: 924 925 22 - 31 : sorted shader index 926 11 - 21 : entity index 927 2 - 6 : fog index 928 removed : used to be clipped flag 929 0 - 1 : dlightmap index 930 931 #define QSORT_SHADERNUM_SHIFT 22 932 #define QSORT_ENTITYNUM_SHIFT 11 933 #define QSORT_FOGNUM_SHIFT 2 934 935 */ 936 937 #define QSORT_FOGNUM_SHIFT 2 938 #define QSORT_REFENTITYNUM_SHIFT 11 939 #define QSORT_SHADERNUM_SHIFT (QSORT_REFENTITYNUM_SHIFT+REFENTITYNUM_BITS) 940 #if (QSORT_SHADERNUM_SHIFT+SHADERNUM_BITS) > 32 941 #error "Need to update sorting, too many bits." 942 #endif 943 944 // GR - tessellation flag in bit 8 945 #define QSORT_ATI_TESS_SHIFT 8 946 // GR - TruForm flags 947 #define ATI_TESS_TRUFORM 1 948 #define ATI_TESS_NONE 0 949 950 extern int gl_filter_min, gl_filter_max; 951 952 /* 953 ** performanceCounters_t 954 */ 955 typedef struct { 956 int c_sphere_cull_patch_in, c_sphere_cull_patch_clip, c_sphere_cull_patch_out; 957 int c_box_cull_patch_in, c_box_cull_patch_clip, c_box_cull_patch_out; 958 int c_sphere_cull_md3_in, c_sphere_cull_md3_clip, c_sphere_cull_md3_out; 959 int c_box_cull_md3_in, c_box_cull_md3_clip, c_box_cull_md3_out; 960 961 int c_leafs; 962 int c_dlightSurfaces; 963 int c_dlightSurfacesCulled; 964 } frontEndCounters_t; 965 966 #define FOG_TABLE_SIZE 256 967 #define FUNCTABLE_SIZE 1024 968 #define FUNCTABLE_SIZE2 10 969 #define FUNCTABLE_MASK ( FUNCTABLE_SIZE - 1 ) 970 971 972 // the renderer front end should never modify glstate_t 973 typedef struct { 974 int currenttextures[2]; 975 int currenttmu; 976 qboolean finishCalled; 977 int texEnv[2]; 978 int faceCulling; 979 unsigned long glStateBits; 980 } glstate_t; 981 982 983 typedef struct { 984 int c_surfaces, c_shaders, c_vertexes, c_indexes, c_totalIndexes; 985 float c_overDraw; 986 987 int c_dlightVertexes; 988 int c_dlightIndexes; 989 990 int c_flareAdds; 991 int c_flareTests; 992 int c_flareRenders; 993 994 int msec; // total msec for backend run 995 } backEndCounters_t; 996 997 // all state modified by the back end is seperated 998 // from the front end state 999 typedef struct { 1000 trRefdef_t refdef; 1001 viewParms_t viewParms; 1002 orientationr_t or; 1003 backEndCounters_t pc; 1004 qboolean isHyperspace; 1005 trRefEntity_t *currentEntity; 1006 qboolean skyRenderedThisView; // flag for drawing sun 1007 1008 qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes 1009 byte color2D[4]; 1010 qboolean vertexes2D; // shader needs to be finished 1011 #ifdef USE_BLOOM 1012 qboolean doneBloom; // done bloom this frame 1013 qboolean doneSurfaces; // done any 3d surfaces already 1014 #endif 1015 trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering 1016 } backEndState_t; 1017 1018 /* 1019 ** trGlobals_t 1020 ** 1021 ** Most renderer globals are defined here. 1022 ** backend functions should never modify any of these fields, 1023 ** but may read fields that aren't dynamically modified 1024 ** by the frontend. 1025 */ 1026 typedef struct { 1027 qboolean registered; // cleared at shutdown, set at beginRegistration 1028 1029 int visCount; // incremented every time a new vis cluster is entered 1030 int frameCount; // incremented every frame 1031 int sceneCount; // incremented every scene 1032 int viewCount; // incremented every view (twice a scene if portaled) 1033 // and every R_MarkFragments call 1034 1035 int frameSceneNum; // zeroed at RE_BeginFrame 1036 1037 qboolean worldMapLoaded; 1038 world_t *world; 1039 1040 const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load 1041 1042 image_t *defaultImage; 1043 image_t *scratchImage[32]; 1044 image_t *fogImage; 1045 image_t *dlightImage; // inverse-square highlight for projective adding 1046 image_t *flareImage; 1047 image_t *whiteImage; // full of 0xff 1048 image_t *identityLightImage; // full of tr.identityLightByte 1049 1050 shader_t *defaultShader; 1051 shader_t *shadowShader; 1052 shader_t *projectionShadowShader; 1053 shader_t *dlightShader; //----(SA) added 1054 1055 shader_t *flareShader; 1056 shader_t *spotFlareShader; 1057 char *sunShaderName; 1058 shader_t *sunShader; 1059 shader_t *sunflareShader[6]; //----(SA) for the camera lens flare effect for sun 1060 1061 int numLightmaps; 1062 image_t **lightmaps; 1063 1064 trRefEntity_t *currentEntity; 1065 trRefEntity_t worldEntity; // point currentEntity at this when rendering world 1066 int currentEntityNum; 1067 int shiftedEntityNum; // currentEntityNum << QSORT_REFENTITYNUM_SHIFT 1068 model_t *currentModel; 1069 1070 viewParms_t viewParms; 1071 1072 float identityLight; // 1.0 / ( 1 << overbrightBits ) 1073 int identityLightByte; // identityLight * 255 1074 int overbrightBits; // r_overbrightBits->integer, but set to 0 if no hw gamma 1075 1076 orientationr_t or; // for current entity 1077 1078 trRefdef_t refdef; 1079 1080 int viewCluster; 1081 1082 vec3_t sunLight; // from the sky shader for this level 1083 vec3_t sunDirection; 1084 1085 //----(SA) added 1086 float lightGridMulAmbient; // lightgrid multipliers specified in sky shader 1087 float lightGridMulDirected; // 1088 //----(SA) end 1089 1090 // qboolean levelGLFog; 1091 1092 frontEndCounters_t pc; 1093 int frontEndMsec; // not in pc due to clearing issue 1094 1095 // 1096 // put large tables at the end, so most elements will be 1097 // within the +/32K indexed range on risc processors 1098 // 1099 model_t *models[MAX_MOD_KNOWN]; 1100 int numModels; 1101 1102 int numImages; 1103 image_t *images[MAX_DRAWIMAGES]; 1104 1105 // shader indexes from other modules will be looked up in tr.shaders[] 1106 // shader indexes from drawsurfs will be looked up in sortedShaders[] 1107 // lower indexed sortedShaders must be rendered first (opaque surfaces before translucent) 1108 int numShaders; 1109 shader_t *shaders[MAX_SHADERS]; 1110 shader_t *sortedShaders[MAX_SHADERS]; 1111 1112 int numSkins; 1113 skin_t *skins[MAX_SKINS]; 1114 1115 float sinTable[FUNCTABLE_SIZE]; 1116 float squareTable[FUNCTABLE_SIZE]; 1117 float triangleTable[FUNCTABLE_SIZE]; 1118 float sawToothTable[FUNCTABLE_SIZE]; 1119 float inverseSawToothTable[FUNCTABLE_SIZE]; 1120 float fogTable[FOG_TABLE_SIZE]; 1121 1122 // RF, temp var used while parsing shader only 1123 int allowCompress; 1124 1125 } trGlobals_t; 1126 1127 extern backEndState_t backEnd; 1128 extern trGlobals_t tr; 1129 extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared during ref re-init 1130 extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init 1131 1132 // These two variables should live inside glConfig but can't because of compatibility issues to the original ID vms. 1133 // If you release a stand-alone game and your mod uses tr_types.h from this build you can safely move them to 1134 // the glconfig_t struct. 1135 extern qboolean textureFilterAnisotropic; 1136 extern int maxAnisotropy; 1137 extern float displayAspect; 1138 1139 // 1140 // cvars 1141 // 1142 extern cvar_t *r_flareSize; 1143 extern cvar_t *r_flareFade; 1144 // coefficient for the flare intensity falloff function. 1145 #define FLARE_STDCOEFF "150" 1146 extern cvar_t *r_flareCoeff; 1147 1148 extern cvar_t *r_railWidth; 1149 extern cvar_t *r_railCoreWidth; 1150 extern cvar_t *r_railSegmentLength; 1151 1152 extern cvar_t *r_ignore; // used for debugging anything 1153 extern cvar_t *r_verbose; // used for verbose debug spew 1154 extern cvar_t *r_ignoreFastPath; // allows us to ignore our Tess fast paths 1155 1156 extern cvar_t *r_znear; // near Z clip plane 1157 extern cvar_t *r_zproj; // z distance of projection plane 1158 extern cvar_t *r_stereoSeparation; // separation of cameras for stereo rendering 1159 extern cvar_t *r_zfar; // far Z clip plane 1160 1161 extern cvar_t *r_stencilbits; // number of desired stencil bits 1162 extern cvar_t *r_depthbits; // number of desired depth bits 1163 extern cvar_t *r_colorbits; // number of desired color bits, only relevant for fullscreen 1164 extern cvar_t *r_texturebits; // number of desired texture bits 1165 // 0 = use framebuffer depth 1166 // 16 = use 16-bit textures 1167 // 32 = use 32-bit textures 1168 // all else = error 1169 extern cvar_t *r_ext_multisample; 1170 1171 extern cvar_t *r_measureOverdraw; // enables stencil buffer overdraw measurement 1172 1173 extern cvar_t *r_lodbias; // push/pull LOD transitions 1174 extern cvar_t *r_lodscale; 1175 1176 extern cvar_t *r_primitives; // "0" = based on compiled vertex array existance 1177 // "1" = glDrawElemet tristrips 1178 // "2" = glDrawElements triangles 1179 // "-1" = no drawing 1180 1181 extern cvar_t *r_inGameVideo; // controls whether in game video should be draw 1182 extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn 1183 extern cvar_t *r_drawSun; // controls drawing of sun quad 1184 // "0" no sun 1185 // "1" draw sun 1186 // "2" also draw lens flare effect centered on sun 1187 extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled 1188 extern cvar_t *r_dlightScale; // global user attenuation of dlights 1189 extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity 1190 1191 extern cvar_t *r_norefresh; // bypasses the ref rendering 1192 extern cvar_t *r_drawentities; // disable/enable entity rendering 1193 extern cvar_t *r_drawworld; // disable/enable world rendering 1194 extern cvar_t *r_speeds; // various levels of information display 1195 extern cvar_t *r_detailTextures; // enables/disables detail texturing stages 1196 extern cvar_t *r_novis; // disable/enable usage of PVS 1197 extern cvar_t *r_nocull; 1198 extern cvar_t *r_facePlaneCull; // enables culling of planar surfaces with back side test 1199 extern cvar_t *r_nocurves; 1200 extern cvar_t *r_showcluster; 1201 1202 extern cvar_t *r_mode; // video mode 1203 extern cvar_t *r_fullscreen; 1204 extern cvar_t *r_noborder; 1205 extern cvar_t *r_gamma; 1206 extern cvar_t *r_ignorehwgamma; // overrides hardware gamma capabilities 1207 extern cvar_t *r_displayRefresh; // optional display refresh option 1208 1209 extern cvar_t *r_allowExtensions; // global enable/disable of OpenGL extensions 1210 extern cvar_t *r_ext_compressed_textures; // these control use of specific extensions 1211 extern cvar_t *r_ext_multitexture; 1212 extern cvar_t *r_ext_compiled_vertex_array; 1213 extern cvar_t *r_ext_texture_env_add; 1214 extern cvar_t *r_ext_texture_filter_anisotropic; 1215 extern cvar_t *r_ext_max_anisotropy; 1216 1217 //----(SA) added 1218 extern cvar_t *r_ext_ATI_pntriangles; 1219 extern cvar_t *r_ati_truform_tess; 1220 extern cvar_t *r_ati_truform_pointmode; //----(SA) 1221 extern cvar_t *r_ati_truform_normalmode; //----(SA) 1222 extern cvar_t *r_ati_fsaa_samples; //DAJ 1223 extern cvar_t *r_ext_NV_fog_dist; 1224 extern cvar_t *r_nv_fogdist_mode; 1225 //----(SA) end 1226 1227 extern cvar_t *r_waterFogColor; //----(SA) added 1228 extern cvar_t *r_mapFogColor; //----(SA) added 1229 extern cvar_t *r_savegameFogColor; //----(SA) added 1230 1231 extern cvar_t *r_nobind; // turns off binding to appropriate textures 1232 extern cvar_t *r_singleShader; // make most world faces use default shader 1233 extern cvar_t *r_roundImagesDown; 1234 extern cvar_t *r_lowMemTextureSize; 1235 extern cvar_t *r_lowMemTextureThreshold; 1236 extern cvar_t *r_rmse; // reduces textures to this root mean square error 1237 extern cvar_t *r_colorMipLevels; // development aid to see texture mip usage 1238 extern cvar_t *r_picmip; // controls picmip values 1239 extern cvar_t *r_picmip2; // controls picmip values for designated (character skin) textures 1240 extern cvar_t *r_finish; 1241 extern cvar_t *r_drawBuffer; 1242 extern cvar_t *r_glIgnoreWicked3D; 1243 extern cvar_t *r_swapInterval; 1244 extern cvar_t *r_textureMode; 1245 extern cvar_t *r_offsetFactor; 1246 extern cvar_t *r_offsetUnits; 1247 1248 extern cvar_t *r_fullbright; // avoid lightmap pass 1249 extern cvar_t *r_lightmap; // render lightmaps only 1250 extern cvar_t *r_vertexLight; // vertex lighting mode for better performance 1251 extern cvar_t *r_uiFullScreen; // ui is running fullscreen 1252 1253 extern cvar_t *r_logFile; // number of frames to emit GL logs 1254 extern cvar_t *r_showtris; // enables wireframe rendering of the world 1255 extern cvar_t *r_showsky; // forces sky in front of all surfaces 1256 extern cvar_t *r_shownormals; // draws wireframe normals 1257 extern cvar_t *r_clear; // force screen clear every frame 1258 1259 extern cvar_t *r_shadows; // controls shadows: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection 1260 extern cvar_t *r_flares; // light flares 1261 1262 extern cvar_t *r_portalsky; // (SA) added 1263 extern cvar_t *r_intensity; 1264 1265 extern cvar_t *r_lockpvs; 1266 extern cvar_t *r_noportals; 1267 extern cvar_t *r_portalOnly; 1268 1269 extern cvar_t *r_subdivisions; 1270 extern cvar_t *r_lodCurveError; 1271 extern cvar_t *r_skipBackEnd; 1272 1273 extern cvar_t *r_stereoEnabled; 1274 extern cvar_t *r_anaglyphMode; 1275 1276 extern cvar_t *r_greyscale; 1277 1278 extern cvar_t *r_ignoreGLErrors; 1279 1280 extern cvar_t *r_overBrightBits; 1281 extern cvar_t *r_mapOverBrightBits; 1282 1283 extern cvar_t *r_debugSurface; 1284 extern cvar_t *r_simpleMipMaps; 1285 1286 extern cvar_t *r_showImages; 1287 extern cvar_t *r_debugSort; 1288 1289 extern cvar_t *r_printShaders; 1290 extern cvar_t *r_saveFontData; 1291 1292 extern cvar_t *r_marksOnTriangleMeshes; 1293 1294 // Ridah 1295 extern cvar_t *r_bonesDebug; 1296 // done. 1297 1298 // Rafael - wolf fog 1299 extern cvar_t *r_wolffog; 1300 // done 1301 1302 extern cvar_t *r_highQualityVideo; 1303 //==================================================================== 1304 1305 float R_NoiseGet4f( float x, float y, float z, double t ); 1306 void R_NoiseInit( void ); 1307 1308 void R_SwapBuffers( int ); 1309 1310 void R_RenderView( viewParms_t *parms ); 1311 1312 void R_AddMD3Surfaces( trRefEntity_t *e ); 1313 void R_AddNullModelSurfaces( trRefEntity_t *e ); 1314 void R_AddBeamSurfaces( trRefEntity_t *e ); 1315 void R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater ); 1316 void R_AddLightningBoltSurfaces( trRefEntity_t *e ); 1317 1318 void R_TagInfo_f( void ); 1319 1320 void R_AddPolygonSurfaces( void ); 1321 1322 // GR - add tessellation flag 1323 void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, 1324 int *fogNum, int *dlightMap, int *atiTess ); 1325 1326 // GR - add tessellation flag 1327 void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, int dlightMap, int atiTess ); 1328 1329 1330 #define CULL_IN 0 // completely unclipped 1331 #define CULL_CLIP 1 // clipped by one or more planes 1332 #define CULL_OUT 2 // completely outside the clipping planes 1333 void R_LocalNormalToWorld( vec3_t local, vec3_t world ); 1334 void R_LocalPointToWorld( vec3_t local, vec3_t world ); 1335 int R_CullLocalBox( vec3_t bounds[2] ); 1336 int R_CullPointAndRadius( vec3_t origin, float radius ); 1337 int R_CullLocalPointAndRadius( vec3_t origin, float radius ); 1338 1339 void R_SetupProjection(viewParms_t *dest, float zProj, qboolean computeFrustum); 1340 void R_RotateForEntity( const trRefEntity_t * ent, const viewParms_t * viewParms, orientationr_t * or ); 1341 1342 /* 1343 ** GL wrapper/helper functions 1344 */ 1345 void GL_Bind( image_t *image ); 1346 void GL_SetDefaultState( void ); 1347 void GL_SelectTexture( int unit ); 1348 void GL_TextureMode( const char *string ); 1349 void GL_CheckErrors( void ); 1350 void GL_State( unsigned long stateVector ); 1351 void GL_TexEnv( int env ); 1352 void GL_Cull( int cullType ); 1353 1354 #define GLS_SRCBLEND_ZERO 0x00000001 1355 #define GLS_SRCBLEND_ONE 0x00000002 1356 #define GLS_SRCBLEND_DST_COLOR 0x00000003 1357 #define GLS_SRCBLEND_ONE_MINUS_DST_COLOR 0x00000004 1358 #define GLS_SRCBLEND_SRC_ALPHA 0x00000005 1359 #define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA 0x00000006 1360 #define GLS_SRCBLEND_DST_ALPHA 0x00000007 1361 #define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA 0x00000008 1362 #define GLS_SRCBLEND_ALPHA_SATURATE 0x00000009 1363 #define GLS_SRCBLEND_BITS 0x0000000f 1364 1365 #define GLS_DSTBLEND_ZERO 0x00000010 1366 #define GLS_DSTBLEND_ONE 0x00000020 1367 #define GLS_DSTBLEND_SRC_COLOR 0x00000030 1368 #define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR 0x00000040 1369 #define GLS_DSTBLEND_SRC_ALPHA 0x00000050 1370 #define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA 0x00000060 1371 #define GLS_DSTBLEND_DST_ALPHA 0x00000070 1372 #define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA 0x00000080 1373 #define GLS_DSTBLEND_BITS 0x000000f0 1374 1375 #define GLS_DEPTHMASK_TRUE 0x00000100 1376 1377 #define GLS_POLYMODE_LINE 0x00001000 1378 1379 #define GLS_DEPTHTEST_DISABLE 0x00010000 1380 #define GLS_DEPTHFUNC_EQUAL 0x00020000 1381 1382 #define GLS_ATEST_GT_0 0x10000000 1383 #define GLS_ATEST_LT_80 0x20000000 1384 #define GLS_ATEST_GE_80 0x40000000 1385 #define GLS_ATEST_BITS 0x70000000 1386 1387 #define GLS_DEFAULT GLS_DEPTHMASK_TRUE 1388 1389 void RE_StretchRaw( int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty ); 1390 void RE_UploadCinematic( int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty ); 1391 1392 void RE_BeginFrame( stereoFrame_t stereoFrame ); 1393 void RE_BeginRegistration( glconfig_t *glconfig ); 1394 void RE_LoadWorldMap( const char *mapname ); 1395 void RE_SetWorldVisData( const byte *vis ); 1396 qhandle_t RE_RegisterModel( const char *name ); 1397 qhandle_t RE_RegisterSkin( const char *name ); 1398 void RE_Shutdown( qboolean destroyWindow ); 1399 1400 qboolean R_GetEntityToken( char *buffer, int size ); 1401 1402 //----(SA) 1403 qboolean RE_GetSkinModel( qhandle_t skinid, const char *type, char *name ); 1404 qhandle_t RE_GetShaderFromModel( qhandle_t modelid, int surfnum, int withlightmap ); //----(SA) 1405 //----(SA) end 1406 1407 model_t *R_AllocModel( void ); 1408 1409 void R_Init( void ); 1410 image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ); 1411 image_t *R_FindImageFileExt( const char *name, imgType_t type, imgFlags_t flags, qboolean characterMip ); //----(SA) added 1412 1413 image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, int internalFormat ); 1414 //----(SA) added (didn't want to modify all instances of R_CreateImage() 1415 image_t *R_CreateImageExt( const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, int internalFormat, qboolean characterMip ); 1416 //----(SA) end 1417 qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ); 1418 1419 void R_SetColorMappings( void ); 1420 void R_GammaCorrect( byte *buffer, int bufSize ); 1421 1422 void R_ImageList_f( void ); 1423 void R_SkinList_f( void ); 1424 // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 1425 const void *RB_TakeScreenshotCmd( const void *data ); 1426 void R_ScreenShot_f( void ); 1427 void R_ScreenShotJPEG_f( void ); 1428 1429 void R_InitFogTable( void ); 1430 float R_FogFactor( float s, float t ); 1431 void R_InitImages( void ); 1432 void R_DeleteTextures( void ); 1433 int R_SumOfUsedImages( void ); 1434 void R_InitSkins( void ); 1435 skin_t *R_GetSkinByHandle( qhandle_t hSkin ); 1436 1437 const void *RB_TakeVideoFrameCmd( const void *data ); 1438 1439 1440 // 1441 // tr_shader.c 1442 // 1443 qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ); 1444 qhandle_t RE_RegisterShader( const char *name ); 1445 qhandle_t RE_RegisterShaderNoMip( const char *name ); 1446 qhandle_t RE_RegisterShaderFromImage( const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage ); 1447 1448 shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ); 1449 shader_t *R_GetShaderByHandle( qhandle_t hShader ); 1450 shader_t *R_GetShaderByState( int index, long *cycleTime ); 1451 shader_t *R_FindShaderByName( const char *name ); 1452 void R_InitShaders( void ); 1453 void R_ShaderList_f( void ); 1454 void R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ); 1455 1456 /* 1457 ==================================================================== 1458 1459 IMPLEMENTATION SPECIFIC FUNCTIONS 1460 1461 ==================================================================== 1462 */ 1463 1464 void GLimp_Init( qboolean fixedFunction ); 1465 void GLimp_Shutdown( void ); 1466 void GLimp_EndFrame( void ); 1467 1468 void GLimp_LogComment( char *comment ); 1469 void GLimp_Minimize(void); 1470 1471 void GLimp_SetGamma( unsigned char red[256], 1472 unsigned char green[256], 1473 unsigned char blue[256] ); 1474 1475 1476 /* 1477 ==================================================================== 1478 1479 TESSELATOR/SHADER DECLARATIONS 1480 1481 ==================================================================== 1482 */ 1483 typedef byte color4ub_t[4]; 1484 1485 typedef struct stageVars 1486 { 1487 color4ub_t colors[SHADER_MAX_VERTEXES]; 1488 vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES]; 1489 } stageVars_t; 1490 1491 typedef struct shaderCommands_s 1492 { 1493 glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); 1494 vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); 1495 vec4_t normal[SHADER_MAX_VERTEXES] QALIGN(16); 1496 vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16); 1497 color4ub_t vertexColors[SHADER_MAX_VERTEXES] QALIGN(16); 1498 int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); 1499 1500 stageVars_t svars QALIGN(16); 1501 1502 color4ub_t constantColor255[SHADER_MAX_VERTEXES] QALIGN(16); 1503 1504 shader_t *shader; 1505 double shaderTime; 1506 int fogNum; 1507 1508 int dlightBits; // or together of all vertexDlightBits 1509 1510 int numIndexes; 1511 int numVertexes; 1512 1513 qboolean ATI_tess; 1514 1515 // info extracted from current shader 1516 int numPasses; 1517 void ( *currentStageIteratorFunc )( void ); 1518 shaderStage_t **xstages; 1519 } shaderCommands_t; 1520 1521 extern shaderCommands_t tess; 1522 1523 #ifdef USE_BLOOM 1524 void RB_SetGL2D (void); 1525 #endif 1526 void RB_BeginSurface( shader_t *shader, int fogNum ); 1527 void RB_EndSurface( void ); 1528 void RB_CheckOverflow( int verts, int indexes ); 1529 #define RB_CHECKOVERFLOW( v,i ) if ( tess.numVertexes + ( v ) >= SHADER_MAX_VERTEXES || tess.numIndexes + ( i ) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow( v,i );} 1530 1531 void RB_StageIteratorGeneric( void ); 1532 void RB_StageIteratorSky( void ); 1533 void RB_StageIteratorVertexLitTexture( void ); 1534 void RB_StageIteratorLightmappedMultitexture( void ); 1535 1536 void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color ); 1537 void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 ); 1538 1539 void RB_ShowImages( void ); 1540 1541 1542 /* 1543 ============================================================ 1544 1545 WORLD MAP 1546 1547 ============================================================ 1548 */ 1549 1550 void R_AddBrushModelSurfaces( trRefEntity_t *e ); 1551 void R_AddWorldSurfaces( void ); 1552 1553 1554 /* 1555 ============================================================ 1556 1557 FLARES 1558 1559 ============================================================ 1560 */ 1561 1562 void R_ClearFlares( void ); 1563 1564 void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, float scale, vec3_t normal, int id, int flags ); // TTimo updated prototype 1565 void RB_AddDlightFlares( void ); 1566 void RB_RenderFlares( void ); 1567 1568 /* 1569 ============================================================ 1570 1571 LIGHTS 1572 1573 ============================================================ 1574 */ 1575 1576 void R_DlightBmodel( bmodel_t *bmodel ); 1577 void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); 1578 void R_TransformDlights( int count, dlight_t * dl, orientationr_t * or ); 1579 int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); 1580 1581 1582 /* 1583 ============================================================ 1584 1585 SHADOWS 1586 1587 ============================================================ 1588 */ 1589 1590 void RB_ShadowTessEnd( void ); 1591 void RB_ShadowFinish( void ); 1592 void RB_ProjectionShadowDeform( void ); 1593 1594 /* 1595 ============================================================ 1596 1597 SKIES 1598 1599 ============================================================ 1600 */ 1601 1602 void R_BuildCloudData( shaderCommands_t *shader ); 1603 void R_InitSkyTexCoords( float cloudLayerHeight ); 1604 void R_DrawSkyBox( shaderCommands_t *shader ); 1605 void RB_DrawSun( float scale, shader_t *shader ); 1606 void RB_ClipSkyPolygons( shaderCommands_t *shader ); 1607 1608 /* 1609 ============================================================ 1610 1611 CURVE TESSELATION 1612 1613 ============================================================ 1614 */ 1615 1616 #define PATCH_STITCHING 1617 1618 srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, 1619 drawVert_t points[MAX_PATCH_SIZE * MAX_PATCH_SIZE] ); 1620 srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror ); 1621 srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror ); 1622 void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ); 1623 1624 /* 1625 ============================================================ 1626 1627 MARKERS, POLYGON PROJECTION ON WORLD POLYGONS 1628 1629 ============================================================ 1630 */ 1631 1632 int R_MarkFragments( int orientation, const vec3_t *points, const vec3_t projection, 1633 int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); 1634 1635 1636 /* 1637 ============================================================ 1638 1639 SCENE GENERATION 1640 1641 ============================================================ 1642 */ 1643 1644 void R_InitNextFrame( void ); 1645 1646 void RE_ClearScene( void ); 1647 void RE_AddRefEntityToScene( const refEntity_t *ent ); 1648 void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts ); 1649 // Ridah 1650 void RE_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ); 1651 // done. 1652 // Ridah 1653 void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b, int overdraw ); 1654 // done. 1655 //----(SA) 1656 void RE_AddCoronaToScene( const vec3_t org, float r, float g, float b, float scale, int id, int flags ); 1657 //----(SA) 1658 void RE_RenderScene( const refdef_t *fd ); 1659 1660 /* 1661 ============================================================= 1662 1663 UNCOMPRESSING BONES 1664 1665 ============================================================= 1666 */ 1667 1668 #define MC_BITS_X (16) 1669 #define MC_BITS_Y (16) 1670 #define MC_BITS_Z (16) 1671 #define MC_BITS_VECT (16) 1672 1673 #define MC_SCALE_X (1.0f/64) 1674 #define MC_SCALE_Y (1.0f/64) 1675 #define MC_SCALE_Z (1.0f/64) 1676 1677 void MC_UnCompress(float mat[3][4],const unsigned char * comp); 1678 1679 /* 1680 ============================================================= 1681 1682 ANIMATED MODELS 1683 1684 ============================================================= 1685 */ 1686 1687 void R_AddAnimSurfaces( trRefEntity_t *ent ); 1688 void RB_SurfaceAnim( mdsSurface_t *surfType ); 1689 int R_GetBoneTag( orientation_t *outTag, mdsHeader_t *mds, int startTagIndex, const refEntity_t *refent, const char *tagName ); 1690 void R_MDRAddAnimSurfaces( trRefEntity_t *ent ); 1691 void RB_MDRSurfaceAnim( mdrSurface_t *surface ); 1692 qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name ); 1693 void R_AddIQMSurfaces( trRefEntity_t *ent ); 1694 void RB_IQMSurfaceAnim( surfaceType_t *surface ); 1695 int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, 1696 int startFrame, int endFrame, 1697 float frac, const char *tagName, int startIndex ); 1698 1699 /* 1700 ============================================================= 1701 1702 IMAGE LOADERS 1703 1704 ============================================================= 1705 */ 1706 1707 void R_LoadBMP( const char *name, byte **pic, int *width, int *height ); 1708 void R_LoadJPG( const char *name, byte **pic, int *width, int *height ); 1709 void R_LoadPCX( const char *name, byte **pic, int *width, int *height ); 1710 void R_LoadPNG( const char *name, byte **pic, int *width, int *height ); 1711 void R_LoadTGA( const char *name, byte **pic, int *width, int *height ); 1712 1713 /* 1714 ============================================================= 1715 ============================================================= 1716 */ 1717 void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, 1718 vec4_t eye, vec4_t dst ); 1719 void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ); 1720 1721 void RB_DeformTessGeometry( void ); 1722 1723 void RB_CalcEnvironmentTexCoords( float *dstTexCoords ); 1724 void RB_CalcFireRiseEnvTexCoords( float *st ); 1725 void RB_CalcFogTexCoords( float *dstTexCoords ); 1726 void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords ); 1727 void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords ); 1728 void RB_CalcScaleTexCoords( const float scale[2], float *dstTexCoords ); 1729 void RB_CalcSwapTexCoords( float *dstTexCoords ); 1730 void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *dstTexCoords ); 1731 void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *dstTexCoords ); 1732 void RB_CalcModulateColorsByFog( unsigned char *dstColors ); 1733 void RB_CalcModulateAlphasByFog( unsigned char *dstColors ); 1734 void RB_CalcModulateRGBAsByFog( unsigned char *dstColors ); 1735 void RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors ); 1736 void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ); 1737 void RB_CalcAlphaFromEntity( unsigned char *dstColors ); 1738 void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors ); 1739 void RB_CalcStretchTexCoords( const waveForm_t *wf, float *texCoords ); 1740 void RB_CalcColorFromEntity( unsigned char *dstColors ); 1741 void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors ); 1742 void RB_CalcSpecularAlpha( unsigned char *alphas ); 1743 void RB_CalcDiffuseColor( unsigned char *colors ); 1744 1745 void RB_ZombieFXInit( void ); 1746 void RB_ZombieFXAddNewHit( int entityNum, const vec3_t hitPos, const vec3_t hitDir ); 1747 1748 1749 /* 1750 ============================================================= 1751 1752 RENDERER BACK END FUNCTIONS 1753 1754 ============================================================= 1755 */ 1756 1757 void RB_ExecuteRenderCommands( const void *data ); 1758 1759 /* 1760 ============================================================= 1761 1762 RENDERER BACK END COMMAND QUEUE 1763 1764 ============================================================= 1765 */ 1766 1767 #define MAX_RENDER_COMMANDS 0x40000 1768 1769 typedef struct { 1770 byte cmds[MAX_RENDER_COMMANDS]; 1771 int used; 1772 } renderCommandList_t; 1773 1774 typedef struct { 1775 int commandId; 1776 float color[4]; 1777 } setColorCommand_t; 1778 1779 typedef struct { 1780 int commandId; 1781 int buffer; 1782 } drawBufferCommand_t; 1783 1784 typedef struct { 1785 int commandId; 1786 image_t *image; 1787 int width; 1788 int height; 1789 void *data; 1790 } subImageCommand_t; 1791 1792 typedef struct { 1793 int commandId; 1794 } swapBuffersCommand_t; 1795 1796 typedef struct { 1797 int commandId; 1798 int buffer; 1799 } endFrameCommand_t; 1800 1801 typedef struct { 1802 int commandId; 1803 shader_t *shader; 1804 float x, y; 1805 float w, h; 1806 float s1, t1; 1807 float s2, t2; 1808 1809 byte gradientColor[4]; // color values 0-255 1810 int gradientType; //----(SA) added 1811 float angle; // NERVE - SMF 1812 } stretchPicCommand_t; 1813 1814 typedef struct { 1815 int commandId; 1816 trRefdef_t refdef; 1817 viewParms_t viewParms; 1818 drawSurf_t *drawSurfs; 1819 int numDrawSurfs; 1820 } drawSurfsCommand_t; 1821 1822 typedef struct { 1823 int commandId; 1824 int x; 1825 int y; 1826 int width; 1827 int height; 1828 char *fileName; 1829 qboolean jpeg; 1830 } screenshotCommand_t; 1831 1832 typedef struct { 1833 int commandId; 1834 int width; 1835 int height; 1836 byte *captureBuffer; 1837 byte *encodeBuffer; 1838 qboolean motionJpeg; 1839 } videoFrameCommand_t; 1840 1841 typedef struct 1842 { 1843 int commandId; 1844 1845 GLboolean rgba[4]; 1846 } colorMaskCommand_t; 1847 1848 typedef struct 1849 { 1850 int commandId; 1851 } clearDepthCommand_t; 1852 1853 typedef enum { 1854 RC_END_OF_LIST, 1855 RC_SET_COLOR, 1856 RC_STRETCH_PIC, 1857 RC_STRETCH_PIC_GRADIENT, // (SA) added 1858 RC_DRAW_SURFS, 1859 RC_DRAW_BUFFER, 1860 RC_SWAP_BUFFERS, 1861 RC_SCREENSHOT, 1862 RC_VIDEOFRAME, 1863 RC_COLORMASK, 1864 RC_CLEARDEPTH 1865 } renderCommand_t; 1866 1867 1868 // these are sort of arbitrary limits. 1869 // the limits apply to the sum of all scenes in a frame -- 1870 // the main view, all the 3D icons, etc 1871 1872 // Ridah, these aren't enough for cool effects 1873 //#define MAX_POLYS 256 1874 //#define MAX_POLYVERTS 1024 1875 #define MAX_POLYS 4096 1876 #define MAX_POLYVERTS 8192 1877 // done. 1878 1879 // all of the information needed by the back end must be 1880 // contained in a backEndData_t 1881 typedef struct { 1882 drawSurf_t drawSurfs[MAX_DRAWSURFS]; 1883 dlight_t dlights[MAX_DLIGHTS]; 1884 corona_t coronas[MAX_CORONAS]; //----(SA) 1885 trRefEntity_t entities[MAX_REFENTITIES]; 1886 srfPoly_t *polys;//[MAX_POLYS]; 1887 polyVert_t *polyVerts;//[MAX_POLYVERTS]; 1888 renderCommandList_t commands; 1889 } backEndData_t; 1890 1891 extern int max_polys; 1892 extern int max_polyverts; 1893 1894 extern backEndData_t *backEndData; // the second one may not be allocated 1895 1896 void *R_GetCommandBuffer( int bytes ); 1897 void RB_ExecuteRenderCommands( const void *data ); 1898 1899 void R_IssuePendingRenderCommands( void ); 1900 1901 void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); 1902 1903 void RE_SetColor( const float *rgba ); 1904 void RE_StretchPic( float x, float y, float w, float h, 1905 float s1, float t1, float s2, float t2, qhandle_t hShader ); 1906 void RE_StretchPicGradient( float x, float y, float w, float h, 1907 float s1, float t1, float s2, float t2, qhandle_t hShader, const float *gradientColor, int gradientType ); 1908 void RE_BeginFrame( stereoFrame_t stereoFrame ); 1909 void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); 1910 void RE_SaveJPG(char * filename, int quality, int image_width, int image_height, 1911 unsigned char *image_buffer, int padding); 1912 size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, 1913 int image_width, int image_height, byte *image_buffer, int padding); 1914 void RE_TakeVideoFrame( int width, int height, 1915 byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); 1916 1917 void R_DrawElements( int numIndexes, const glIndex_t *indexes ); 1918 void VectorArrayNormalize( vec4_t *normals, unsigned int count ); 1919 void R_BindAnimatedImage( textureBundle_t *bundle ); 1920 1921 #ifdef idppc_altivec 1922 void LerpMeshVertexes_altivec( md3Surface_t *surf, float backlerp ); 1923 void ProjectDlightTexture_altivec( void ); 1924 void RB_CalcDiffuseColor_altivec( unsigned char *colors ); 1925 #endif 1926 1927 // font stuff 1928 void R_InitFreeType( void ); 1929 void R_DoneFreeType( void ); 1930 void RE_RegisterFont( const char *fontName, int pointSize, fontInfo_t *font ); 1931 1932 #ifdef USE_BLOOM 1933 //Bloom Stuff 1934 void R_BloomInit( void ); 1935 void R_BloomScreen( void ); 1936 #endif 1937 1938 //------------------------------------------------------------------------------ 1939 // Ridah, mesh compression 1940 #define NUMMDCVERTEXNORMALS 256 1941 1942 extern float r_anormals[NUMMDCVERTEXNORMALS][3]; 1943 1944 // NOTE: MDC_MAX_ERROR is effectively the compression level. the lower this value, the higher 1945 // the accuracy, but with lower compression ratios. 1946 #define MDC_MAX_ERROR 0.1 // if any compressed vert is off by more than this from the 1947 // actual vert, make this a baseframe 1948 1949 #define MDC_DIST_SCALE 0.05 // lower for more accuracy, but less range 1950 1951 // note: we are locked in at 8 or less bits since changing to byte-encoded normals 1952 #define MDC_BITS_PER_AXIS 8 1953 #define MDC_MAX_OFS 127.0 // to be safe 1954 1955 #define MDC_MAX_DIST ( MDC_MAX_OFS * MDC_DIST_SCALE ) 1956 1957 #if 0 1958 void R_MDC_DecodeXyzCompressed( mdcXyzCompressed_t *xyzComp, vec3_t out, vec3_t normal ); 1959 #else // optimized version 1960 #define R_MDC_DecodeXyzCompressed( ofsVec, out, normal ) \ 1961 ( out )[0] = ( (float)( ( ofsVec ) & 255 ) - MDC_MAX_OFS ) * MDC_DIST_SCALE; \ 1962 ( out )[1] = ( (float)( ( ofsVec >> 8 ) & 255 ) - MDC_MAX_OFS ) * MDC_DIST_SCALE; \ 1963 ( out )[2] = ( (float)( ( ofsVec >> 16 ) & 255 ) - MDC_MAX_OFS ) * MDC_DIST_SCALE; \ 1964 VectorCopy( ( r_anormals )[( ofsVec >> 24 )], normal ); 1965 #endif 1966 1967 void R_AddMDCSurfaces( trRefEntity_t *ent ); 1968 // done. 1969 //------------------------------------------------------------------------------ 1970 1971 void R_LatLongToNormal( vec3_t outNormal, short latLong ); 1972 1973 1974 /* 1975 ============================================================ 1976 1977 GL FOG 1978 1979 ============================================================ 1980 */ 1981 1982 //extern glfog_t glfogCurrent; 1983 extern glfog_t glfogsettings[NUM_FOGS]; // [0] never used (FOG_NONE) 1984 extern glfogType_t glfogNum; // fog type to use (from the fog_t enum list) 1985 1986 extern qboolean fogIsOn; 1987 1988 extern void R_FogOff( void ); 1989 extern void R_FogOn( void ); 1990 1991 extern void R_SetFog( int fogvar, int var1, int var2, float r, float g, float b, float density ); 1992 1993 extern int skyboxportal; 1994 extern int drawskyboxportal; 1995 1996 // Ridah, virtual memory 1997 void *R_Hunk_Begin( void ); 1998 void R_Hunk_End( void ); 1999 2000 #endif //TR_LOCAL_H (THIS MUST BE LAST!!) 2001