2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 /** @file video_driver.hpp Base of all video drivers. */
10 #ifndef VIDEO_VIDEO_DRIVER_HPP
11 #define VIDEO_VIDEO_DRIVER_HPP
13 #include "../driver.h"
14 #include "../core/geometry_type.hpp"
17 /** The base of all video drivers. */
18 class VideoDriver
: public Driver
{
21 * Mark a particular area dirty.
22 * @param left The left most line of the dirty area.
23 * @param top The top most line of the dirty area.
24 * @param width The width of the dirty area.
25 * @param height The height of the dirty area.
27 virtual void MakeDirty(int left
, int top
, int width
, int height
) = 0;
30 * Perform the actual drawing.
32 virtual void MainLoop() = 0;
35 * Change the resolution of the window.
36 * @param w The new width.
37 * @param h The new height.
38 * @return True if the change succeeded.
40 virtual bool ChangeResolution(int w
, int h
) = 0;
43 * Change the full screen setting.
44 * @param fullscreen The new setting.
45 * @return True if the change succeeded.
47 virtual bool ToggleFullscreen(bool fullscreen
) = 0;
50 * Callback invoked after the blitter was changed.
51 * This may only be called between AcquireBlitterLock and ReleaseBlitterLock.
52 * @return True if no error.
54 virtual bool AfterBlitterChange()
60 * Acquire any lock(s) required to be held when changing blitters.
61 * These lock(s) may not be acquired recursively.
63 virtual void AcquireBlitterLock() { }
66 * Release any lock(s) required to be held when changing blitters.
67 * These lock(s) may not be acquired recursively.
69 virtual void ReleaseBlitterLock() { }
71 virtual bool ClaimMousePointer()
77 * Whether the driver has a graphical user interface with the end user.
78 * Or in other words, whether we should spawn a thread for world generation
79 * and NewGRF scanning so the graphical updates can keep coming. Otherwise
80 * progress has to be shown on the console, which uses by definition another
81 * thread/process for display purposes.
82 * @return True for all drivers except null and dedicated.
84 virtual bool HasGUI() const
90 * An edit box lost the input focus. Abort character compositing if necessary.
92 virtual void EditBoxLostFocus() {}
95 * An edit box gained the input focus
97 virtual void EditBoxGainedFocus() {}
100 * Get the currently active instance of the video driver.
102 static VideoDriver
*GetInstance() {
103 return static_cast<VideoDriver
*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO
));
107 extern char *_ini_videodriver
;
108 extern std::vector
<Dimension
> _resolutions
;
109 extern Dimension _cur_resolution
;
110 extern bool _rightclick_emulate
;
112 #endif /* VIDEO_VIDEO_DRIVER_HPP */