xoreos  0.0.5
windowman.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_WINDOWMAN_H
26 #define GRAPHICS_WINDOWMAN_H
27 
28 #include "src/common/singleton.h"
29 #include "src/common/mutex.h"
30 #include "src/common/ustring.h"
31 
32 #include "src/graphics/types.h"
33 
34 namespace Graphics {
35 
36 typedef SDL_DisplayMode DisplayMode;
37 
39 class WindowManager : public Common::Singleton<WindowManager> {
40 public:
41  enum RenderType {
42  kOpenGL21 = 0,
45  };
46 
47  WindowManager();
49 
51  void init();
53  void deinit();
54 
56  bool initRender(RenderType type, bool useDebug, int fsaa);
57 
59  bool isFullScreen() const;
61  void setFullScreen(bool fullScreen);
63  void toggleFullScreen();
64 
66  int getWindowWidth() const;
68  int getWindowHeight() const;
70  void setWindowSize(int width, int height);
71 
73  std::vector<DisplayMode> getDisplayModes();
74 
76  int getSystemWidth() const;
78  int getSystemHeight() const;
79 
81  int getMaxFSAA() const;
82 
84  void toggleMouseGrab();
85 
87  void setWindowTitle(const Common::UString &title = "");
88 
90  float getGamma() const;
92  void setGamma(float gamma);
93 
95  void showCursor(bool show);
97  void setCursorPosition(int x, int y);
98 
99  void beginScene();
100  void endScene();
101 private:
102  enum CursorState {
106  };
107 
108  bool _fullScreen;
109 
110  int _fsaaMax;
111 
112  int _width;
113  int _height;
114 
115  float _gamma;
116 
118 
119  SDL_Window *_window;
120  SDL_GLContext _glContext;
121 
124 
126  void initWindow(uint32 flags);
127  void deinitWindow();
128 
129  void probeFSAA();
130 
131  void handleCursorSwitch();
132 };
133 
134 } // End of namespace Graphics
135 
137 #define WindowMan Graphics::WindowManager::instance()
138 
139 #endif // GRAPHICS_WINDOWMAN_H
int getWindowHeight() const
Return the current window height.
Definition: windowman.cpp:189
void showCursor(bool show)
Show/Hide the cursor.
Definition: windowman.cpp:396
Class and macro for implementing singletons.
Common::UString _windowTitle
The current window title.
Definition: windowman.h:117
A class holding an UTF-8 string.
Definition: ustring.h:48
int _width
The game&#39;s window width.
Definition: windowman.h:112
int getSystemHeight() const
Return the system&#39;s screen height.
Definition: windowman.cpp:256
void deinit()
Deinitialize the window manager.
Definition: windowman.cpp:85
SDL_Window * _window
The OpenGL hardware surface.
Definition: windowman.h:119
int getSystemWidth() const
Return the system&#39;s screen width.
Definition: windowman.cpp:247
int _fsaaMax
Max supported FSAA level.
Definition: windowman.h:110
Basic graphics types.
The graphics manager.
Definition: windowman.h:39
void setWindowSize(int width, int height)
Set the window size.
Definition: windowman.cpp:193
bool initRender(RenderType type, bool useDebug, int fsaa)
Setup the Render Context on the window.
Definition: windowman.cpp:89
void init()
Initialize the window manager.
Definition: windowman.cpp:67
Common::Mutex _cursorMutex
A mutex locked for the cursor.
Definition: windowman.h:122
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
A mutex.
Definition: mutex.h:40
CursorState _cursorState
What to do with the cursor.
Definition: windowman.h:123
float getGamma() const
Get the overall gamma correction.
Definition: windowman.cpp:339
int getWindowWidth() const
Return the current window width.
Definition: windowman.cpp:185
int getMaxFSAA() const
Return the max supported FSAA level.
Definition: windowman.cpp:265
int _height
The game&#39;s window height.
Definition: windowman.h:113
void setWindowTitle(const Common::UString &title="")
Set the window&#39;s title.
Definition: windowman.cpp:331
void initWindow(uint32 flags)
Definition: windowman.cpp:279
bool isFullScreen() const
Are we currently in full screen mode?
Definition: windowman.cpp:142
SDL_GLContext _glContext
Definition: windowman.h:120
void setFullScreen(bool fullScreen)
Set full screen/windowed mode.
Definition: windowman.cpp:146
Unicode string handling.
Thread mutex classes.
bool _fullScreen
Are we currently in fullscreen mode?
Definition: windowman.h:108
uint32_t uint32
Definition: types.h:204
SDL_DisplayMode DisplayMode
Definition: windowman.h:36
void toggleMouseGrab()
Toggle mouse grab.
Definition: windowman.cpp:392
void toggleFullScreen()
Toggle between full screen and windowed mode.
Definition: windowman.cpp:181
float _gamma
The current gamma correction value.
Definition: windowman.h:115
std::vector< DisplayMode > getDisplayModes()
Get all possible display modes.
Definition: windowman.cpp:230
void setCursorPosition(int x, int y)
Set position to the cursor.
Definition: windowman.cpp:365
void setGamma(float gamma)
Set the overall gamma correction.
Definition: windowman.cpp:343