BsVideoModeInfo.h 3.5 KB

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