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