2007-07-05 14:23:54 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 17:11:33 +02:00
|
|
|
/** @file video_driver.hpp Base of all video drivers. */
|
|
|
|
|
2007-07-05 14:23:54 +02:00
|
|
|
#ifndef VIDEO_VIDEO_DRIVER_HPP
|
|
|
|
#define VIDEO_VIDEO_DRIVER_HPP
|
|
|
|
|
|
|
|
#include "../driver.h"
|
2008-06-16 21:38:41 +02:00
|
|
|
#include "../core/geometry_type.hpp"
|
2007-07-05 14:23:54 +02:00
|
|
|
|
2011-05-02 18:14:23 +02:00
|
|
|
/** The base of all video drivers. */
|
2007-07-05 14:23:54 +02:00
|
|
|
class VideoDriver: public Driver {
|
|
|
|
public:
|
2011-05-02 18:14:23 +02:00
|
|
|
/**
|
|
|
|
* Mark a particular area dirty.
|
|
|
|
* @param left The left most line of the dirty area.
|
|
|
|
* @param top The top most line of the dirty area.
|
|
|
|
* @param width The width of the dirty area.
|
|
|
|
* @param height The height of the dirty area.
|
|
|
|
*/
|
2007-07-05 14:23:54 +02:00
|
|
|
virtual void MakeDirty(int left, int top, int width, int height) = 0;
|
|
|
|
|
2011-05-02 18:14:23 +02:00
|
|
|
/**
|
|
|
|
* Perform the actual drawing.
|
|
|
|
*/
|
2007-07-05 14:23:54 +02:00
|
|
|
virtual void MainLoop() = 0;
|
|
|
|
|
2011-05-02 18:14:23 +02:00
|
|
|
/**
|
|
|
|
* Change the resolution of the window.
|
|
|
|
* @param w The new width.
|
|
|
|
* @param h The new height.
|
|
|
|
* @return True if the change succeeded.
|
|
|
|
*/
|
2007-07-05 14:23:54 +02:00
|
|
|
virtual bool ChangeResolution(int w, int h) = 0;
|
|
|
|
|
2011-05-02 18:14:23 +02:00
|
|
|
/**
|
|
|
|
* Change the full screen setting.
|
|
|
|
* @param fullscreen The new setting.
|
|
|
|
* @return True if the change succeeded.
|
|
|
|
*/
|
2008-01-01 15:20:48 +01:00
|
|
|
virtual bool ToggleFullscreen(bool fullscreen) = 0;
|
2011-08-24 14:11:10 +02:00
|
|
|
|
2011-10-04 23:35:40 +02:00
|
|
|
/**
|
|
|
|
* Callback invoked after the blitter was changed.
|
|
|
|
* @return True if no error.
|
|
|
|
*/
|
|
|
|
virtual bool AfterBlitterChange()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-17 22:09:08 +01:00
|
|
|
virtual bool ClaimMousePointer()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-08-24 14:11:10 +02:00
|
|
|
/**
|
|
|
|
* Whether the driver has a graphical user interface with the end user.
|
|
|
|
* Or in other words, whether we should spawn a thread for world generation
|
|
|
|
* and NewGRF scanning so the graphical updates can keep coming. Otherwise
|
|
|
|
* progress has to be shown on the console, which uses by definition another
|
|
|
|
* thread/process for display purposes.
|
|
|
|
* @return True for all drivers except null and dedicated.
|
|
|
|
*/
|
|
|
|
virtual bool HasGUI() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2007-07-05 14:23:54 +02:00
|
|
|
};
|
|
|
|
|
2011-05-02 18:14:23 +02:00
|
|
|
/** Base of the factory for the video drivers. */
|
2007-07-05 14:23:54 +02:00
|
|
|
class VideoDriverFactoryBase: public DriverFactoryBase {
|
|
|
|
};
|
|
|
|
|
2011-05-02 18:14:23 +02:00
|
|
|
/**
|
|
|
|
* Factory for the video drivers.
|
|
|
|
* @tparam T The type of the video factory to register.
|
|
|
|
*/
|
2007-07-05 14:23:54 +02:00
|
|
|
template <class T>
|
|
|
|
class VideoDriverFactory: public VideoDriverFactoryBase {
|
|
|
|
public:
|
2007-07-07 22:31:23 +02:00
|
|
|
VideoDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_VIDEO, ((T *)this)->priority); }
|
2007-07-05 14:23:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the long, human readable, name for the Driver-class.
|
|
|
|
*/
|
|
|
|
const char *GetName();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern VideoDriver *_video_driver;
|
2009-01-08 12:06:07 +01:00
|
|
|
extern char *_ini_videodriver;
|
2008-01-13 22:41:24 +01:00
|
|
|
extern int _num_resolutions;
|
2008-06-16 21:38:41 +02:00
|
|
|
extern Dimension _resolutions[32];
|
|
|
|
extern Dimension _cur_resolution;
|
2010-07-19 18:21:49 +02:00
|
|
|
extern bool _rightclick_emulate;
|
2007-07-05 14:23:54 +02:00
|
|
|
|
|
|
|
#endif /* VIDEO_VIDEO_DRIVER_HPP */
|