Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Monitor.h
1/*
2 * Gamedev Framework (gf)
3 * Copyright (C) 2016-2022 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 "GraphicsApi.h"
28#include "Library.h"
29#include "Vector.h"
30
31namespace gf {
32#ifndef DOXYGEN_SHOULD_SKIP_THIS
33inline namespace v1 {
34#endif
35
41 struct GF_GRAPHICS_API VideoMode {
43 unsigned bitsPerPixel;
45 };
46
51 class GF_GRAPHICS_API Monitor {
52 public:
59
63 static std::vector<Monitor> getAvailableMonitors();
64
68 Monitor(const Monitor&) = delete;
69
73 Monitor& operator=(const Monitor&) = delete;
74
78 Monitor(Monitor&& other) = default;
79
83 Monitor& operator=(Monitor&& other) = default;
84
90 std::string getName() const;
91
98
105
111 std::vector<VideoMode> getAvailableVideoModes() const;
112
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
A class to represent the library.
Definition: Library.h:44
A monitor.
Definition: Monitor.h:51
Monitor(Monitor &&other)=default
Move constructor.
Monitor & operator=(Monitor &&other)=default
Move assignement.
static std::vector< Monitor > getAvailableMonitors()
Get all the available monitors.
Vector2i getPosition() const
Get the position of the monitor.
std::string getName() const
Get the name of the monitor.
Monitor & operator=(const Monitor &)=delete
Deleted copy assignment.
static Monitor getPrimaryMonitor()
Get the primary monitor.
VideoMode getCurrentVideoMode() const
Get the current video mode.
std::vector< VideoMode > getAvailableVideoModes() const
Get the available video modes for this monitor.
Vector2i getPhysicalSize() const
Get the physical size of the monitor.
Monitor(const Monitor &)=delete
Deleted copy constructor.
An OS window.
Definition: Window.h:97
The namespace for gf classes.
A video mode.
Definition: Monitor.h:41
unsigned bitsPerPixel
Video mode pixel depth, in bits per pixel.
Definition: Monitor.h:43
Vector2i size
Video mode size, in pixels.
Definition: Monitor.h:42
int refreshRate
Video mode refresh rate, in Hz.
Definition: Monitor.h:44