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.

121 lines
4.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef IVIDEOMODE_H
  10. #define IVIDEOMODE_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "vmodes.h"
  15. #include "vtf/vtf.h"
  16. struct MovieInfo_t;
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. //-----------------------------------------------------------------------------
  20. abstract_class IVideoMode
  21. {
  22. public:
  23. virtual ~IVideoMode() {}
  24. virtual bool Init( ) = 0;
  25. virtual void Shutdown( void ) = 0;
  26. // Shows the start-up graphics based on the mod
  27. // (Filesystem path for the mod must be set up first)
  28. virtual void DrawStartupGraphic() = 0;
  29. // Creates the game window, plays the startup movie, starts up the material system
  30. virtual bool CreateGameWindow( int nWidth, int nHeight, bool bWindowed ) = 0;
  31. // Sets the game window in editor mode
  32. virtual void SetGameWindow( void *hWnd ) = 0;
  33. // Sets the video mode, and re-sizes the window
  34. virtual bool SetMode( int nWidth, int nHeight, bool bWindowed ) = 0;
  35. // Returns the fullscreen modes for the adapter the game was started on
  36. virtual int GetModeCount( void ) = 0;
  37. virtual struct vmode_s *GetMode( int num ) = 0;
  38. // Purpose: This is called in response to a WM_MOVE message
  39. // or whatever the equivalent that would be under linux
  40. virtual void UpdateWindowPosition( void ) = 0;
  41. // Alt-tab handling
  42. virtual void RestoreVideo( void ) = 0;
  43. virtual void ReleaseVideo( void ) = 0;
  44. virtual void DrawNullBackground( void *hdc, int w, int h ) = 0;
  45. virtual void InvalidateWindow() = 0;
  46. // Returns the video mode width + height. In the case of windowed mode,
  47. // it returns the width and height of the drawable region of the window.
  48. // (it doesn't include the window borders)
  49. virtual int GetModeWidth() const = 0;
  50. virtual int GetModeHeight() const = 0;
  51. virtual bool IsWindowedMode() const = 0;
  52. // Returns the video mode width + height for a single stereo display.
  53. // if the game isn't running in side by side stereo, this is the same
  54. // as GetModeWidth and GetModeHeight
  55. virtual int GetModeStereoWidth() const = 0;
  56. virtual int GetModeStereoHeight() const = 0;
  57. // Returns the size of full screen UI. This might be wider than a single
  58. // eye on displays like the Oculus Rift where a single eye is very narrow.
  59. // if the game isn't running in side by side stereo, this is the same
  60. // as GetModeWidth and GetModeHeight
  61. virtual int GetModeUIWidth() const = 0;
  62. virtual int GetModeUIHeight() const = 0;
  63. // Returns the subrect to draw the client view into.
  64. // Coordinates are measured relative to the drawable region of the window
  65. virtual const vrect_t & GetClientViewRect( ) const = 0;
  66. virtual void SetClientViewRect( const vrect_t &viewRect ) = 0;
  67. // Lazily recomputes client view rect
  68. virtual void MarkClientViewRectDirty() = 0;
  69. virtual void TakeSnapshotTGA( const char *pFileName ) = 0;
  70. virtual void TakeSnapshotTGARect( const char *pFilename, int x, int y, int w, int h, int resampleWidth, int resampleHeight, bool bPFM = false, CubeMapFaceIndex_t faceIndex = CUBEMAP_FACE_RIGHT ) = 0;
  71. virtual void WriteMovieFrame( const MovieInfo_t& info ) = 0;
  72. // Takes snapshots
  73. virtual void TakeSnapshotJPEG( const char *pFileName, int quality ) = 0;
  74. virtual bool TakeSnapshotJPEGToBuffer( CUtlBuffer& buf, int quality ) = 0;
  75. virtual void ReadScreenPixels( int x, int y, int w, int h, void *pBuffer, ImageFormat format ) = 0;
  76. };
  77. //-----------------------------------------------------------------------------
  78. // Utilities for virtual screen coordinates
  79. //-----------------------------------------------------------------------------
  80. #define XRES(x) ( x * ( ( float )videomode->GetModeStereoWidth() / 640.0 ) )
  81. #define YRES(y) ( y * ( ( float )videomode->GetModeStereoHeight() / 480.0 ) )
  82. //-----------------------------------------------------------------------------
  83. // Singleton accessor
  84. //-----------------------------------------------------------------------------
  85. extern IVideoMode *videomode;
  86. //-----------------------------------------------------------------------------
  87. // Class factory
  88. //-----------------------------------------------------------------------------
  89. void VideoMode_Create();
  90. void VideoMode_Destroy();
  91. #endif // IVIDEOMODE_H