FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
devicecaps.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 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 
38 namespace FIFE {
39 
40  class ScreenMode {
41  public:
46  ScreenMode();
47  ScreenMode(uint16_t width, uint16_t height, uint16_t bpp, uint32_t SDLFlags);
48  ScreenMode(const ScreenMode& rhs);
49 
53 
54  bool operator <(const ScreenMode& rhs) const;
55 
60  uint16_t getWidth() const { return m_width; };
61 
66  uint16_t getHeight() const { return m_height; };
67 
70  uint16_t getBPP() const { return m_bpp; };
71 
74  uint32_t getSDLFlags() const { return m_SDLFlags; };
75 
78  bool isFullScreen() const { return (m_SDLFlags & SDL_FULLSCREEN) ? true : false;};
79 
82  bool isOpenGL() const { return (m_SDLFlags & SDL_OPENGL) ? true : false; };
83 
86  bool isSDL() const { return (!(m_SDLFlags & SDL_OPENGL)) ? true : false; };
87 
90  bool isSDLHardwareSurface() const { return (m_SDLFlags & SDL_HWSURFACE) ? true : false; };
91 
92 
93  //OpenGL, windowed, hw accel
94  static const uint32_t HW_WINDOWED_OPENGL = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL;
95  //OpenGL, fullscreen, hw accel
96  static const uint32_t HW_FULLSCREEN_OPENGL = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL | SDL_FULLSCREEN;
97  //SDL, windowed
98  static const uint32_t WINDOWED_SDL = 0;
99  //SDL, windowed, HW surface and double buffer
100  static const uint32_t WINDOWED_SDL_DB_HW = SDL_HWSURFACE | SDL_DOUBLEBUF;
101  //SDL, fullscreen
102  static const uint32_t FULLSCREEN_SDL = SDL_FULLSCREEN;
103  //SDL, fullscreen, HW surface and double buffer
104  static const uint32_t FULLSCREEN_SDL_DB_HW = SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF;
105 
106  private:
111 
112  }; //ScreenMode
113 
114  class DeviceCaps {
115  public:
118  DeviceCaps();
119 
122  ~DeviceCaps();
123 
126  void fillDeviceCaps();
127 
130  void reset();
131 
134  std::vector<std::string> getAvailableDrivers() const { return m_availableDrivers; };
135 
138  std::vector<ScreenMode> getSupportedScreenModes() const { return m_screenModes; };
139 
142  ScreenMode getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string& renderer, bool fs) const;
143 
146  std::string getDriverName() const { return m_driverName; };
147 
150  bool isHwSurfaceAvail() const { return m_hwAvailable; };
151 
154  bool isWindowManagerAvail() const { return m_wmAvailable;} ;
155 
158  bool isHwBlitAccel() const { return m_hwBlitAccel; };
159 
162  bool isHwColorkeyBlitAccel() const { return m_hwCCBlitAccel; };
163 
166  bool isHwAlphaBlitAccel() const { return m_hwToHwAlphaBlitAccel; };
167 
170  bool isSwToHwBlitAccel() const { return m_swToHwBlitAccel; };
171 
175 
179 
182  bool isBlitFillAccel() const { return m_BlitFillAccel; };
183 
186  uint32_t getVideoMemory() const { return m_videoMem; };
187 
190  int32_t getDesktopWidth() const;
191 
194  int32_t getDesktopHeight() const;
195 
196  private:
197  std::vector<ScreenMode> m_screenModes;
198  std::string m_driverName;
199  std::vector<std::string> m_availableDrivers;
200 
210 
212  int32_t m_desktopWidth;
214 
217  void fillAvailableDrivers();
218  }; //DeviceCaps
219 } //FIFE
220 
221 
222 
223 #endif //FIFE_DEVICECAPS_H
uint32_t getVideoMemory() const
Total amount of video memory in Kilobytes, only valid if hardware sufaces are available.
Definition: devicecaps.h:186
~ScreenMode()
Destructor.
Definition: devicecaps.h:52
bool m_swToHwBlitAccel
Definition: devicecaps.h:206
uint16_t m_bpp
Definition: devicecaps.h:109
bool isSwToHwAlphaBlitAccel() const
Are software to hardware alpha blits accelerated ?
Definition: devicecaps.h:178
static const uint32_t HW_WINDOWED_OPENGL
Definition: devicecaps.h:94
std::vector< ScreenMode > getSupportedScreenModes() const
Returns a vector containing screen modes.
Definition: devicecaps.h:138
int32_t getDesktopHeight() const
Returns the height of the desktop resolution.
Definition: devicecaps.cpp:353
uint32_t getSDLFlags() const
Returns the SDL flags used when testing this mode.
Definition: devicecaps.h:74
bool isWindowManagerAvail() const
Is there a window manager available ?
Definition: devicecaps.h:154
static const uint32_t FULLSCREEN_SDL_DB_HW
Definition: devicecaps.h:104
std::vector< std::string > m_availableDrivers
Definition: devicecaps.h:199
uint32_t m_SDLFlags
Definition: devicecaps.h:110
std::string m_driverName
Definition: devicecaps.h:198
bool isSDL() const
Is this screen mode an SDL only screen mode.
Definition: devicecaps.h:86
bool m_swToHwCCBlistAccel
Definition: devicecaps.h:207
uint16_t getBPP() const
Returns the number of bits per pixel this mode uses.
Definition: devicecaps.h:70
bool isSDLHardwareSurface() const
Returns true if this is a SDL screen mode with the SDL hardware surface enabled.
Definition: devicecaps.h:90
bool isOpenGL() const
True if this mode uses the OpenGL renderer.
Definition: devicecaps.h:82
bool operator<(const ScreenMode &rhs) const
Definition: devicecaps.cpp:55
ScreenMode getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string &renderer, bool fs) const
Gets the nearest valid screen mode based on the arguments passed.
Definition: devicecaps.cpp:277
void fillAvailableDrivers()
Called in the constructor.
Definition: devicecaps.cpp:130
bool isFullScreen() const
True if this is a fullscreen mode.
Definition: devicecaps.h:78
bool isSwToHwColorkeyBlitAccel() const
Are software to hardware colorkey blits accelerated ?
Definition: devicecaps.h:174
ScreenMode()
Default Constructor.
Definition: devicecaps.cpp:40
static const uint32_t FULLSCREEN_SDL
Definition: devicecaps.h:102
int32_t m_desktopHeight
Definition: devicecaps.h:213
static const uint32_t HW_FULLSCREEN_OPENGL
Definition: devicecaps.h:96
uint16_t m_width
Definition: devicecaps.h:107
std::vector< std::string > getAvailableDrivers() const
Gets the available graphics drivers for your operating system.
Definition: devicecaps.h:134
void reset()
Clears all information gathered for the device.
Definition: devicecaps.cpp:112
std::string getDriverName() const
Returns the name of the current video driver.
Definition: devicecaps.h:146
int32_t m_desktopWidth
Definition: devicecaps.h:212
uint16_t getHeight() const
Returns the height of the screen mode.
Definition: devicecaps.h:66
bool m_hwToHwAlphaBlitAccel
Definition: devicecaps.h:205
bool isBlitFillAccel() const
Are color fills accelerated ?
Definition: devicecaps.h:182
unsigned short uint16_t
Definition: core.h:39
uint16_t getWidth() const
Returns the width of the screen mode.
Definition: devicecaps.h:60
uint32_t m_videoMem
Definition: devicecaps.h:211
static const uint32_t WINDOWED_SDL_DB_HW
Definition: devicecaps.h:100
int32_t getDesktopWidth() const
Returns the width of the desktop resolution.
Definition: devicecaps.cpp:349
void fillDeviceCaps()
Should be called AFTER SDL_Init() has been called.
Definition: devicecaps.cpp:154
static const uint32_t WINDOWED_SDL
Definition: devicecaps.h:98
bool isHwAlphaBlitAccel() const
Are hardware to hardware alpha blits accelerated ?
Definition: devicecaps.h:166
bool isSwToHwBlitAccel() const
Are software to hardware blits accelerated ?
Definition: devicecaps.h:170
bool isHwSurfaceAvail() const
Is it possible to create hardware surfaces ?
Definition: devicecaps.h:150
uint16_t m_height
Definition: devicecaps.h:108
unsigned int uint32_t
Definition: core.h:40
bool isHwBlitAccel() const
Are hardware to hardware blits accelerated ?
Definition: devicecaps.h:158
std::vector< ScreenMode > m_screenModes
Definition: devicecaps.h:197
bool isHwColorkeyBlitAccel() const
Are hardware to hardware colorkey blits accelerated ?
Definition: devicecaps.h:162
bool m_swToHwAlphaBlitAccel
Definition: devicecaps.h:208
~DeviceCaps()
Destructor.
Definition: devicecaps.cpp:109
DeviceCaps()
Constructor.
Definition: devicecaps.cpp:90