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.

222 lines
6.7 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef RENDER_H
  9. #define RENDER_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "mathlib/vector.h"
  14. // render.h -- public interface to refresh functions
  15. extern float r_blend; // Global blending factor for the current entity
  16. extern float r_colormod[3]; // Global color modulation for the current entity
  17. extern bool g_bIsBlendingOrModulating;
  18. #ifndef DEDICATED
  19. #include "cl_splitscreen.h" // ISplitScreen
  20. #endif
  21. //-----------------------------------------------------------------------------
  22. // Current view
  23. //-----------------------------------------------------------------------------
  24. inline const Vector &CurrentViewOrigin()
  25. {
  26. extern Vector g_CurrentViewOrigin;
  27. #ifndef DEDICATED
  28. extern bool g_bCanAccessCurrentView;
  29. Assert( g_bCanAccessCurrentView );
  30. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  31. #endif
  32. return g_CurrentViewOrigin;
  33. }
  34. inline const Vector &CurrentViewForward()
  35. {
  36. extern Vector g_CurrentViewForward;
  37. extern Vector g_CurrentViewOrigin;
  38. #ifndef DEDICATED
  39. extern bool g_bCanAccessCurrentView;
  40. Assert( g_bCanAccessCurrentView );
  41. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  42. #endif
  43. return g_CurrentViewForward;
  44. }
  45. inline const Vector &CurrentViewRight()
  46. {
  47. extern Vector g_CurrentViewRight;
  48. #ifndef DEDICATED
  49. extern bool g_bCanAccessCurrentView;
  50. Assert( g_bCanAccessCurrentView );
  51. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  52. #endif
  53. return g_CurrentViewRight;
  54. }
  55. inline const Vector &CurrentViewUp()
  56. {
  57. extern Vector g_CurrentViewUp;
  58. #ifndef DEDICATED
  59. extern bool g_bCanAccessCurrentView;
  60. Assert( g_bCanAccessCurrentView );
  61. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  62. #endif
  63. return g_CurrentViewUp;
  64. }
  65. extern Vector g_MainViewOrigin[ MAX_SPLITSCREEN_CLIENTS ];
  66. extern Vector g_MainViewForward[ MAX_SPLITSCREEN_CLIENTS ];
  67. extern Vector g_MainViewRight[ MAX_SPLITSCREEN_CLIENTS ];
  68. extern Vector g_MainViewUp[ MAX_SPLITSCREEN_CLIENTS ];
  69. //-----------------------------------------------------------------------------
  70. // Main view
  71. //-----------------------------------------------------------------------------
  72. inline const Vector &MainViewOrigin( int nSlot = -1 )
  73. {
  74. #ifdef DEDICATED
  75. nSlot = 0;
  76. #else
  77. if ( nSlot == -1 )
  78. {
  79. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  80. nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
  81. }
  82. #endif
  83. return g_MainViewOrigin[ nSlot ];
  84. }
  85. inline const Vector &MainViewForward( int nSlot = -1 )
  86. {
  87. #ifdef DEDICATED
  88. nSlot = 0;
  89. #else
  90. if ( nSlot == -1 )
  91. {
  92. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  93. nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
  94. }
  95. #endif
  96. return g_MainViewForward[ nSlot ];
  97. }
  98. inline const Vector &MainViewRight( int nSlot = -1 )
  99. {
  100. #ifdef DEDICATED
  101. nSlot = 0;
  102. #else
  103. if ( nSlot == -1 )
  104. {
  105. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  106. nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
  107. }
  108. #endif
  109. return g_MainViewRight[ nSlot ];
  110. }
  111. inline const Vector &MainViewUp( int nSlot = -1 )
  112. {
  113. #ifdef DEDICATED
  114. nSlot = 0;
  115. #else
  116. if ( nSlot == -1 )
  117. {
  118. ASSERT_LOCAL_PLAYER_RESOLVABLE();
  119. nSlot = GET_ACTIVE_SPLITSCREEN_SLOT();
  120. }
  121. #endif
  122. return g_MainViewUp[ nSlot ];
  123. }
  124. void R_Init (void);
  125. void R_LevelInit(void);
  126. void R_LevelShutdown(void);
  127. // Loads world geometry. Called when map changes or dx level changes
  128. void R_LoadWorldGeometry( bool bDXChange = false );
  129. #include "view_shared.h"
  130. #include "ivrenderview.h"
  131. class VMatrix;
  132. abstract_class IRender
  133. {
  134. public:
  135. virtual void FrameBegin( void ) = 0;
  136. virtual void FrameEnd( void ) = 0;
  137. virtual void ViewSetupVis( bool novis, int numorigins, const Vector origin[] ) = 0;
  138. virtual void ViewDrawFade( byte *color, IMaterial* pFadeMaterial, bool mapFullTextureToScreen = true ) = 0;
  139. virtual void DrawSceneBegin( void ) = 0;
  140. virtual void DrawSceneEnd( void ) = 0;
  141. virtual IWorldRenderList * CreateWorldList() = 0;
  142. #if defined(_PS3)
  143. virtual IWorldRenderList * CreateWorldList_PS3( int viewID ) = 0;
  144. virtual void BuildWorldLists_PS3_Epilogue( IWorldRenderList *pList, WorldListInfo_t* pInfo, bool bShadowDepth ) = 0;
  145. #else
  146. virtual void BuildWorldLists_Epilogue( IWorldRenderList *pList, WorldListInfo_t* pInfo, bool bShadowDepth ) = 0;
  147. #endif
  148. virtual void BuildWorldLists( IWorldRenderList *pList, WorldListInfo_t* pInfo, int iForceViewLeaf, const VisOverrideData_t* pVisData, bool bShadowDepth, float *pReflectionWaterHeight ) = 0;
  149. virtual void DrawWorldLists( IMatRenderContext *pRenderContext, IWorldRenderList *pList, unsigned long flags, float waterZAdjust ) = 0;
  150. // UNDONE: these are temporary functions that will end up on the other
  151. // side of this interface
  152. // accessors
  153. // virtual const Vector& UnreflectedViewOrigin() = 0;
  154. virtual const Vector& ViewOrigin( void ) = 0;
  155. virtual const QAngle& ViewAngles( void ) = 0;
  156. virtual CViewSetup const &ViewGetCurrent( void ) = 0;
  157. virtual const VMatrix& ViewMatrix( void ) = 0;
  158. virtual const VMatrix& WorldToScreenMatrix( void ) = 0;
  159. virtual float GetFramerate( void ) = 0;
  160. virtual float GetZNear( void ) = 0;
  161. virtual float GetZFar( void ) = 0;
  162. // Query current fov and view model fov
  163. virtual float GetFov( void ) = 0;
  164. virtual float GetFovY( void ) = 0;
  165. virtual float GetFovViewmodel( void ) = 0;
  166. // Compute the clip-space coordinates of a point in 3D
  167. // Clip-space is normalized screen coordinates (-1 to 1 in x and y)
  168. // Returns true if the point is behind the camera
  169. virtual bool ClipTransform( Vector const& point, Vector* pClip ) = 0;
  170. // Compute the screen-space coordinates of a point in 3D
  171. // This returns actual pixels
  172. // Returns true if the point is behind the camera
  173. virtual bool ScreenTransform( Vector const& point, Vector* pScreen ) = 0;
  174. virtual void Push3DView( IMatRenderContext *pRenderContext, const CViewSetup &view, int nFlags, ITexture* pRenderTarget, Frustum frustumPlanes ) = 0;
  175. virtual void Push3DView( IMatRenderContext *pRenderContext, const CViewSetup &view, int nFlags, ITexture* pRenderTarget, Frustum frustumPlanes, ITexture* pDepthTexture ) = 0;
  176. virtual void Push2DView( IMatRenderContext *pRenderContext, const CViewSetup &view, int nFlags, ITexture* pRenderTarget, Frustum frustumPlanes ) = 0;
  177. virtual void PopView( IMatRenderContext *pRenderContext, Frustum frustumPlanes ) = 0;
  178. virtual void SetMainView( const Vector &vecOrigin, const QAngle &angles ) = 0;
  179. virtual void ViewSetupVisEx( bool novis, int numorigins, const Vector origin[], unsigned int &returnFlags ) = 0;
  180. virtual void OverrideViewFrustum( Frustum custom ) = 0;
  181. virtual void UpdateBrushModelLightmap( model_t *model, IClientRenderable *Renderable ) = 0;
  182. virtual void BeginUpdateLightmaps( void ) = 0;
  183. virtual void EndUpdateLightmaps() = 0;
  184. virtual bool InLightmapUpdate( void ) const = 0;
  185. };
  186. void R_PushDlights (void);
  187. // UNDONE Remove this - pass this around to functions/systems that need it.
  188. extern IRender *g_EngineRenderer;
  189. #endif // RENDER_H