|
OpenTTD Source
1.11.0-RC1
|
Go to the documentation of this file.
10 #ifndef VIDEO_VIDEO_DRIVER_HPP
11 #define VIDEO_VIDEO_DRIVER_HPP
13 #include "../driver.h"
14 #include "../core/geometry_type.hpp"
15 #include "../core/math_func.hpp"
16 #include "../gfx_func.h"
17 #include "../settings_type.h"
18 #include "../zoom_type.h"
21 #include <condition_variable>
47 virtual void MakeDirty(
int left,
int top,
int width,
int height) = 0;
78 virtual bool ClaimMousePointer()
295 std::chrono::steady_clock::duration GetGameInterval()
300 if (
_game_speed == 0)
return std::chrono::microseconds(0);
305 std::chrono::steady_clock::duration GetDrawInterval()
310 std::chrono::steady_clock::time_point next_game_tick;
311 std::chrono::steady_clock::time_point next_draw_tick;
316 bool is_game_threaded;
317 std::thread game_thread;
318 std::mutex game_state_mutex;
319 std::mutex game_thread_wait_mutex;
326 void RealChangeBlitter(
const char *repl_blitter);
void Tick()
Give the video-driver a tick.
uint16 refresh_rate
How often we refresh the screen (time between draw-ticks).
virtual bool HasAnimBuffer()
Does this video driver support a separate animation buffer in addition to the colour buffer?
@ ZOOM_LVL_OUT_2X
Zoomed 2 times out.
static Driver ** GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
The base of all video drivers.
Dimensions (a width and height) of a rectangle in 2D.
virtual void CheckPaletteAnim()
Process any pending palette animation.
void ChangeBlitter(const char *new_blitter)
Queue a request to change the blitter.
virtual void MakeDirty(int left, int top, int width, int height)=0
Mark a particular area dirty.
virtual bool ToggleFullscreen(bool fullscreen)=0
Change the full screen setting.
Dimension _cur_resolution
The current resolution.
static uint ClampU(const uint a, const uint min, const uint max)
Clamp an unsigned integer between an interval.
ZoomLevel
All zoom levels we know.
ClientSettings _settings_client
The current settings for this game.
virtual bool HasGUI() const
Whether the driver has a graphical user interface with the end user.
void StartGameThread()
Start the loop for game-tick.
virtual ZoomLevel GetSuggestedUIZoom()
Get a suggested default GUI zoom taking screen DPI into account.
virtual void ClearSystemSprites()
Clear all cached sprites.
virtual float GetDPIScale()
Get DPI scaling factor of the screen OTTD is displayed on.
const uint DEFAULT_WINDOW_HEIGHT
Default window height.
virtual void InputLoop()
Handle input logic, is CTRL pressed, should we fast-forward, etc.
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
virtual void Paint()
Paint the window.
bool _rightclick_emulate
Whether right clicking is emulated.
const uint ALLOWED_DRIFT
How many times videodriver can miss deadlines without it being overly compensated.
PauseMode _pause_mode
The current pause mode.
virtual bool ChangeResolution(int w, int h)=0
Change the resolution of the window.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
virtual void UnlockVideoBuffer()
Unlock a previously locked video buffer.
virtual uint8 * GetAnimBuffer()
Get a pointer to the animation buffer of the video back-end.
virtual bool UseSystemCursor()
Get whether the mouse cursor is drawn by the video driver.
void GameLoopPause()
Pause the game-loop for a bit, releasing the game-state lock.
void StopGameThread()
Stop the loop for the game-tick.
virtual void PopulateSystemSprites()
Populate all sprites in cache.
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
@ DT_VIDEO
A video driver.
bool unlock
Stores if the lock did anything that has to be undone.
std::string _ini_videodriver
The video driver a stored in the configuration file.
bool fast_forward_via_key
The fast-forward was enabled by key press.
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
static const uint MILLISECONDS_PER_TICK
The number of milliseconds per game tick.
void SleepTillNextTick()
Sleep till the next tick is about to happen.
virtual void MainLoop()=0
Perform the actual drawing.
bool fast_forward_key_pressed
The fast-forward key is being pressed.
virtual bool HasEfficient8Bpp() const
Has this video driver an efficient code path for palette animated 8-bpp sprites?
const char * change_blitter
Request to change the blitter. nullptr if no pending request.
virtual bool LockVideoBuffer()
Make sure the video buffer is ready for drawing.
@ ZOOM_LVL_NORMAL
The normal zoom level.
virtual void EditBoxLostFocus()
An edit box lost the input focus.
const uint DEFAULT_WINDOW_WIDTH
Default window width.
A driver for communicating with the user.
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
std::vector< Dimension > _resolutions
List of resolutions.
virtual bool PollEvent()
Process a single system event.
Helper struct to ensure the video buffer is locked and ready for drawing.
uint16 _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
GUISettings gui
settings related to the GUI
virtual Dimension GetScreenSize() const
Get the resolution of the main screen.
virtual void EditBoxGainedFocus()
An edit box gained the input focus.
virtual bool AfterBlitterChange()
Callback invoked after the blitter was changed.