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.

136 lines
3.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef VIEW_SHARED_H
  7. #define VIEW_SHARED_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "convar.h"
  12. #include "mathlib/vector.h"
  13. #include "materialsystem/MaterialSystemUtil.h"
  14. //-----------------------------------------------------------------------------
  15. // Flags passed in with view setup
  16. //-----------------------------------------------------------------------------
  17. enum ClearFlags_t
  18. {
  19. VIEW_CLEAR_COLOR = 0x1,
  20. VIEW_CLEAR_DEPTH = 0x2,
  21. VIEW_CLEAR_FULL_TARGET = 0x4,
  22. VIEW_NO_DRAW = 0x8,
  23. VIEW_CLEAR_OBEY_STENCIL = 0x10, // Draws a quad allowing stencil test to clear through portals
  24. VIEW_CLEAR_STENCIL = 0x20,
  25. };
  26. enum StereoEye_t
  27. {
  28. STEREO_EYE_MONO = 0,
  29. STEREO_EYE_LEFT = 1,
  30. STEREO_EYE_RIGHT = 2,
  31. STEREO_EYE_MAX = 3,
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Purpose: Renderer setup data.
  35. //-----------------------------------------------------------------------------
  36. class CViewSetup
  37. {
  38. public:
  39. CViewSetup()
  40. {
  41. m_flAspectRatio = 0.0f;
  42. m_bRenderToSubrectOfLargerScreen = false;
  43. m_bDoBloomAndToneMapping = true;
  44. m_bOrtho = false;
  45. m_bOffCenter = false;
  46. m_bCacheFullSceneState = false;
  47. // m_bUseExplicitViewVector = false;
  48. m_bViewToProjectionOverride = false;
  49. m_eStereoEye = STEREO_EYE_MONO;
  50. }
  51. // shared by 2D & 3D views
  52. // left side of view window
  53. int x;
  54. int m_nUnscaledX;
  55. // top side of view window
  56. int y;
  57. int m_nUnscaledY;
  58. // width of view window
  59. int width;
  60. int m_nUnscaledWidth;
  61. // height of view window
  62. int height;
  63. // which eye are we rendering?
  64. StereoEye_t m_eStereoEye;
  65. int m_nUnscaledHeight;
  66. // the rest are only used by 3D views
  67. // Orthographic projection?
  68. bool m_bOrtho;
  69. // View-space rectangle for ortho projection.
  70. float m_OrthoLeft;
  71. float m_OrthoTop;
  72. float m_OrthoRight;
  73. float m_OrthoBottom;
  74. // horizontal FOV in degrees
  75. float fov;
  76. // horizontal FOV in degrees for in-view model
  77. float fovViewmodel;
  78. // 3D origin of camera
  79. Vector origin;
  80. // heading of camera (pitch, yaw, roll)
  81. QAngle angles;
  82. // local Z coordinate of near plane of camera
  83. float zNear;
  84. // local Z coordinate of far plane of camera
  85. float zFar;
  86. // local Z coordinate of near plane of camera ( when rendering view model )
  87. float zNearViewmodel;
  88. // local Z coordinate of far plane of camera ( when rendering view model )
  89. float zFarViewmodel;
  90. // set to true if this is to draw into a subrect of the larger screen
  91. // this really is a hack, but no more than the rest of the way this class is used
  92. bool m_bRenderToSubrectOfLargerScreen;
  93. // The aspect ratio to use for computing the perspective projection matrix
  94. // (0.0f means use the viewport)
  95. float m_flAspectRatio;
  96. // Controls for off-center projection (needed for poster rendering)
  97. bool m_bOffCenter;
  98. float m_flOffCenterTop;
  99. float m_flOffCenterBottom;
  100. float m_flOffCenterLeft;
  101. float m_flOffCenterRight;
  102. // Control that the SFM needs to tell the engine not to do certain post-processing steps
  103. bool m_bDoBloomAndToneMapping;
  104. // Cached mode for certain full-scene per-frame varying state such as sun entity coverage
  105. bool m_bCacheFullSceneState;
  106. // If using VR, the headset calibration will feed you a projection matrix per-eye.
  107. // This does NOT override the Z range - that will be set up as normal (i.e. the values in this matrix will be ignored).
  108. bool m_bViewToProjectionOverride;
  109. VMatrix m_ViewToProjection;
  110. };
  111. #endif // VIEW_SHARED_H