Team Fortress 2 Source Code as on 22/4/2020
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.

174 lines
5.4 KiB

  1. //========= Copyright 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. //-----------------------------------------------------------------------------
  19. // Current view
  20. //-----------------------------------------------------------------------------
  21. inline const Vector &CurrentViewOrigin()
  22. {
  23. #ifdef DBGFLAG_ASSERT
  24. extern bool g_bCanAccessCurrentView;
  25. #endif
  26. extern Vector g_CurrentViewOrigin;
  27. Assert( g_bCanAccessCurrentView );
  28. return g_CurrentViewOrigin;
  29. }
  30. inline const Vector &CurrentViewForward()
  31. {
  32. #ifdef DBGFLAG_ASSERT
  33. extern bool g_bCanAccessCurrentView;
  34. #endif
  35. extern Vector g_CurrentViewForward;
  36. Assert( g_bCanAccessCurrentView );
  37. return g_CurrentViewForward;
  38. }
  39. inline const Vector &CurrentViewRight()
  40. {
  41. #ifdef DBGFLAG_ASSERT
  42. extern bool g_bCanAccessCurrentView;
  43. #endif
  44. extern Vector g_CurrentViewRight;
  45. Assert( g_bCanAccessCurrentView );
  46. return g_CurrentViewRight;
  47. }
  48. inline const Vector &CurrentViewUp()
  49. {
  50. #ifdef DBGFLAG_ASSERT
  51. extern bool g_bCanAccessCurrentView;
  52. #endif
  53. extern Vector g_CurrentViewUp;
  54. Assert( g_bCanAccessCurrentView );
  55. return g_CurrentViewUp;
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Main view
  59. //-----------------------------------------------------------------------------
  60. inline const Vector &MainViewOrigin()
  61. {
  62. extern Vector g_MainViewOrigin;
  63. return g_MainViewOrigin;
  64. }
  65. inline const Vector &MainViewForward()
  66. {
  67. extern Vector g_MainViewForward;
  68. return g_MainViewForward;
  69. }
  70. inline const Vector &MainViewRight()
  71. {
  72. extern Vector g_MainViewRight;
  73. return g_MainViewRight;
  74. }
  75. inline const Vector &MainViewUp()
  76. {
  77. extern Vector g_MainViewUp;
  78. return g_MainViewUp;
  79. }
  80. void R_Init (void);
  81. void R_LevelInit(void);
  82. void R_LevelShutdown(void);
  83. // Loads world geometry. Called when map changes or dx level changes
  84. void R_LoadWorldGeometry( bool bDXChange = false );
  85. #include "view_shared.h"
  86. #include "ivrenderview.h"
  87. class VMatrix;
  88. abstract_class IRender
  89. {
  90. public:
  91. virtual void FrameBegin( void ) = 0;
  92. virtual void FrameEnd( void ) = 0;
  93. virtual void ViewSetupVis( bool novis, int numorigins, const Vector origin[] ) = 0;
  94. virtual void ViewDrawFade( byte *color, IMaterial* pFadeMaterial ) = 0;
  95. virtual void DrawSceneBegin( void ) = 0;
  96. virtual void DrawSceneEnd( void ) = 0;
  97. virtual IWorldRenderList * CreateWorldList() = 0;
  98. virtual void BuildWorldLists( IWorldRenderList *pList, WorldListInfo_t* pInfo, int iForceViewLeaf, const VisOverrideData_t* pVisData, bool bShadowDepth, float *pReflectionWaterHeight ) = 0;
  99. virtual void DrawWorldLists( IWorldRenderList *pList, unsigned long flags, float waterZAdjust ) = 0;
  100. // UNDONE: these are temporary functions that will end up on the other
  101. // side of this interface
  102. // accessors
  103. // virtual const Vector& UnreflectedViewOrigin() = 0;
  104. virtual const Vector& ViewOrigin( void ) = 0;
  105. virtual const QAngle& ViewAngles( void ) = 0;
  106. virtual CViewSetup const &ViewGetCurrent( void ) = 0;
  107. virtual const VMatrix& ViewMatrix( void ) = 0;
  108. virtual const VMatrix& WorldToScreenMatrix( void ) = 0;
  109. virtual float GetFramerate( void ) = 0;
  110. virtual float GetZNear( void ) = 0;
  111. virtual float GetZFar( void ) = 0;
  112. // Query current fov and view model fov
  113. virtual float GetFov( void ) = 0;
  114. virtual float GetFovY( void ) = 0;
  115. virtual float GetFovViewmodel( void ) = 0;
  116. // Compute the clip-space coordinates of a point in 3D
  117. // Clip-space is normalized screen coordinates (-1 to 1 in x and y)
  118. // Returns true if the point is behind the camera
  119. virtual bool ClipTransformWithProjection ( const VMatrix& worldToScreen, const Vector& point, Vector* pClip ) = 0;
  120. // Same, using the current engine's matrices.
  121. virtual bool ClipTransform( Vector const& point, Vector* pClip ) = 0;
  122. // Compute the screen-space coordinates of a point in 3D
  123. // This returns actual pixels
  124. // Returns true if the point is behind the camera
  125. virtual bool ScreenTransform( Vector const& point, Vector* pScreen ) = 0;
  126. virtual void Push3DView( const CViewSetup &view, int nFlags, ITexture* pRenderTarget, Frustum frustumPlanes ) = 0;
  127. virtual void Push3DView( const CViewSetup &view, int nFlags, ITexture* pRenderTarget, Frustum frustumPlanes, ITexture* pDepthTexture ) = 0;
  128. virtual void Push2DView( const CViewSetup &view, int nFlags, ITexture* pRenderTarget, Frustum frustumPlanes ) = 0;
  129. virtual void PopView( Frustum frustumPlanes ) = 0;
  130. virtual void SetMainView( const Vector &vecOrigin, const QAngle &angles ) = 0;
  131. virtual void ViewSetupVisEx( bool novis, int numorigins, const Vector origin[], unsigned int &returnFlags ) = 0;
  132. virtual void OverrideViewFrustum( Frustum custom ) = 0;
  133. virtual void UpdateBrushModelLightmap( model_t *model, IClientRenderable *Renderable ) = 0;
  134. virtual void BeginUpdateLightmaps( void ) = 0;
  135. virtual void EndUpdateLightmaps( void ) = 0;
  136. virtual bool InLightmapUpdate( void ) const = 0;
  137. };
  138. void R_PushDlights (void);
  139. // UNDONE Remove this - pass this around to functions/systems that need it.
  140. extern IRender *g_EngineRenderer;
  141. #endif // RENDER_H