FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
devicecaps.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_DEVICECAPS_H
23 #define FIFE_DEVICECAPS_H
24 
25 // Standard C++ library includes
26 #include <string>
27 #include <vector>
28 
29 // Platform specific includes
30 
31 // 3rd party library includes
32 
33 // FIFE includes
34 // These includes are split up in two parts, separated by one empty line
35 // First block: files included from the FIFE root src directory
36 // Second block: files included from the same folder
37 #include "util/structures/rect.h"
38 
39 namespace FIFE {
40 
41  class ScreenMode {
42  public:
47  ScreenMode();
48  ScreenMode(uint16_t width, uint16_t height, uint16_t bpp, uint32_t SDLFlags);
49  ScreenMode(uint16_t width, uint16_t height, uint16_t bpp, uint16_t rate, uint32_t SDLFlags);
50  ScreenMode(const ScreenMode& rhs);
51 
55 
56  bool operator <(const ScreenMode& rhs) const;
57 
62  uint16_t getWidth() const { return m_width; };
63 
68  uint16_t getHeight() const { return m_height; };
69 
72  uint16_t getBPP() const { return m_bpp; };
73 
77 
80  uint32_t getSDLFlags() const { return m_SDLFlags; };
81 
84  bool isFullScreen() const { return (m_SDLFlags & SDL_WINDOW_FULLSCREEN) ? true : false;};
85 
88  bool isOpenGL() const { return (m_SDLFlags & SDL_WINDOW_OPENGL) ? true : false; };
89 
92  bool isSDL() const { return (!(m_SDLFlags & SDL_WINDOW_OPENGL)) ? true : false; };
93 
96  void setFormat(uint32_t format) { m_format = format;}
97 
100  uint32_t getFormat() const { return m_format; }
101 
104  void setDisplay(uint8_t display) { m_display = display; }
105 
108  uint8_t getDisplay() const { return m_display; }
109 
112  void setRenderDriverName(const std::string driver) { m_renderDriver = driver; }
113 
116  const std::string& getRenderDriverName() const { return m_renderDriver; }
117 
120  void setRenderDriverIndex(int8_t index) { m_renderDriverIndex = index; }
121 
124  int8_t getRenderDriverIndex() const { return m_renderDriverIndex; }
125 
126  //OpenGL, windowed
127  static const uint32_t WINDOWED_OPENGL = SDL_WINDOW_OPENGL;
128  //OpenGL, fullscreen
129  static const uint32_t FULLSCREEN_OPENGL = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN;
130  //SDL, windowed
131  static const uint32_t WINDOWED_SDL = 0;
132  //SDL, fullscreen
133  static const uint32_t FULLSCREEN_SDL = SDL_WINDOW_FULLSCREEN;
134 
135  private:
143  std::string m_renderDriver;
145  }; //ScreenMode
146 
147  class DeviceCaps {
148  public:
151  DeviceCaps();
152 
155  ~DeviceCaps();
156 
159  void fillDeviceCaps();
160 
163  void reset();
164 
167  std::vector<std::string> getAvailableVideoDrivers() const { return m_availableVideoDrivers; };
168 
171  std::vector<std::string> getAvailableRenderDrivers() const { return m_availableRenderDrivers; };
172 
175  std::vector<ScreenMode> getSupportedScreenModes() const { return m_screenModes; };
176 
179  ScreenMode getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string& renderer, bool fs) const;
180 
183  ScreenMode getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string& renderer, bool fs, uint16_t refresh, uint8_t display = 0) const;
184 
187  std::string getVideoDriverName() const { return m_videoDriverName; }
188 
191  void setVideoDriverName(const std::string& driver) { m_videoDriverName = driver; }
192 
196  std::string getRenderDriverName() const { return m_renderDriverName; }
197 
200  void setRenderDriverName(const std::string& driver);
201 
204  uint8_t getDisplayCount() const;
205 
208  std::string getDisplayName(uint8_t display = 0) const;
209 
212  uint32_t getDesktopFormat(uint8_t display = 0) const;
213 
216  int32_t getDesktopRefreshRate(uint8_t display = 0) const;
217 
220  int32_t getDesktopWidth(uint8_t display = 0) const;
221 
224  int32_t getDesktopHeight(uint8_t display = 0) const;
225 
228  Rect getDisplayBounds(uint8_t display = 0) const;
229 
230  private:
231  std::vector<ScreenMode> m_screenModes;
232  std::string m_videoDriverName;
233  std::vector<std::string> m_availableVideoDrivers;
234 
235  std::string m_renderDriverName;
237  std::vector<std::string> m_availableRenderDrivers;
238 
241  void fillAvailableDrivers();
242  }; //DeviceCaps
243 } //FIFE
244 
245 
246 
247 #endif //FIFE_DEVICECAPS_H
uint8_t m_display
Definition: devicecaps.h:142
std::vector< std::string > m_availableVideoDrivers
Definition: devicecaps.h:233
std::vector< std::string > getAvailableVideoDrivers() const
Gets the available video drivers for your operating system.
Definition: devicecaps.h:167
std::string m_renderDriverName
Definition: devicecaps.h:235
~ScreenMode()
Destructor.
Definition: devicecaps.h:54
void setVideoDriverName(const std::string &driver)
Sets the name of the video driver.
Definition: devicecaps.h:191
uint16_t m_bpp
Definition: devicecaps.h:138
std::string getVideoDriverName() const
Returns the name of the current video driver.
Definition: devicecaps.h:187
std::vector< ScreenMode > getSupportedScreenModes() const
Returns a vector containing screen modes.
Definition: devicecaps.h:175
uint8_t getDisplay() const
Returns the display index.
Definition: devicecaps.h:108
std::string m_videoDriverName
Definition: devicecaps.h:232
uint32_t getSDLFlags() const
Returns the SDL flags used when testing this mode.
Definition: devicecaps.h:80
uint32_t m_SDLFlags
Definition: devicecaps.h:140
bool isSDL() const
Is this screen mode an SDL only screen mode.
Definition: devicecaps.h:92
uint16_t getBPP() const
Returns the number of bits per pixel this mode uses.
Definition: devicecaps.h:72
bool isOpenGL() const
True if this mode uses the OpenGL renderer.
Definition: devicecaps.h:88
void setFormat(uint32_t format)
Sets the pixel format enum.
Definition: devicecaps.h:96
void setRenderDriverName(const std::string driver)
Sets the render driver name.
Definition: devicecaps.h:112
bool operator<(const ScreenMode &rhs) const
Definition: devicecaps.cpp:67
int8_t getRenderDriverIndex() const
Returns the index of the render driver.
Definition: devicecaps.h:124
bool isFullScreen() const
True if this is a fullscreen mode.
Definition: devicecaps.h:84
static const uint32_t WINDOWED_OPENGL
Definition: devicecaps.h:127
unsigned char uint8_t
Definition: core.h:38
ScreenMode()
Default Constructor.
Definition: devicecaps.cpp:40
static const uint32_t FULLSCREEN_SDL
Definition: devicecaps.h:133
uint32_t getFormat() const
Returns the pixel format enum.
Definition: devicecaps.h:100
uint16_t m_width
Definition: devicecaps.h:136
std::string getRenderDriverName() const
Returns the name of the current render driver or an empty string to initialize the first one supporti...
Definition: devicecaps.h:196
uint16_t getRefreshRate() const
Returns the refresh rate in Hz of this mode.
Definition: devicecaps.h:76
int8_t m_renderDriverIndex
Definition: devicecaps.h:236
uint16_t getHeight() const
Returns the height of the screen mode.
Definition: devicecaps.h:68
unsigned short uint16_t
Definition: core.h:39
uint16_t getWidth() const
Returns the width of the screen mode.
Definition: devicecaps.h:62
uint16_t m_refreshRate
Definition: devicecaps.h:139
static const uint32_t FULLSCREEN_OPENGL
Definition: devicecaps.h:129
int8_t m_renderDriverIndex
Definition: devicecaps.h:144
static const uint32_t WINDOWED_SDL
Definition: devicecaps.h:131
void setDisplay(uint8_t display)
Sets the display index.
Definition: devicecaps.h:104
std::string m_renderDriver
Definition: devicecaps.h:143
uint32_t m_format
Definition: devicecaps.h:141
void setRenderDriverIndex(int8_t index)
Sets the index of the render driver used by SDL.
Definition: devicecaps.h:120
uint16_t m_height
Definition: devicecaps.h:137
const std::string & getRenderDriverName() const
Returns the render driver name.
Definition: devicecaps.h:116
unsigned int uint32_t
Definition: core.h:40
std::vector< ScreenMode > m_screenModes
Definition: devicecaps.h:231
std::vector< std::string > getAvailableRenderDrivers() const
Gets the available render drivers for your operating system.
Definition: devicecaps.h:171
std::vector< std::string > m_availableRenderDrivers
Definition: devicecaps.h:237