BsVideoModeInfo.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /** @addtogroup RenderAPI
  6. * @{
  7. */
  8. /**
  9. * Video mode contains information about how a render window presents its information to an output device like a
  10. * monitor.
  11. */
  12. class BS_CORE_EXPORT VideoMode
  13. {
  14. public:
  15. VideoMode() {}
  16. /**
  17. * Creates a new video mode.
  18. *
  19. * @param[in] width Width of the frame buffer in pixels.
  20. * @param[in] height Height of the frame buffer in pixels.
  21. * @param[in] refreshRate How often should the output device refresh the output image in hertz.
  22. * @param[in] outputIdx Output index of the output device. Normally this means output monitor. 0th index always
  23. * represents the primary device while order of others is undefined.
  24. */
  25. VideoMode(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 outputIdx = 0);
  26. virtual ~VideoMode();
  27. bool operator== (const VideoMode& other) const;
  28. /** Width of the front/back buffer in pixels. */
  29. UINT32 getWidth() const { return mWidth; }
  30. /** Height of the front/back buffer in pixels. */
  31. UINT32 getHeight() const { return mHeight; }
  32. /** Returns a refresh rate in hertz. */
  33. virtual float getRefreshRate() const { return mRefreshRate; }
  34. /** Returns information about the parent output. */
  35. UINT32 getOutputIdx() const { return mOutputIdx; }
  36. /**
  37. * Determines was video mode user created or provided by the API/OS. API/OS created video modes can contain
  38. * additional information that allows the video mode to be used more accurately and you should use them when possible.
  39. */
  40. bool isCustom() const { return mIsCustom; }
  41. protected:
  42. UINT32 mWidth = 1280;
  43. UINT32 mHeight = 720;
  44. float mRefreshRate = 60.0f;
  45. UINT32 mOutputIdx = 0;
  46. bool mIsCustom = true;
  47. };
  48. /** Contains information about a video output device, including a list of all available video modes. */
  49. class BS_CORE_EXPORT VideoOutputInfo
  50. {
  51. public:
  52. VideoOutputInfo() { }
  53. virtual ~VideoOutputInfo();
  54. VideoOutputInfo(const VideoOutputInfo&) = delete; // Make non-copyable
  55. VideoOutputInfo& operator=(const VideoOutputInfo&) = delete; // Make non-copyable
  56. /** Name of the output device. */
  57. const String& getName() const { return mName; }
  58. /** Number of available video modes for this output. */
  59. UINT32 getNumVideoModes() const { return (UINT32)mVideoModes.size(); }
  60. /** Returns video mode at the specified index. */
  61. const VideoMode& getVideoMode(UINT32 idx) const { return *mVideoModes.at(idx); }
  62. /** Returns the video mode currently used by the desktop. */
  63. const VideoMode& getDesktopVideoMode() const { return *mDesktopVideoMode; }
  64. protected:
  65. String mName;
  66. Vector<VideoMode*> mVideoModes;
  67. VideoMode* mDesktopVideoMode = nullptr;
  68. };
  69. /** Contains information about available output devices (e.g. monitor) and their video modes. */
  70. class BS_CORE_EXPORT VideoModeInfo
  71. {
  72. public:
  73. VideoModeInfo() { }
  74. virtual ~VideoModeInfo();
  75. VideoModeInfo(const VideoModeInfo&) = delete; // Make non-copyable
  76. VideoModeInfo& operator=(const VideoModeInfo&) = delete; // Make non-copyable
  77. /** Returns the number of available output devices. */
  78. UINT32 getNumOutputs() const { return (UINT32)mOutputs.size(); }
  79. /**
  80. * Returns video mode information about a specific output device. 0th index always represents the primary device
  81. * while order of others is undefined.
  82. */
  83. const VideoOutputInfo& getOutputInfo(UINT32 idx) const { return *mOutputs[idx]; }
  84. protected:
  85. Vector<VideoOutputInfo*> mOutputs;
  86. };
  87. /** @} */
  88. }