Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VideoMode.h
Go to the documentation of this file.
1 /* Copyright (C) 2010 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_VIDEOMODE
19 #define INCLUDED_VIDEOMODE
20 
21 typedef struct SDL_Window SDL_Window;
22 
24 {
25 public:
26  CVideoMode();
27 
28  /**
29  * Initialise the video mode, for use in an SDL-using application.
30  */
31  bool InitSDL();
32 
33  /**
34  * Initialise parts of the video mode, for use in Atlas (which uses
35  * wxWidgets instead of SDL for GL).
36  * Currently this just tries to enable S3TC.
37  */
38  bool InitNonSDL();
39 
40  /**
41  * Shut down after InitSDL/InitNonSDL, so that they can be used again.
42  */
43  void Shutdown();
44 
45  /**
46  * Resize the SDL window and associated graphics stuff to the new size.
47  */
48  bool ResizeWindow(int w, int h);
49 
50  /**
51  * Switch to fullscreen or windowed mode.
52  */
53  bool SetFullscreen(bool fullscreen);
54 
55  /**
56  * Switch between fullscreen and windowed mode.
57  */
58  bool ToggleFullscreen();
59 
60  /**
61  * Update the graphics code to start drawing to the new size.
62  * This should be called after the GL context has been resized.
63  * This can also be used when the GL context is managed externally, not via SDL.
64  */
65  static void UpdateRenderer(int w, int h);
66 
67  int GetXRes();
68  int GetYRes();
69  int GetBPP();
70 
71  int GetDesktopXRes();
72  int GetDesktopYRes();
73  int GetDesktopBPP();
74  int GetDesktopFreq();
75 
77 
78 private:
79  void ReadConfig();
80  int GetBestBPP();
81  bool SetVideoMode(int w, int h, int bpp, bool fullscreen);
82  void EnableS3TC();
83 
84  /**
85  * Remember whether Init has been called. (This isn't used for anything
86  * important, just for verifying that the callers call our methods in
87  * the right order.)
88  */
90 
92 
93  // Initial desktop settings
98 
99  // Config file settings (0 if unspecified)
105 
106  // If we're fullscreen, size of window when we were last windowed (or the default window size
107  // if we started fullscreen), to support switching back to the old window size
110 
111  // Whether we're currently being displayed fullscreen
113 
114  // The last mode selected
118 };
119 
120 extern CVideoMode g_VideoMode;
121 
122 #endif // INCLUDED_VIDEOMODE
static bool fullscreen
Definition: wsdl.cpp:61
int m_CurrentH
Definition: VideoMode.h:116
int GetDesktopFreq()
Definition: VideoMode.cpp:500
bool SetVideoMode(int w, int h, int bpp, bool fullscreen)
Definition: VideoMode.cpp:66
int GetDesktopXRes()
Definition: VideoMode.cpp:482
int GetYRes()
Definition: VideoMode.cpp:470
bool ToggleFullscreen()
Switch between fullscreen and windowed mode.
Definition: VideoMode.cpp:424
bool m_ConfigFullscreen
Definition: VideoMode.h:103
CVideoMode g_VideoMode
Definition: VideoMode.cpp:42
bool ResizeWindow(int w, int h)
Resize the SDL window and associated graphics stuff to the new size.
Definition: VideoMode.cpp:338
int m_ConfigH
Definition: VideoMode.h:101
void Shutdown()
Shut down after InitSDL/InitNonSDL, so that they can be used again.
Definition: VideoMode.cpp:308
SDL_Window * GetWindow()
Definition: VideoMode.cpp:506
int m_PreferredH
Definition: VideoMode.h:95
int m_CurrentBPP
Definition: VideoMode.h:117
int m_ConfigW
Definition: VideoMode.h:100
int m_WindowedW
Definition: VideoMode.h:108
int m_PreferredW
Definition: VideoMode.h:94
static void UpdateRenderer(int w, int h)
Update the graphics code to start drawing to the new size.
Definition: VideoMode.cpp:429
bool InitNonSDL()
Initialise parts of the video mode, for use in Atlas (which uses wxWidgets instead of SDL for GL)...
Definition: VideoMode.cpp:295
int m_PreferredBPP
Definition: VideoMode.h:96
int m_WindowedH
Definition: VideoMode.h:109
struct SDL_Window SDL_Window
Definition: VideoMode.h:21
int m_CurrentW
Definition: VideoMode.h:115
int m_ConfigBPP
Definition: VideoMode.h:102
int m_PreferredFreq
Definition: VideoMode.h:97
bool m_IsInitialised
Remember whether Init has been called.
Definition: VideoMode.h:89
int GetDesktopYRes()
Definition: VideoMode.cpp:488
int GetDesktopBPP()
Definition: VideoMode.cpp:494
bool SetFullscreen(bool fullscreen)
Switch to fullscreen or windowed mode.
Definition: VideoMode.cpp:363
SDL_Window * m_Window
Definition: VideoMode.h:91
int GetBestBPP()
Definition: VideoMode.cpp:455
int GetXRes()
Definition: VideoMode.cpp:464
bool m_ConfigForceS3TCEnable
Definition: VideoMode.h:104
int GetBPP()
Definition: VideoMode.cpp:476
bool m_IsFullscreen
Definition: VideoMode.h:112
bool InitSDL()
Initialise the video mode, for use in an SDL-using application.
Definition: VideoMode.cpp:191
void ReadConfig()
Definition: VideoMode.cpp:54
void EnableS3TC()
Definition: VideoMode.cpp:316