BsVideoModeInfo.h 3.7 KB

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