Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GLOW_OVERLAY_H
  8. #define GLOW_OVERLAY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "mathlib/vector.h"
  13. #include "materialsystem/imaterial.h"
  14. #include "sun_shared.h"
  15. #include "c_pixel_visibility.h"
  16. #ifdef PORTAL
  17. #include "c_prop_portal.h" //MAX_PORTAL_RECURSIVE_VIEWS
  18. #endif
  19. extern float g_flOverlayRange;
  20. class CGlowSprite
  21. {
  22. public:
  23. Vector m_vColor; // 0-1
  24. float m_flHorzSize; // Horizontal and vertical sizes.
  25. float m_flVertSize; // 1 = size of the sun
  26. IMaterial *m_pMaterial; // Material to use
  27. };
  28. class CGlowOverlay
  29. {
  30. public:
  31. CGlowOverlay();
  32. virtual ~CGlowOverlay();
  33. // Return false to remove (and delete) the overlay.
  34. virtual bool Update();
  35. // Data the creator should fill in.
  36. public:
  37. // Position of the light source. If m_bDirectional is set, then it ignores
  38. // this and uses m_vDirection as the direction of the light source.
  39. Vector m_vPos;
  40. // Optional direction. Used for really far away things like the sun.
  41. // The direction should point AT the light source.
  42. bool m_bDirectional;
  43. Vector m_vDirection;
  44. // If this is set, then the overlay is only visible if the ray to it hits the sky.
  45. bool m_bInSky;
  46. float m_skyObstructionScale;
  47. #ifdef PORTAL
  48. float m_skyObstructionScaleBackups[MAX_PORTAL_RECURSIVE_VIEWS]; //used in portal mod during stencil rendering to maintain obstructions while rendering recursive views
  49. #endif
  50. CGlowSprite m_Sprites[MAX_SUN_LAYERS];
  51. int m_nSprites;
  52. float m_flProxyRadius;
  53. float m_flHDRColorScale;
  54. public:
  55. // After creating the overlay, call this to add it to the active list.
  56. // You can also call Activate and Deactivate as many times as you want.
  57. void Activate();
  58. void Deactivate();
  59. // Render all the active overlays.
  60. static void DrawOverlays( bool bCacheFullSceneState );
  61. static void UpdateSkyOverlays( float zFar, bool bCacheFullSceneState );
  62. #ifdef PORTAL
  63. static void BackupSkyOverlayData( int iBackupToSlot );
  64. static void RestoreSkyOverlayData( int iRestoreFromSlot );
  65. #endif
  66. protected:
  67. void UpdateGlowObstruction( const Vector &vToGlow, bool bCacheFullSceneState );
  68. void UpdateSkyGlowObstruction( float zFar, bool bCacheFullSceneState );
  69. virtual void CalcSpriteColorAndSize(
  70. float flDot,
  71. CGlowSprite *pSprite,
  72. float *flHorzSize,
  73. float *flVertSize,
  74. Vector *vColor );
  75. virtual void CalcBasis(
  76. const Vector &vToGlow,
  77. float flHorzSize,
  78. float flVertSize,
  79. Vector &vBasePt,
  80. Vector &vUp,
  81. Vector &vRight );
  82. virtual void Draw( bool bCacheFullSceneState );
  83. float CalcGlowAspect();
  84. float m_flGlowObstructionScale;
  85. bool m_bCacheGlowObstruction; // Flags to cache obstruction scales
  86. bool m_bCacheSkyObstruction; // Used in IFM poster rendering
  87. private:
  88. short m_bActivated;
  89. unsigned short m_ListIndex; // index into s_GlowOverlays.
  90. pixelvis_handle_t m_queryHandle;
  91. };
  92. //Override for warping
  93. class CWarpOverlay : public CGlowOverlay
  94. {
  95. protected:
  96. virtual void Draw( bool bCacheFullSceneState );
  97. };
  98. #endif // GLOW_OVERLAY_H