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/>.
|
|
|
|
*/
|
|
|
|
|
2020-06-06 06:15:23 +02:00
|
|
|
/** @file null_v.cpp The video driver that doesn't blit. */
|
2008-05-06 17:11:33 +02:00
|
|
|
|
2005-07-25 09:16:10 +02:00
|
|
|
#include "../stdafx.h"
|
2007-12-23 11:56:02 +01:00
|
|
|
#include "../gfx_func.h"
|
2007-06-17 22:30:28 +02:00
|
|
|
#include "../blitter/factory.hpp"
|
2021-06-10 19:34:53 +02:00
|
|
|
#include "../saveload/saveload.h"
|
Add: draw the screen at a steady pace, also during fast-forward
During fast-forward, the game was drawing as fast as it could. This
means that the fast-forward was limited also by how fast we could
draw, something that people in general don't expect.
To give an extreme case, if you are fully zoomed out on a busy
map, fast-forward would be mostly limited because of the time it
takes to draw the screen.
By decoupling the draw-tick and game-tick, we can keep the pace
of the draw-tick the same while speeding up the game-tick. To use
the extreme case as example again, if you are fully zoomed out
now, the screen only redraws 33.33 times per second, fast-forwarding
or not. This means fast-forward is much more likely to go at the
same speed, no matter what you are looking at.
2021-02-17 15:04:46 +01:00
|
|
|
#include "../window_func.h"
|
2005-07-25 09:16:10 +02:00
|
|
|
#include "null_v.h"
|
2005-07-23 17:16:57 +02:00
|
|
|
|
2014-04-23 22:13:33 +02:00
|
|
|
#include "../safeguards.h"
|
|
|
|
|
2011-05-01 21:14:12 +02:00
|
|
|
/** Factory for the null video driver. */
|
2007-07-05 14:23:54 +02:00
|
|
|
static FVideoDriver_Null iFVideoDriver_Null;
|
|
|
|
|
2020-05-17 23:32:08 +02:00
|
|
|
const char *VideoDriver_Null::Start(const StringList &parm)
|
2005-07-23 17:16:57 +02:00
|
|
|
{
|
2011-11-05 00:47:00 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
/* Disable the MSVC assertion message box. */
|
|
|
|
_set_error_mode(_OUT_TO_STDERR);
|
|
|
|
#endif
|
|
|
|
|
2021-01-14 21:53:06 +01:00
|
|
|
this->UpdateAutoResolution();
|
|
|
|
|
2007-07-13 15:03:20 +02:00
|
|
|
this->ticks = GetDriverParamInt(parm, "ticks", 1000);
|
2008-06-16 21:38:41 +02:00
|
|
|
_screen.width = _screen.pitch = _cur_resolution.width;
|
|
|
|
_screen.height = _cur_resolution.height;
|
2019-04-10 23:07:06 +02:00
|
|
|
_screen.dst_ptr = nullptr;
|
2008-04-19 01:32:10 +02:00
|
|
|
ScreenSizeChanged();
|
|
|
|
|
2007-06-12 22:24:12 +02:00
|
|
|
/* Do not render, nor blit */
|
2021-06-12 09:10:17 +02:00
|
|
|
Debug(misc, 1, "Forcing blitter 'null'...");
|
2014-01-02 23:41:58 +01:00
|
|
|
BlitterFactory::SelectBlitter("null");
|
2019-04-10 23:07:06 +02:00
|
|
|
return nullptr;
|
2005-07-23 17:16:57 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 14:23:54 +02:00
|
|
|
void VideoDriver_Null::Stop() { }
|
2005-07-23 17:16:57 +02:00
|
|
|
|
2007-07-05 14:23:54 +02:00
|
|
|
void VideoDriver_Null::MakeDirty(int left, int top, int width, int height) {}
|
2005-07-23 17:16:57 +02:00
|
|
|
|
2007-07-05 14:23:54 +02:00
|
|
|
void VideoDriver_Null::MainLoop()
|
2005-07-23 17:16:57 +02:00
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
|
2007-07-13 15:03:20 +02:00
|
|
|
for (i = 0; i < this->ticks; i++) {
|
2021-02-24 15:22:23 +01:00
|
|
|
::GameLoop();
|
|
|
|
::InputLoop();
|
|
|
|
::UpdateWindows();
|
2005-07-23 17:16:57 +02:00
|
|
|
}
|
2021-06-10 19:34:53 +02:00
|
|
|
|
|
|
|
/* If requested, make a save just before exit. The normal exit-flow is
|
|
|
|
* not triggered from this driver, so we have to do this manually. */
|
|
|
|
if (_settings_client.gui.autosave_on_exit) {
|
|
|
|
DoExitSave();
|
|
|
|
}
|
2005-07-23 17:16:57 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 14:23:54 +02:00
|
|
|
bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; }
|
|
|
|
|
2008-01-01 15:20:48 +01:00
|
|
|
bool VideoDriver_Null::ToggleFullscreen(bool fs) { return false; }
|