Advertisement
Guest User

Fixed veriosn!

a guest
Sep 28th, 2016
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 29.57 KB | None | 0 0
  1. //
  2. // written by BUzer for HL: Paranoia modification
  3. //
  4. //      2006
  5.  
  6. #include "hud.h"
  7. #include "cl_util.h"
  8. #include "const.h"
  9. #include "com_model.h"
  10. #include "gl_manager.h"
  11. #include "gl_texloader.h"
  12.  
  13. #include "studio_util.h"
  14. #include "r_studioint.h"
  15. #include "ref_params.h"
  16. #include "parsemsg.h"
  17.  
  18. #include "r_efx.h"
  19. #include "event_api.h"
  20. #include "pm_defs.h"
  21. #include "pmtrace.h"
  22. #include "gl_renderer.h"
  23. #include "gl_dlight.h" // buz
  24.  
  25.  
  26. extern vec3_t   render_origin;
  27. extern vec3_t   render_angles;
  28.  
  29.  
  30. float   savedMinmaxs[6];
  31. int     renderer_prepared_for_this_frame = 0;
  32. vec3_t  saved_view_orig;
  33. int     newframe = 0;
  34.  
  35. int     reloaded = 1;
  36. int     needkillsky = 0;
  37. int     curvisframe;
  38. int     framecount = 0;
  39. int     no_sky_visible = 0;
  40.  
  41. extern msurface_t *skychain;
  42.  
  43. cvar_t *cv_renderer;
  44. cvar_t *cv_bump;
  45. cvar_t *cv_bumpvecs;
  46. cvar_t *cv_detailtex;
  47. cvar_t *cv_bumpdebug;
  48. cvar_t *cv_specular;
  49. cvar_t *cv_dynamiclight;
  50. cvar_t *cv_entdynamiclight;
  51. cvar_t *cv_specular_nocombiners;
  52. cvar_t *cv_specular_noshaders;
  53. cvar_t *cv_highspecular;
  54. cvar_t *cv_speculartwopass;
  55. cvar_t *cv_dyntwopass;
  56. cvar_t *cv_gamma;
  57. cvar_t *cv_brightness;
  58. cvar_t *cv_contrast;
  59. cvar_t *cv_blurtest;
  60. cvar_t *cv_nsr; // new studio renderer :)
  61. cvar_t *cv_lambert;
  62. cvar_t *cv_drawbrushents;
  63. cvar_t *cv_clipplanes;
  64. cvar_t *cv_showplane;
  65.  
  66. int     norm_cubemap_id = 0;
  67. int     default_normalmap_id = 0;
  68.  
  69. #define MAX_CLRENDER_ENTS   512
  70.  
  71. cl_entity_t *renderents[MAX_CLRENDER_ENTS];
  72. int numrenderents = 0;
  73. cl_entity_t *currententity;
  74. //int maxmsgnum = -1;
  75. //int addedents = 0;
  76.  
  77. /*
  78. #define         MAX_VISEDICTS   256
  79. extern  int             cl_numvisedicts;
  80. extern  entity_t        *cl_visedicts[MAX_VISEDICTS];
  81. */
  82.  
  83. FrustumCheck viewFrustum;
  84.  
  85.  
  86. // surface rendering
  87. void PrepareFirstPass();
  88. void DrawPolyFirstPass(msurface_t *s);
  89. void RenderSecondPass();
  90. void RenderAdditionalBumpPass();
  91. void RenderSpecular();
  92. void ResetCounters();
  93.  
  94. // lightmaps loading
  95. void BumpMarkFaces();
  96. void UpdateLightmaps();
  97. void SetLightmapBaseIndex();
  98.  
  99. // decals
  100. void LoadDecals();
  101. void DrawDecals();
  102. void InitDecals();
  103. void DeleteDecals();
  104. void DecalsShutdown();
  105. void DecalsPrintDebugInfo();
  106.  
  107. // sky
  108. void DrawSky();
  109. void InitSky();
  110. void ResetSky();
  111. void StoreSkyboxEntity(cl_entity_t *ent);
  112.  
  113. // dymanic lighting
  114. void DrawDynamicLights();
  115. void DrawDynamicLightForEntity (cl_entity_t *e);
  116. void ResetDynamicLights();
  117. void MY_DecayLights ();
  118. void CreateAttenuationTextures();
  119.  
  120. // debug
  121. void DrawTextureVecs();
  122. void DumpTextures();
  123. void DumpLevel();
  124. void DumpLeafInfo();
  125. void PrintOtherDebugInfo();
  126. void PrintBumpDebugInfo();
  127. void DrawDebugFrustumPlane();
  128.  
  129. // vertex arrays
  130. void GenerateVertexArray();
  131. void FreeBuffer();
  132. void EnableVertexArray();
  133. void DisableVertexArray();
  134.  
  135. extern int numskyents;
  136.  
  137.  
  138. // When rendering world, we must prevent engine from drawing world model,
  139. // but allow him to draw models, sprites, beams, and other entities.
  140. //
  141. // Idea is to put node[0] bbox behind player's back, so engine will think that is invisible.
  142. // After rendering, node[0] bbox must be restored by calling RestoreWorldDrawing
  143. //
  144. // Good thing that engine will precalculate PVS visibility info for us
  145.  
  146. void DisableWorldDrawing( ref_params_t *pparams )
  147. {
  148.     vec3_t wcoord;
  149.     model_t* world = gEngfuncs.GetEntityByIndex(0)->model;
  150.     AngleVectors ( pparams->viewangles, pparams->forward, pparams->right, pparams->up );
  151.     VectorMA(pparams->vieworg, -100, pparams->forward, wcoord);
  152.     memcpy(savedMinmaxs, world->nodes[0].minmaxs, 6 * sizeof(float));
  153.     VectorCopy(wcoord, world->nodes[0].minmaxs);
  154.     VectorCopy(wcoord, world->nodes[0].minmaxs + 3);
  155. }
  156.  
  157. void RestoreWorldDrawing()
  158. {
  159.     model_t* world = gEngfuncs.GetEntityByIndex(0)->model;
  160.     memcpy(world->nodes[0].minmaxs, savedMinmaxs, 6 * sizeof(float));
  161. }
  162.  
  163.  
  164. //===================================
  165. // CreateNormalizationCubemap
  166. //
  167. //      thanks steps3d.narod.ru
  168. //===================================
  169. #define NORM_CUBE_SIZE  (32)
  170.  
  171. void getCubeVector ( int side, int x, int y, vec3_t &v )
  172. {
  173.     float s  = ((float) x + 0.5f) / (float) NORM_CUBE_SIZE;
  174.     float t  = ((float) y + 0.5f) / (float) NORM_CUBE_SIZE;
  175.     float sc = 2*s - 1;
  176.     float tc = 2*t - 1;
  177.  
  178.     switch ( side )
  179.     {
  180.         case 0:
  181.             v[0] = 1; v[1] = -tc; v[2] = -sc;
  182.             break;
  183.  
  184.         case 1:
  185.             v[0] = -1; v[1] = -tc; v[2] = sc;
  186.             break;
  187.  
  188.         case 2:
  189.             v[0] = sc; v[1] = 1; v[2] = tc;
  190.             break;
  191.  
  192.         case 3:
  193.             v[0] = sc; v[1] = -1; v[2] = -tc;
  194.             break;
  195.  
  196.         case 4:
  197.             v[0] = sc; v[1] = -tc; v[2] = 1;
  198.             break;
  199.  
  200.         case 5:
  201.             v[0] = -sc; v[1] = -tc; v[2] = -1;
  202.             break;
  203.     }
  204.     VectorNormalize(v);
  205. }
  206.  
  207. int CreateNormalizationCubemap()
  208. {
  209.     vec3_t v;
  210.     byte pixels[NORM_CUBE_SIZE * NORM_CUBE_SIZE * 3];
  211.  
  212.     gl.glEnable        ( GL_TEXTURE_CUBE_MAP_ARB );
  213.     gl.glBindTexture   ( GL_TEXTURE_CUBE_MAP_ARB, current_ext_texture_id );
  214.     gl.glPixelStorei   ( GL_UNPACK_ALIGNMENT, 1 );
  215.     gl.glTexParameteri ( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
  216.     gl.glTexParameteri ( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
  217.  
  218.     for ( int side = 0; side < 6; side++ )
  219.     {
  220.         for ( int x = 0; x < NORM_CUBE_SIZE; x++ )
  221.             for ( int y = 0; y < NORM_CUBE_SIZE; y++ )
  222.             {
  223.                 int offs = 3 * (y * NORM_CUBE_SIZE + x);
  224.  
  225.                 getCubeVector ( side, x, y, v );
  226.  
  227.                 pixels [offs    ] = 128 + 127 * v[0];
  228.                 pixels [offs + 1] = 128 + 127 * v[1];
  229.                 pixels [offs + 2] = 128 + 127 * v[2];
  230.             //  gEngfuncs.Con_Printf("%d, %d, %d\n", pixels[0], pixels[1], pixels[2]);
  231.             }
  232.  
  233.          gl.glTexImage2D ( GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + side, 0, GL_RGB,
  234.                     NORM_CUBE_SIZE, NORM_CUBE_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
  235.     }
  236.  
  237.     Log("Created normalization cubemap\n");
  238.     gl.glTexParameteri ( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
  239.     gl.glTexParameteri ( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
  240.     gl.glDisable ( GL_TEXTURE_CUBE_MAP_ARB );
  241.  
  242.     current_ext_texture_id++;
  243.     return (current_ext_texture_id - 1);
  244. }
  245.  
  246. //===================================
  247. // CreateDefaultNormalMap
  248. //
  249. // generates default normalmap texture
  250. //===================================
  251. int CreateDefaultNormalMap ()
  252. {
  253.     color24 buf[16*16];
  254.  
  255.     for (int i = 0; i < 256; i++)
  256.     {
  257.         buf[i].r = 127;
  258.         buf[i].g = 127;
  259.         buf[i].b = 255;
  260.     }
  261.  
  262.     // upload image
  263.     gl.glBindTexture(GL_TEXTURE_2D, current_ext_texture_id);
  264.     gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  265.     gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  266.     gl.glTexImage2D (GL_TEXTURE_2D, 0, 3, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, buf);
  267.  
  268.     Log("Created default normal map\n");
  269.     current_ext_texture_id++;
  270.     return (current_ext_texture_id - 1);
  271. }
  272.  
  273.  
  274. void ResetRenderState()
  275. {
  276.     for (int i = 0; i < gl.MAX_TU_supported; i++)
  277.     {
  278.         gl.glActiveTextureARB( GL_TEXTURE0_ARB + i );
  279.         gl.glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);
  280.         gl.glDisable(GL_TEXTURE_2D);
  281.     }
  282.  
  283.     gl.glActiveTextureARB( GL_TEXTURE0_ARB );
  284.     gl.glEnable(GL_TEXTURE_2D);
  285.  
  286.     gl.glDisable(GL_BLEND);
  287.     gl.glDepthMask(GL_TRUE);
  288. }
  289.  
  290.  
  291.  
  292.  
  293. /*
  294. =================
  295. R_DrawBrushModel
  296. =================
  297. */
  298. vec3_t vec_to_eyes;
  299.  
  300. void R_RotateForEntity (cl_entity_t *e)
  301. {
  302.     gl.glTranslatef (e->origin[0],  e->origin[1],  e->origin[2]);
  303.  
  304.     gl.glRotatef (e->angles[1],  0, 0, 1);
  305.     gl.glRotatef (-e->angles[0],  0, 1, 0);
  306.     gl.glRotatef (e->angles[2],  1, 0, 0);
  307. }
  308.  
  309. int IsEntityMoved(cl_entity_t *e)
  310. {
  311.     if (e->angles[0] || e->angles[1] || e->angles[2] ||
  312.         e->origin[0] || e->origin[1] || e->origin[2] ||
  313.         e->curstate.renderfx == 70) // skybox models reques separate pass
  314.         return TRUE;
  315.     else
  316.         return FALSE;
  317. }
  318.  
  319. int IsEntityTransparent(cl_entity_t *e)
  320. {
  321.     if (e->curstate.rendermode == kRenderNormal ||
  322.         e->curstate.rendermode == kRenderTransAlpha)
  323.         return FALSE;
  324.     else
  325.         return TRUE;
  326. }
  327.  
  328.  
  329. void R_DrawBrushModel (cl_entity_t *e, int onlyfirstpass)
  330. {
  331. //  int         j, k;
  332.     vec3_t      mins, maxs;
  333.     int         i;//, numsurfaces;
  334.     msurface_t  *psurf;
  335.     float       dot;
  336.     mplane_t    *pplane;
  337.     model_t     *clmodel;
  338.     int         rotated;
  339.     vec3_t      trans;
  340.  
  341.     currententity = e;
  342.     clmodel = e->model;
  343.  
  344.     if (e->angles[0] || e->angles[1] || e->angles[2])
  345.     {
  346.         rotated = true;
  347.         for (i=0 ; i<3 ; i++)
  348.         {
  349.             mins[i] = e->origin[i] - clmodel->radius;
  350.             maxs[i] = e->origin[i] + clmodel->radius;
  351.         }
  352.     }
  353.     else
  354.     {
  355.         rotated = false;
  356.         VectorAdd (e->origin, clmodel->mins, mins);
  357.         VectorAdd (e->origin, clmodel->maxs, maxs);
  358.     }
  359.  
  360.     if (e->curstate.renderfx == 70) // skybox entity
  361.     {
  362.         // Fix?
  363.  
  364.         /*
  365.  
  366.         if (!gl.Paranoia_hacks)
  367.             return;
  368.  
  369.         trans = render_origin - sky_origin;
  370.         if (sky_speed)
  371.         {
  372.             trans = trans - (render_origin - sky_world_origin) / sky_speed;
  373.             vec3_t skypos = sky_origin + (render_origin - sky_world_origin) / sky_speed;
  374.             VectorSubtract (skypos, e->origin, vec_to_eyes);
  375.         }
  376.         else
  377.             VectorSubtract (sky_origin, e->origin, vec_to_eyes);
  378.  
  379.         */
  380.  
  381.         gl.glTranslatef(trans[0], trans[1], trans[2]);
  382.         gl.glDepthRange (0.8, 0.9);    
  383.     }
  384.     else
  385.     {
  386.         if (viewFrustum.R_CullBox (mins, maxs))
  387.             return;
  388.  
  389.         VectorSubtract (saved_view_orig, e->origin, vec_to_eyes);
  390.     }
  391.  
  392.     if (rotated)
  393.     {
  394.         vec3_t  temp;
  395.         vec3_t  forward, right, up;
  396.  
  397.         VectorCopy (vec_to_eyes, temp);
  398.         AngleVectors (e->angles, forward, right, up);
  399.         vec_to_eyes[0] = DotProduct (temp, forward);
  400.         vec_to_eyes[1] = -DotProduct (temp, right);
  401.         vec_to_eyes[2] = DotProduct (temp, up);
  402.     }
  403.  
  404.     psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
  405.  
  406.     gl.glPushMatrix ();
  407. e->angles[0] = -e->angles[0];   // stupid quake bug
  408.     R_RotateForEntity (e);
  409. e->angles[0] = -e->angles[0];   // stupid quake bug
  410.  
  411.     //
  412.     // draw polys
  413.     //
  414.  
  415.     if (!onlyfirstpass)
  416.         PrepareFirstPass();
  417.  
  418.     if (e->curstate.rendermode == kRenderTransAlpha)
  419.     {
  420.         gl.glEnable(GL_ALPHA_TEST);
  421.         gl.glAlphaFunc(GL_GREATER, 0.25);
  422.     }
  423.     else if (e->curstate.rendermode == kRenderTransTexture)
  424.     {
  425.         gl.glDepthMask(GL_FALSE);
  426.         gl.glEnable(GL_BLEND);
  427.         gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  428.         gl.glColor4ub(255, 255, 255, e->curstate.renderamt);
  429.     }
  430.     else if (e->curstate.rendermode == kRenderTransAdd)
  431.     {
  432.         gl.glDepthMask(GL_FALSE);
  433.         gl.glEnable(GL_BLEND);
  434.         gl.glBlendFunc(GL_ONE, GL_ONE);
  435.         gl.glColor4ub(255, 255, 255, e->curstate.renderamt);
  436.     }  
  437.  
  438.     for (i=0 ; i<clmodel->nummodelsurfaces ; i++, psurf++)
  439.     {
  440.         pplane = psurf->plane;
  441.         dot = DotProduct (vec_to_eyes, pplane->normal) - pplane->dist;
  442.  
  443.         if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
  444.             (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
  445.         {
  446.             psurf->visframe = framecount;
  447.             DrawPolyFirstPass(psurf);
  448.         }
  449.     }
  450.  
  451.     if (e->curstate.rendermode == kRenderTransAlpha)
  452.     {
  453.         gl.glDisable(GL_ALPHA_TEST);
  454.     }
  455.     else if (e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd)
  456.     {
  457.         gl.glDepthMask(GL_TRUE);
  458.         gl.glDisable(GL_BLEND);
  459.     }
  460.  
  461.     if (!onlyfirstpass)
  462.     {
  463.         RenderAdditionalBumpPass();
  464.         if (e->curstate.renderfx != 70 && cv_dynamiclight->value && cv_entdynamiclight->value)
  465.             DrawDynamicLightForEntity(e);
  466.         RenderSecondPass();
  467.         RenderSpecular();
  468.     }
  469.  
  470.     gl.glPopMatrix ();
  471.  
  472.     if (e->curstate.renderfx == 70)
  473.     {
  474.         gl.glTranslatef(-trans[0], -trans[1], -trans[2]);
  475.         gl.glDepthRange (0, 0.8);
  476.     }
  477. }
  478.  
  479.  
  480. /*
  481. =================
  482.  World drawing
  483. =================
  484. */
  485. void RecursiveDrawWorld (mnode_t *node)
  486. {
  487.     int         c, side;
  488.     mplane_t    *plane;
  489.     msurface_t  *surf, **mark;
  490.     mleaf_t     *pleaf;
  491.     double      dot;
  492.  
  493.     if (node->contents == CONTENTS_SOLID)
  494.         return;     // solid
  495.  
  496.     if (node->visframe != curvisframe)
  497.         return;
  498.  
  499.     if (viewFrustum.R_CullBox (node->minmaxs, node->minmaxs+3))
  500.         return;
  501.    
  502. // if a leaf node, draw stuff
  503.     if (node->contents < 0)
  504.     {
  505.         pleaf = (mleaf_t *)node;
  506.         mark = pleaf->firstmarksurface;
  507.         c = pleaf->nummarksurfaces;
  508.  
  509.         if (c)
  510.         {
  511.             do
  512.             {
  513.                 (*mark)->visframe = framecount;
  514.                 mark++;
  515.             } while (--c);
  516.         }
  517.         return;
  518.     }
  519.  
  520. // node is just a decision point, so go down the apropriate sides
  521. // find which side of the node we are on
  522.     plane = node->plane;
  523.     switch (plane->type)
  524.     {
  525.     case PLANE_X:
  526.         dot = saved_view_orig[0] - plane->dist; break;
  527.     case PLANE_Y:
  528.         dot = saved_view_orig[1] - plane->dist; break;
  529.     case PLANE_Z:
  530.         dot = saved_view_orig[2] - plane->dist; break;
  531.     default:
  532.         dot = DotProduct (saved_view_orig, plane->normal) - plane->dist; break;
  533.     }
  534.  
  535.     if (dot >= 0) side = 0;
  536.     else side = 1;
  537.  
  538. // recurse down the children, front side first
  539.     RecursiveDrawWorld (node->children[side]);
  540.  
  541. // draw stuff
  542.     c = node->numsurfaces;
  543.     if (c)
  544.     {
  545.         model_t *world = gEngfuncs.GetEntityByIndex(0)->model;
  546.         surf = world->surfaces + node->firstsurface;
  547.  
  548.         if (dot < 0 -BACKFACE_EPSILON)
  549.             side = SURF_PLANEBACK;
  550.         else if (dot > BACKFACE_EPSILON)
  551.             side = 0;
  552.         {
  553.             for ( ; c ; c--, surf++)
  554.             {
  555.                 if (surf->visframe != framecount)
  556.                     continue;
  557.  
  558.                 // don't backface underwater surfaces, because they warp
  559.                 if ( !(surf->flags & SURF_UNDERWATER) && ( (dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) )
  560.                     continue;       // wrong side
  561.  
  562.                 DrawPolyFirstPass(surf);
  563.             }
  564.         }
  565.     }
  566.  
  567. // recurse down the back side
  568.     RecursiveDrawWorld (node->children[!side]);
  569. }
  570.  
  571. //=========================
  572. // PrepareRenderer
  573. //
  574. // sets frustum, disables world drawing, makes shure that everything is okay
  575. //=========================
  576. void PrepareRenderer( ref_params_t *pparams )
  577. {
  578.     ResetCounters();
  579.  
  580.     if (!cv_renderer->value)
  581.         return;
  582.  
  583.     if (!gl.IsGLAllowed())
  584.     {
  585.         gEngfuncs.Cvar_SetValue( "gl_renderer", 0 );
  586.         return;
  587.     }
  588.  
  589.     if (!gl.Paranoia_hacks)
  590.     {
  591.         ConLog("No paranoia hacked opengl32.dll, custom renderer disabled\n");
  592.         gEngfuncs.Cvar_SetValue( "gl_renderer", 0 );
  593.         return;
  594.     }
  595.  
  596.     if (!gEngfuncs.GetEntityByIndex(0)->model->lightdata)
  597.     {
  598.         ConLog("No lightdata, custom renderer disabled\n");
  599.         gEngfuncs.Cvar_SetValue( "gl_renderer", 0 );
  600.         return;
  601.     }
  602.  
  603.     if (!gl.ARB_multitexture_supported || !gl.ARB_dot3_supported ||
  604.         !gl.ARB_texture_cube_map_supported || gl.MAX_TU_supported < 2)
  605.     {
  606.         ConLog("Paranoia custom renderer is not supported by your videocard\n");
  607.         gEngfuncs.Cvar_SetValue( "gl_renderer", 0 );
  608.         return;
  609.     }
  610.  
  611.     if (pparams->onlyClientDraw)
  612.         return;
  613.  
  614.     /*
  615.  
  616.     if (!gl.stencilbits)
  617.     {
  618.         ConLog("Warning: no stencilbits!\n");
  619.         gEngfuncs.Cvar_SetValue( "gl_clipplanes", 1 ); // it's impossible, but who knows?
  620.     }  
  621.  
  622.     */
  623.  
  624.     if (reloaded)
  625.     {
  626.         CreateExtDataForTextures();
  627.         BumpMarkFaces();
  628.         GenerateVertexArray();
  629.         reloaded = 0;
  630.     }
  631.  
  632.     UpdateLightmaps();
  633.  
  634.     if (!norm_cubemap_id)
  635.         norm_cubemap_id = CreateNormalizationCubemap();
  636.  
  637.     if (!default_normalmap_id)
  638.         default_normalmap_id = CreateDefaultNormalMap();
  639.  
  640.     CreateAttenuationTextures();
  641.        
  642.     VectorCopy (pparams->vieworg, saved_view_orig);
  643.     viewFrustum.R_SetFrustum (pparams->viewangles, pparams->vieworg, pparams->viewsize);
  644.  
  645.     // i'd like to draw world here, but engine will erase
  646.     // depth buffer after CalcRefDef returns :(
  647.  
  648.     DisableWorldDrawing( pparams );
  649.     renderer_prepared_for_this_frame = 1;
  650.    
  651.     if( CVAR_GET_FLOAT( "r_drawsky" ) != 0 ) // Fix?
  652.     {
  653.         RestoreWorldDrawing( );
  654.         renderer_prepared_for_this_frame = 1;
  655.     }
  656. }
  657.  
  658. //=========================
  659. // DrawBump
  660. //
  661. //=========================
  662. void DrawBump()
  663. {
  664.     int k;
  665.  
  666.     if (!renderer_prepared_for_this_frame)
  667.         return;
  668.  
  669.     RestoreWorldDrawing();
  670.     renderer_prepared_for_this_frame = 0;
  671.  
  672.     // Current visframe number can be taken from leaf, where our eyes in.
  673.     // obvious, eh?
  674.     model_t *world = gEngfuncs.GetEntityByIndex(0)->model;
  675.     mleaf_t *leaf = Mod_PointInLeaf ( saved_view_orig, world );
  676.     curvisframe = leaf->visframe;
  677.    
  678.     EnableVertexArray();
  679.  
  680.     // Draw world
  681.     VectorCopy(saved_view_orig, vec_to_eyes);
  682.     currententity = gEngfuncs.GetEntityByIndex(0);
  683.  
  684.     PrepareFirstPass();
  685.     RecursiveDrawWorld (world->nodes);
  686.  
  687. //  CONPRINT("static start\n");
  688.  
  689.     // Draw non-moved brush entities
  690.     for (k = 0; k < numrenderents; k++)
  691.     {
  692.         if (!IsEntityMoved(renderents[k])/* && !IsEntityTransparent(renderents[k])*/)
  693.             R_DrawBrushModel (renderents[k], TRUE);
  694.     }
  695.  
  696.     RenderAdditionalBumpPass();
  697.  
  698.     if (cv_dynamiclight->value)
  699.         DrawDynamicLights();
  700.  
  701.     RenderSecondPass();
  702.     RenderSpecular();
  703.  
  704. //  CONPRINT("static end\n");
  705.  
  706.     if (!skychain)
  707.         no_sky_visible = TRUE;
  708.  
  709.     // Draw brush entities
  710.     for (k = 0; k < numrenderents; k++)
  711.     {
  712.         if (IsEntityMoved(renderents[k])/* && !IsEntityTransparent(renderents[k])*/)
  713.             R_DrawBrushModel (renderents[k], FALSE);
  714.     }
  715.  
  716.     gl.glDepthFunc(GL_LEQUAL);
  717.  
  718.     DisableVertexArray();
  719.     DrawDecals();
  720.  
  721. /*  // Draw transparent brush entities
  722.     EnableVertexArray();
  723.     for (k = 0; k < numrenderents; k++)
  724.     {
  725.         if (IsEntityTransparent(renderents[k]))
  726.             R_DrawBrushModel (renderents[k], FALSE);
  727.     }
  728.  
  729.     DisableVertexArray();*/
  730.     ResetRenderState();
  731.  
  732.     // clear texture chains
  733.     texture_t** tex = (texture_t**)world->textures;
  734.     for (int i = 0; i < world->numtextures; i++)
  735.         tex[i]->texturechain = NULL;
  736.  
  737.     // reset surfaces visframe number to default
  738. /*  msurface_t* surfaces = world->surfaces;
  739.     for (i = 0; i < world->numsurfaces; i++)
  740.         surfaces[i].visframe = 1;
  741.  
  742.     // on brush entities too
  743.     // (uhh.. isn't it just a pointers to surfs in world->surfaces array?)
  744.     for (k = 0; k < numrenderents; k++)
  745.     {
  746.         model_t *clmodel = renderents[k]->model;
  747.         msurface_t *psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
  748.         for (i=0 ; i<clmodel->nummodelsurfaces ; i++, psurf++)
  749.             psurf->visframe = 1;
  750.     }*/
  751.  
  752. //  if (numrenderents == 0)
  753. //      CONPRINT("%d brush ents drawn\n", numrenderents);
  754. }
  755.  
  756.  
  757. int MsgCustomDlight(const char *pszName, int iSize, void *pbuf)
  758. {
  759.     BEGIN_READ( pbuf, iSize );
  760.  
  761.     vec3_t pos;
  762.     pos.x = READ_COORD();
  763.     pos.y = READ_COORD();
  764.     pos.z = READ_COORD();
  765.     float radius = (float)READ_BYTE() * 10;
  766.     float life = (float)READ_BYTE() / 10;
  767.     float decay = (float)READ_BYTE() * 10;
  768.  
  769.     DynamicLight *dl = MY_AllocDlight (0);
  770.     dl->origin.x = pos.x;
  771.     dl->origin.y = pos.y;
  772.     dl->origin.z = pos.z;
  773.     dl->radius = radius;
  774.     dl->die = gEngfuncs.GetClientTime() + life;
  775.     dl->decay = decay;
  776.     dl->color = Vector(0.7f, 0.6f, 0.5f);
  777.  
  778.     return 1;
  779. }
  780.  
  781.  
  782. // prevent engine from drawing sky in gl mode
  783. void KillSky()
  784. {
  785.     Log("Killing sky faces\n");
  786.     model_t *world = gEngfuncs.GetEntityByIndex(0)->model;
  787.     msurface_t* surfaces = world->surfaces;
  788.     for (int i = 0; i < world->numsurfaces; i++)
  789.     {
  790.         if (surfaces[i].flags & SURF_DRAWSKY)
  791.         {
  792.             glpoly_t *p = surfaces[i].polys;
  793.             p->numverts = -p->numverts;
  794.         }
  795.     }
  796. }
  797.  
  798.  
  799. // debug command
  800. // usage: makelight [R G B] [radius] [life]\n" );
  801. void MakeLight()
  802. {
  803.     DynamicLight *dl = MY_AllocDlight (0);
  804.     dl->origin.x = render_origin[0];
  805.     dl->origin.y = render_origin[1];
  806.     dl->origin.z = render_origin[2];
  807.    
  808.     if (gEngfuncs.Cmd_Argc() >= 4)
  809.     {
  810.         dl->color[0] = atof(gEngfuncs.Cmd_Argv(1));
  811.         dl->color[1] = atof(gEngfuncs.Cmd_Argv(2));
  812.         dl->color[2] = atof(gEngfuncs.Cmd_Argv(3));
  813.     }
  814.     else
  815.     {
  816.         dl->color = Vector(0.7f, 0.6f, 0.5f);
  817.     }
  818.  
  819.     if (gEngfuncs.Cmd_Argc() >= 5)
  820.         dl->radius = atof(gEngfuncs.Cmd_Argv(4));
  821.     else
  822.         dl->radius = 128;
  823.  
  824.     if (gEngfuncs.Cmd_Argc() >= 6)
  825.         dl->die = gEngfuncs.GetClientTime() + atof(gEngfuncs.Cmd_Argv(5));
  826.     else
  827.         dl->die = gEngfuncs.GetClientTime() + 2;
  828. }
  829.  
  830.  
  831. // ======================
  832. // GL_MtexStateSaver class
  833. //
  834. // manages storing and restoring some opengl parameters
  835. // so our renderer will not affect engine's drawing
  836. // ======================
  837. class GL_MtexStateSaver
  838. {
  839. public:
  840.     GL_MtexStateSaver()
  841.     {
  842.         if (gl.IsGLAllowed() && gl.ARB_multitexture_supported)
  843.         {
  844.             gl.glPushAttrib(GL_ALL_ATTRIB_BITS);
  845.  
  846.             do_this = TRUE;
  847.             gl.glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTU);
  848.             gl.glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE_ARB, &clactiveTU);
  849.         //  CONPRINT("active: %d\n", activeTU);
  850.  
  851.             if (gl.glIsEnabled(GL_BLEND)) blendactive = TRUE;
  852.             else blendactive = FALSE;
  853.  
  854.             gl.glActiveTextureARB( GL_TEXTURE0_ARB );
  855.             if (gl.glIsEnabled(GL_TEXTURE_2D)) TU1tex2dEnable = TRUE;
  856.             else TU1tex2dEnable = FALSE;
  857.             gl.glGetIntegerv(GL_TEXTURE_BINDING_2D, &TU1bind);
  858.             gl.glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &TU1BlendMode);
  859.  
  860.             gl.glActiveTextureARB( GL_TEXTURE1_ARB );
  861.             if (gl.glIsEnabled(GL_TEXTURE_2D)) TU2tex2dEnable = TRUE;
  862.             else TU2tex2dEnable = FALSE;
  863.             gl.glGetIntegerv(GL_TEXTURE_BINDING_2D, &TU2bind);
  864.             gl.glDisable(GL_TEXTURE_2D); // disable texturing at 2nd TU
  865.  
  866.             if (gl.MAX_TU_supported > 2)
  867.             {
  868.                 gl.glActiveTextureARB( GL_TEXTURE2_ARB );
  869.                 if (gl.glIsEnabled(GL_TEXTURE_2D)) TU3tex2dEnable = TRUE;
  870.                 else TU3tex2dEnable = FALSE;
  871.                 gl.glGetIntegerv(GL_TEXTURE_BINDING_2D, &TU3bind);
  872.                 gl.glDisable(GL_TEXTURE_2D); // disable texturing at 3rd TU
  873.             //  CONPRINT("tex3 enabled: %d, bind %d\n", TU3tex2dEnable, TU3bind);
  874.  
  875.                 // steam version sets texture matrix for detail textures, we must save it
  876.                 gl.glMatrixMode(GL_TEXTURE);
  877.                 gl.glPushMatrix();
  878.                 gl.glLoadIdentity();
  879.                 gl.glMatrixMode(GL_MODELVIEW);
  880.  
  881.                 if (gl.MAX_TU_supported > 3)
  882.                 {
  883.                     gl.glActiveTextureARB( GL_TEXTURE3_ARB );
  884.                     if (gl.glIsEnabled(GL_TEXTURE_2D)) TU4tex2dEnable = TRUE;
  885.                     else TU4tex2dEnable = FALSE;
  886.                     gl.glGetIntegerv(GL_TEXTURE_BINDING_2D, &TU4bind);
  887.                     gl.glDisable(GL_TEXTURE_2D); // disable texturing at 4th TU
  888.                 //  CONPRINT("tex4 enabled: %d, bind %d\n", TU4tex2dEnable, TU4bind);
  889.                 }
  890.             }
  891.  
  892.             gl.glActiveTextureARB( GL_TEXTURE0_ARB );
  893.  
  894.             gl.glGetIntegerv(GL_ALPHA_TEST_FUNC, &alphafunc);
  895.             gl.glGetFloatv(GL_ALPHA_TEST_REF, &alphaval);
  896.             if (gl.glIsEnabled(GL_ALPHA_TEST)) alphatestenabled = TRUE;
  897.             else alphatestenabled = FALSE;
  898.         }
  899.         else
  900.             do_this = FALSE;       
  901.     }
  902.  
  903.     ~GL_MtexStateSaver()
  904.     {
  905.         if (do_this)
  906.         {
  907.             gl.glPopAttrib();
  908.  
  909.             gl.glActiveTextureARB( GL_TEXTURE0_ARB );
  910.             if (TU1tex2dEnable) gl.glEnable(GL_TEXTURE_2D);
  911.             else gl.glDisable(GL_TEXTURE_2D);
  912.             gl.glBindTexture(GL_TEXTURE_2D, TU1bind);
  913.             gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, TU1BlendMode);
  914.  
  915.             gl.glActiveTextureARB( GL_TEXTURE1_ARB );
  916.             if (TU2tex2dEnable) gl.glEnable(GL_TEXTURE_2D);
  917.             else gl.glDisable(GL_TEXTURE_2D);
  918.             gl.glBindTexture(GL_TEXTURE_2D, TU2bind);
  919.  
  920.             if (gl.MAX_TU_supported > 2)
  921.             {
  922.                 gl.glActiveTextureARB( GL_TEXTURE2_ARB );
  923.                 if (TU3tex2dEnable) gl.glEnable(GL_TEXTURE_2D);
  924.                 else gl.glDisable(GL_TEXTURE_2D);
  925.                 gl.glBindTexture(GL_TEXTURE_2D, TU3bind);
  926.  
  927.                 // this must be set for steam version, so it will render detail textures correctly
  928.                 if (gl.ARB_dot3_supported)
  929.                 {
  930.                     gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
  931.                     gl.glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
  932.                     gl.glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
  933.                     gl.glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
  934.                     gl.glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
  935.                 }
  936.  
  937.                 // load saved matrix for steam version
  938.                 gl.glMatrixMode(GL_TEXTURE);
  939.                 gl.glPopMatrix();
  940.                 gl.glMatrixMode(GL_MODELVIEW);
  941.  
  942.                 if (gl.MAX_TU_supported > 3)
  943.                 {
  944.                     gl.glActiveTextureARB( GL_TEXTURE3_ARB );
  945.                     if (TU4tex2dEnable) gl.glEnable(GL_TEXTURE_2D);
  946.                     else gl.glDisable(GL_TEXTURE_2D);
  947.                     gl.glBindTexture(GL_TEXTURE_2D, TU4bind);
  948.                 }
  949.             }
  950.  
  951.             gl.glActiveTextureARB( activeTU );
  952.             gl.glClientActiveTextureARB( clactiveTU );
  953.  
  954.             if (blendactive) gl.glEnable(GL_BLEND);
  955.             else gl.glDisable(GL_BLEND);
  956.  
  957.             if (alphatestenabled) gl.glEnable(GL_ALPHA_TEST);
  958.             else gl.glDisable(GL_ALPHA_TEST);
  959.  
  960.             gl.glAlphaFunc(alphafunc, alphaval);
  961.         }
  962.     }
  963.  
  964. private:
  965.     int do_this;
  966.     GLint blendactive;
  967.     GLint TU1bind;
  968.     GLint TU2bind;
  969.     GLint TU3bind;
  970.     GLint TU4bind;
  971.     GLint TU1tex2dEnable;
  972.     GLint TU2tex2dEnable;
  973.     GLint TU3tex2dEnable;
  974.     GLint TU4tex2dEnable;
  975.     GLint activeTU;
  976.     GLint clactiveTU;
  977.     GLint TU1BlendMode;
  978.  
  979.     GLint alphafunc;
  980.     GLclampf alphaval;
  981.     GLint alphatestenabled;
  982. };
  983.  
  984.  
  985. //===============================
  986. // LINK TO WORLD
  987. //===============================
  988.  
  989.  
  990. void RendererCreateEntities()
  991. {
  992.     // ztrick is not allowed
  993.     float ztrick = CVAR_GET_FLOAT( "gl_ztrick" );
  994.     if (ztrick)
  995.     {
  996.         ConLog("gl_ztrick 1 is not allowed\n");
  997.         gEngfuncs.Cvar_SetValue( "gl_ztrick", 0 );
  998.     }
  999.  
  1000.     if (needkillsky)
  1001.     {
  1002.         // Fix?
  1003.         // KillSky();
  1004.         needkillsky = 0;
  1005.     }
  1006. }
  1007.  
  1008.  
  1009. void RendererTentsUpdate()
  1010. {
  1011. //  if (!addedents) numrenderents = 0;
  1012. //  else addedents = 0;
  1013. }
  1014.  
  1015.  
  1016. void RendererUpdateEntityList()
  1017. {
  1018.     numrenderents = 0;
  1019.  
  1020.     if (!cv_renderer->value || !cv_drawbrushents->value)
  1021.         return;
  1022.  
  1023.     cl_entity_t *localPlayer = gEngfuncs.GetLocalPlayer();
  1024.     if (!localPlayer)
  1025.     {
  1026.         gEngfuncs.Con_Printf("ERROR: UpdateEntityList - cant get local player!\n");
  1027.         return;
  1028.     }
  1029.  
  1030.     cl_entity_t *viewent = gEngfuncs.GetViewModel();
  1031.  
  1032.     int curmsgnum = localPlayer->curstate.messagenum;
  1033.    
  1034.     for (int ic=1; ic<MAX_EDICTS; ic++)
  1035.     {
  1036.         cl_entity_t *ent = gEngfuncs.GetEntityByIndex( ic );
  1037.         if (!ent)
  1038.             break;
  1039.  
  1040.         if (!ent->model)
  1041.             continue;
  1042.  
  1043.         if (ent->curstate.messagenum != curmsgnum)
  1044.             continue;
  1045.  
  1046.         if (ent->curstate.effects & EF_NODRAW)
  1047.             continue;
  1048.  
  1049.         if (ent == viewent)
  1050.             continue;
  1051.  
  1052.         if (ent->model->type == mod_brush && numrenderents < MAX_CLRENDER_ENTS)
  1053.         {
  1054.             if (!IsEntityTransparent(ent))
  1055.             {
  1056.                 renderents[numrenderents] = ent;
  1057.                 numrenderents++;
  1058.             }
  1059.         }
  1060.     }
  1061. //  CONPRINT("%d ents added\n", numrenderents);
  1062. }
  1063.  
  1064.  
  1065. int RendererFilterEntities( int type, struct cl_entity_s *ent, const char *modelname )
  1066. {
  1067.     if (ent->curstate.renderfx == 71) // dynamic light
  1068.     {
  1069.         DynamicLight *dl = MY_AllocDlight(ent->index);
  1070.         dl->origin = ent->curstate.origin;
  1071.         dl->angles = ent->curstate.angles;
  1072.         dl->radius = ent->curstate.renderamt * 8;
  1073.         dl->color[0] = (float)ent->curstate.rendercolor.r / 128;
  1074.         dl->color[1] = (float)ent->curstate.rendercolor.g / 128;
  1075.         dl->color[2] = (float)ent->curstate.rendercolor.b / 128;
  1076.         if (ent->curstate.scale) // spotlight
  1077.         {
  1078.             dl->cone_hor = ent->curstate.scale;
  1079.             dl->cone_ver = ent->curstate.scale;
  1080.             sprintf(dl->spot_texture, "materials/renderer/spotlight%d.tga", ent->curstate.rendermode);
  1081.         }      
  1082.         dl->die = gEngfuncs.GetClientTime() + 0.01;
  1083.         return 0;
  1084.     }
  1085.  
  1086.     if (ent->curstate.renderfx == 70 && ent->model->type == mod_sprite)
  1087.     {
  1088.         // Fix?
  1089.         // StoreSkyboxEntity(ent);
  1090.         return 0;
  1091.     }
  1092.  
  1093.     if (cv_renderer->value && cv_drawbrushents->value)
  1094.     {
  1095.         if (ent->model->type == mod_brush)
  1096.         {
  1097.             if (!IsEntityTransparent(ent))
  1098.             {
  1099.                 // tell engine dont draw non-transparent brush ents
  1100.                 return 0;
  1101.             }
  1102.         }
  1103.     }
  1104.  
  1105.     return 1;
  1106. }
  1107.  
  1108.  
  1109. void RendererCalcRefDef( ref_params_t *pparams )
  1110. {
  1111. //  CONPRINT("calcrefdef\n");
  1112.     no_sky_visible = 0;
  1113.     newframe = 1;
  1114.     framecount++;
  1115.     PrepareRenderer( pparams );
  1116. }
  1117.  
  1118.  
  1119. void RendererDrawNormal()
  1120. {
  1121. //  CONPRINT("RendererDrawNormal\n");
  1122.     if (newframe)
  1123.     {
  1124.         GL_MtexStateSaver stateSaver;
  1125.     //  CONPRINT("newframe!\n");
  1126.  
  1127.         DrawBump();
  1128.         MY_DecayLights();
  1129.  
  1130.         if (gl.IsGLAllowed() && gl.Paranoia_hacks)
  1131.         {
  1132.             ResetRenderState();
  1133.  
  1134.             // Fix?
  1135.             // DrawSky();
  1136.         }
  1137.  
  1138.         numskyents = 0;
  1139. //      numrenderents = 0;
  1140.         newframe = 0;
  1141.     }
  1142. }
  1143.  
  1144.  
  1145. void RendererDrawTransparent()
  1146. {
  1147. //  GL_MtexStateSaver stateSaver;
  1148.     DrawTextureVecs();
  1149.     DrawDebugFrustumPlane();
  1150. }
  1151.  
  1152.  
  1153. void RendererVidInit()
  1154. {
  1155.     DeleteDecals();
  1156.     LoadDecals();
  1157.     ResetDynamicLights();
  1158.     ResetSky();
  1159.     reloaded = 1;
  1160.     framecount = 0;
  1161. //  maxmsgnum = -1;
  1162. //  addedents = 0;
  1163.  
  1164.     if (gl.IsGLAllowed() && gl.Paranoia_hacks)
  1165.         needkillsky = 1;
  1166. }
  1167.  
  1168.  
  1169. void RendererInit()
  1170. {
  1171.     SetLightmapBaseIndex();
  1172.     InitDecals();
  1173.  
  1174.     // Fix?
  1175.     // InitSky();
  1176.  
  1177.     cv_renderer = gEngfuncs.pfnRegisterVariable( "gl_renderer","1", 0 );
  1178.     cv_bump = gEngfuncs.pfnRegisterVariable( "gl_bump","1", FCVAR_ARCHIVE );
  1179.     cv_detailtex = gEngfuncs.pfnRegisterVariable( "gl_detailtex","1", FCVAR_ARCHIVE );
  1180.     cv_bumpvecs = gEngfuncs.pfnRegisterVariable( "bump_vecs","0", 0 );
  1181.     cv_bumpdebug = gEngfuncs.pfnRegisterVariable( "bump_debug","0", 0 );
  1182.     cv_specular = gEngfuncs.pfnRegisterVariable( "gl_specular","1", FCVAR_ARCHIVE );
  1183.     cv_dynamiclight = gEngfuncs.pfnRegisterVariable( "gl_dynlight","1", 0 );
  1184.     cv_entdynamiclight = gEngfuncs.pfnRegisterVariable( "gl_dynlight_ent","1", 0 );
  1185.     cv_specular_nocombiners = gEngfuncs.pfnRegisterVariable( "gl_nocombs","0", 0 );
  1186.     cv_specular_noshaders = gEngfuncs.pfnRegisterVariable( "gl_noshaders","0", 0 );
  1187.     cv_highspecular = gEngfuncs.pfnRegisterVariable( "gl_highspecular","1", FCVAR_ARCHIVE );
  1188.     cv_gamma = gEngfuncs.pfnRegisterVariable( "gl_gamma","1", FCVAR_ARCHIVE );
  1189.     cv_brightness = gEngfuncs.pfnRegisterVariable( "gl_brightness","0", FCVAR_ARCHIVE );
  1190.     cv_contrast = gEngfuncs.pfnRegisterVariable( "gl_contrast","1", FCVAR_ARCHIVE );
  1191.     cv_speculartwopass = gEngfuncs.pfnRegisterVariable( "gl_twopassspecular","0", 0 );
  1192.     cv_dyntwopass = gEngfuncs.pfnRegisterVariable( "gl_twopassdyn","0", 0 );
  1193.     cv_blurtest = gEngfuncs.pfnRegisterVariable( "gl_blurtest","0", 0 );
  1194.     cv_nsr = gEngfuncs.pfnRegisterVariable( "gl_modelrenderer","1", 0 );
  1195.     cv_lambert = gEngfuncs.pfnRegisterVariable( "gl_lambert","2", 0 );
  1196.     cv_drawbrushents = gEngfuncs.pfnRegisterVariable( "gl_brushents","1", 0 );
  1197.     cv_clipplanes = gEngfuncs.pfnRegisterVariable( "gl_clipplanes","0", 0 );
  1198.     cv_showplane = gEngfuncs.pfnRegisterVariable( "gl_showplane","0", 0 );
  1199.  
  1200.     gEngfuncs.pfnAddCommand ("dumptextures", DumpTextures);
  1201.     gEngfuncs.pfnAddCommand ("dumplevel", DumpLevel);
  1202.     gEngfuncs.pfnAddCommand ("makelight", MakeLight);
  1203.     gEngfuncs.pfnAddCommand ("dumpleaf", DumpLeafInfo);
  1204.  
  1205.     gEngfuncs.pfnHookUserMsg("mydlight", MsgCustomDlight);
  1206. }
  1207.  
  1208.  
  1209. void RendererCleanup()
  1210. {
  1211.     DeleteExtTextures();
  1212.     DecalsShutdown();
  1213.     FreeBuffer();
  1214. }
  1215.  
  1216.  
  1217. void RendererDrawHud()
  1218. {
  1219.     DecalsPrintDebugInfo();
  1220.     PrintOtherDebugInfo();
  1221.     PrintBumpDebugInfo();
  1222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement