OpenTTD

video_driver.hpp
Go to the documentation of this file.
1 /* $Id: video_driver.hpp 27775 2017-03-11 13:05:54Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #ifndef VIDEO_VIDEO_DRIVER_HPP
13 #define VIDEO_VIDEO_DRIVER_HPP
14
15 #include "../driver.h"
16 #include "../core/geometry_type.hpp"
17
19 class VideoDriver : public Driver {
20 public:
28 virtual void MakeDirty(int left, int top, int width, int height) = 0;
29
33 virtual void MainLoop() = 0;
34
41 virtual bool ChangeResolution(int w, int h) = 0;
42
48 virtual bool ToggleFullscreen(bool fullscreen) = 0;
49
55 virtual bool AfterBlitterChange()
56 {
57 return true;
58 }
59
64 virtual void AcquireBlitterLock() { }
65
70 virtual void ReleaseBlitterLock() { }
71
72 virtual bool ClaimMousePointer()
73 {
74 return true;
75 }
76
85 virtual bool HasGUI() const
86 {
87 return true;
88 }
89
93 virtual void EditBoxLostFocus() {}
94
98 static VideoDriver *GetInstance() {
99 return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
100 }
101 };
102
103 extern char *_ini_videodriver;
104 extern int _num_resolutions;
105 extern Dimension _resolutions[32];
106 extern Dimension _cur_resolution;
107 extern bool _rightclick_emulate;
108
109 #endif /* VIDEO_VIDEO_DRIVER_HPP */
VideoDriver::MakeDirty
virtual void MakeDirty(int left, int top, int width, int height)=0
Mark a particular area dirty.
VideoDriver::ReleaseBlitterLock
virtual void ReleaseBlitterLock()
Release any lock(s) required to be held when changing blitters.
Definition: video_driver.hpp:70
VideoDriver::HasGUI
virtual bool HasGUI() const
Whether the driver has a graphical user interface with the end user.
Definition: video_driver.hpp:85
DriverFactoryBase::GetActiveDriver
static Driver ** GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
Definition: driver.h:87
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition: driver.cpp:24
VideoDriver::ToggleFullscreen
virtual bool ToggleFullscreen(bool fullscreen)=0
Change the full screen setting.
_num_resolutions
int _num_resolutions
The number of resolutions.
Definition: driver.cpp:22
_resolutions
Dimension _resolutions[32]
List of resolutions.
Definition: driver.cpp:23
VideoDriver::ChangeResolution
virtual bool ChangeResolution(int w, int h)=0
Change the resolution of the window.
_ini_videodriver
char * _ini_videodriver
The video driver a stored in the configuration file.
Definition: driver.cpp:21
VideoDriver::AcquireBlitterLock
virtual void AcquireBlitterLock()
Acquire any lock(s) required to be held when changing blitters.
Definition: video_driver.hpp:64
Driver
A driver for communicating with the user.
Definition: driver.h:24
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:98
_rightclick_emulate
bool _rightclick_emulate
Whether right clicking is emulated.
Definition: driver.cpp:25
VideoDriver::MainLoop
virtual void MainLoop()=0
Perform the actual drawing.
VideoDriver
The base of all video drivers.
Definition: video_driver.hpp:19
VideoDriver::EditBoxLostFocus
virtual void EditBoxLostFocus()
An edit box lost the input focus.
Definition: video_driver.hpp:93
VideoDriver::AfterBlitterChange
virtual bool AfterBlitterChange()
Callback invoked after the blitter was changed.
Definition: video_driver.hpp:55
Driver::DT_VIDEO
A video driver.
Definition: driver.h:45
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:34