diff options
author | Patric Stout <truebrain@openttd.org> | 2021-03-08 15:42:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 15:42:39 +0100 |
commit | b93d7dd3cbd6dae2011e7863ba8a7aa19614771e (patch) | |
tree | 83d4630bfbcafc4875479fe8f796f3a3c8703691 /src/driver.cpp | |
parent | 6e2a96c1333a0d383c7a0191c75dabd837feeeb5 (diff) | |
download | openttd-b93d7dd3cbd6dae2011e7863ba8a7aa19614771e.tar.xz |
Add: Option to (dis-)allow accelerated video drivers. (#8819)
The video drivers using the OpenGL backend are currently our only
accelerated drivers. The options defaults to off for macOS builds and
to on everywhere else.
Co-authored-by: Michael Lutz <michi@icosahedron.de>
Diffstat (limited to 'src/driver.cpp')
-rw-r--r-- | src/driver.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/driver.cpp b/src/driver.cpp index c4efd3569..42520648f 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -9,10 +9,12 @@ #include "stdafx.h" #include "debug.h" +#include "error.h" #include "sound/sound_driver.hpp" #include "music/music_driver.hpp" #include "video/video_driver.hpp" #include "string_func.h" +#include "table/strings.h" #include <string> #include <sstream> @@ -111,6 +113,8 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t if (d->type != type) continue; if (d->priority != priority) continue; + if (type == Driver::DT_VIDEO && !_video_hw_accel && d->UsesHardwareAcceleration()) continue; + Driver *oldd = *GetActiveDriver(type); Driver *newd = d->CreateInstance(); *GetActiveDriver(type) = newd; @@ -125,6 +129,12 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t *GetActiveDriver(type) = oldd; DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err); delete newd; + + if (type == Driver::DT_VIDEO && _video_hw_accel && d->UsesHardwareAcceleration()) { + _video_hw_accel = false; + ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION); + ScheduleErrorMessage(msg); + } } } usererror("Couldn't find any suitable %s driver", GetDriverTypeName(type)); |