BsVideoModeInfo.h 3.9 KB

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