Gamedev Framework (gf)  0.4.0
A C++11 framework for 2D games
Monitor.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2017 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_MONITOR_H
22 #define GF_MONITOR_H
23 
24 #include <string>
25 #include <vector>
26 
27 #include "Library.h"
28 #include "Portability.h"
29 #include "Vector.h"
30 
31 namespace gf {
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 inline namespace v1 {
34 #endif
35 
36  /**
37  * @ingroup window
38  * @brief A video mode
39  *
40  */
41  struct GF_API VideoMode {
42  Vector2u size; ///< Video mode size, in pixels
43  unsigned bitsPerPixel; ///< Video mode pixel depth, in bits per pixel
44  int refreshRate; ///< Video mode refresh rate, in Hz
45  };
46 
47  /**
48  * @ingroup window
49  * @brief A monitor
50  */
51  class GF_API Monitor {
52  public:
53  /**
54  * @brief Get the primary monitor
55  *
56  * @return The primary monitor
57  */
58  static Monitor getPrimaryMonitor();
59 
60  /**
61  * @brief Get all the available monitors
62  */
63  static std::vector<Monitor> getAvailableMonitors();
64 
65  /**
66  * @brief Deleted copy constructor
67  */
68  Monitor(const Monitor&) = delete;
69 
70  /**
71  * @brief Deleted copy assignment
72  */
73  Monitor& operator=(const Monitor&) = delete;
74 
75  /**
76  * @brief Move constructor
77  */
78  Monitor(Monitor&& other) = default;
79 
80  /**
81  * @brief Move assignement
82  */
83  Monitor& operator=(Monitor&& other) = default;
84 
85  /**
86  * @brief Get the name of the monitor
87  *
88  * @return A string containing the name of the monitor
89  */
90  std::string getName();
91 
92  /**
93  * @brief Get the position of the monitor
94  *
95  * @return The position of the monitor
96  */
97  Vector2i getPosition();
98 
99  /**
100  * @brief Get the physical size of the monitor
101  *
102  * @return The physical size of the monitor
103  */
104  Vector2u getPhysicalSize();
105 
106  /**
107  * @brief Get the available video modes for this monitor
108  *
109  * @return The video modes for this monitor
110  */
111  std::vector<VideoMode> getAvailableVideoModes();
112 
113  /**
114  * @brief Get the current video mode
115  *
116  * @return The current video mode
117  */
119 
120  private:
121  friend class Window;
122 
123  explicit Monitor(int index);
124 
125  Library m_lib; // to automatically initialize SDL
126  int m_index;
127  };
128 
129 #ifndef DOXYGEN_SHOULD_SKIP_THIS
130 }
131 #endif
132 }
133 
134 #endif // GL_MONITOR_H
Vector2i getPosition()
Get the position of the monitor.
int refreshRate
Video mode refresh rate, in Hz.
Definition: Monitor.h:44
std::vector< VideoMode > getAvailableVideoModes()
Get the available video modes for this monitor.
friend class RenderTarget
Definition: Shader.h:388
A video mode.
Definition: Monitor.h:41
Monitor(const Monitor &)=delete
Deleted copy constructor.
static Monitor getPrimaryMonitor()
Get the primary monitor.
Monitor & operator=(Monitor &&other)=default
Move assignement.
The namespace for gf classes.
Definition: Action.h:34
A class to represent the library.
Definition: Library.h:42
VideoMode getCurrentVideoMode()
Get the current video mode.
A monitor.
Definition: Monitor.h:51
static std::vector< Monitor > getAvailableMonitors()
Get all the available monitors.
unsigned bitsPerPixel
Video mode pixel depth, in bits per pixel.
Definition: Monitor.h:43
#define GF_API
Definition: Portability.h:35
std::string getName()
Get the name of the monitor.
Monitor(Monitor &&other)=default
Move constructor.
Vector2u size
Video mode size, in pixels.
Definition: Monitor.h:42
Monitor & operator=(const Monitor &)=delete
Deleted copy assignment.
Vector2u getPhysicalSize()
Get the physical size of the monitor.