BsVideoModeInfo.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. /**
  26. * @brief Width of the front/back buffer in pixels.
  27. */
  28. UINT32 getWidth() const { return mWidth; }
  29. /**
  30. * @brief Height of the front/back buffer in pixels.
  31. */
  32. UINT32 getHeight() const { return mHeight; }
  33. /**
  34. * @brief Returns a refresh rate in Hertz.
  35. */
  36. virtual float getRefreshRate() const { return mRefreshRate; }
  37. /**
  38. * @brief Returns information about the parent output.
  39. */
  40. UINT32 getOutputIdx() const { return mOutputIdx; }
  41. /**
  42. * @brief Determines was video mode user created or provided by the API/OS.
  43. * API/OS created video modes can contain additional information that allows
  44. * the video mode to be used more accurately and you should use them when possible.
  45. */
  46. bool isCustom() const { return mIsCustom; }
  47. protected:
  48. UINT32 mWidth = 1280;
  49. UINT32 mHeight = 720;
  50. float mRefreshRate = 60.0f;
  51. UINT32 mOutputIdx = 0;
  52. bool mIsCustom = true;
  53. };
  54. /**
  55. * @brief Contains information about a video output device, including
  56. * a list of all available video modes.
  57. */
  58. class BS_CORE_EXPORT VideoOutputInfo
  59. {
  60. public:
  61. VideoOutputInfo() { }
  62. virtual ~VideoOutputInfo();
  63. VideoOutputInfo(const VideoOutputInfo&) = delete; // Make non-copyable
  64. VideoOutputInfo& operator=(const VideoOutputInfo&) = delete; // Make non-copyable
  65. /**
  66. * @brief Name of the output device.
  67. */
  68. const String& getName() const { return mName; }
  69. /**
  70. * @brief Number of available video modes for this output.
  71. */
  72. UINT32 getNumVideoModes() const { return (UINT32)mVideoModes.size(); }
  73. /**
  74. * @brief Returns video mode at the specified index.
  75. */
  76. const VideoMode& getVideoMode(UINT32 idx) const { return *mVideoModes.at(idx); }
  77. /**
  78. * @brief Returns the video mode currently used by the desktop.
  79. */
  80. const VideoMode& getDesktopVideoMode() const { return *mDesktopVideoMode; }
  81. protected:
  82. String mName;
  83. Vector<VideoMode*> mVideoModes;
  84. VideoMode* mDesktopVideoMode = nullptr;
  85. };
  86. /**
  87. * @brief Contains information about available output devices (e.g. monitor)
  88. * and their video modes.
  89. */
  90. class BS_CORE_EXPORT VideoModeInfo
  91. {
  92. public:
  93. VideoModeInfo() { }
  94. virtual ~VideoModeInfo();
  95. VideoModeInfo(const VideoModeInfo&) = delete; // Make non-copyable
  96. VideoModeInfo& operator=(const VideoModeInfo&) = delete; // Make non-copyable
  97. /**
  98. * @brief Returns the number of available output devices.
  99. */
  100. UINT32 getNumOutputs() const { return (UINT32)mOutputs.size(); }
  101. /**
  102. * @brief Returns video mode information about a specific output device.
  103. */
  104. const VideoOutputInfo& getOutputInfo(UINT32 idx) const { return *mOutputs[idx]; }
  105. protected:
  106. Vector<VideoOutputInfo*> mOutputs;
  107. };
  108. }