FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
devicecaps.h
1 /***************************************************************************
2  * Copyright (C) 2005-2010 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 
52  ~ScreenMode() {};
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:
107  uint16_t m_width;
108  uint16_t m_height;
109  uint16_t m_bpp;
110  uint32_t m_SDLFlags;
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 
174  bool isSwToHwColorkeyBlitAccel() const { return m_swToHwCCBlistAccel; };
175 
178  bool isSwToHwAlphaBlitAccel() const { return m_swToHwAlphaBlitAccel; };
179 
182  bool isBlitFillAccel() const { return m_BlitFillAccel; };
183 
186  uint32_t getVideoMemory() const { return m_videoMem; };
187 
188  private:
189  std::vector<ScreenMode> m_screenModes;
190  std::string m_driverName;
191  std::vector<std::string> m_availableDrivers;
192 
193  bool m_hwAvailable;
194  bool m_wmAvailable;
195  bool m_hwBlitAccel;
196  bool m_hwCCBlitAccel;
197  bool m_hwToHwAlphaBlitAccel;
198  bool m_swToHwBlitAccel;
199  bool m_swToHwCCBlistAccel;
200  bool m_swToHwAlphaBlitAccel;
201  bool m_BlitFillAccel;
202 
203  uint32_t m_videoMem;
204 
207  void fillAvailableDrivers();
208  }; //DeviceCaps
209 } //FIFE
210 
211 
212 
213 #endif //FIFE_DEVICECAPS_H