summaryrefslogtreecommitdiff
path: root/src/video/win32_v.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-01-16 16:27:50 +0100
committerMichael Lutz <michi@icosahedron.de>2021-01-17 19:57:36 +0100
commit1eceee915ede04301c411bb0465c32a3712aa0d2 (patch)
tree5814ff3bdf8f6a6511868ad5f206783e4efcf9b9 /src/video/win32_v.cpp
parent49df9c415595a7aa104ff5463372118ec874a4c2 (diff)
downloadopenttd-1eceee915ede04301c411bb0465c32a3712aa0d2.tar.xz
Codechange: [SDL2/Win32] Be consistent how 0bpp blitters are not allowed
Sometimes it returned an usererror(), sometimes Start() failed. Now it always fails on Start(), so nothing else has to check again what blitter is used. AfterBlitterChange() can never change to a 0bpp, so it is sufficient to guard this with an assert().
Diffstat (limited to 'src/video/win32_v.cpp')
-rw-r--r--src/video/win32_v.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 9e1df8473..c1b31d14a 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -1004,8 +1004,6 @@ static bool AllocateDibSection(int w, int h, bool force)
w = std::max(w, 64);
h = std::max(h, 64);
- if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
-
if (!force && w == _screen.width && h == _screen.height) return false;
bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
@@ -1016,7 +1014,7 @@ static bool AllocateDibSection(int w, int h, bool force)
bi->bmiHeader.biHeight = -(_wnd.height = h);
bi->bmiHeader.biPlanes = 1;
- bi->bmiHeader.biBitCount = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
+ bi->bmiHeader.biBitCount = bpp;
bi->bmiHeader.biCompression = BI_RGB;
if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect);
@@ -1079,6 +1077,8 @@ static FVideoDriver_Win32 iFVideoDriver_Win32;
const char *VideoDriver_Win32::Start(const StringList &parm)
{
+ if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
+
this->UpdateAutoResolution();
memset(&_wnd, 0, sizeof(_wnd));
@@ -1288,6 +1288,7 @@ bool VideoDriver_Win32::ToggleFullscreen(bool full_screen)
bool VideoDriver_Win32::AfterBlitterChange()
{
+ assert(BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 0);
return AllocateDibSection(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
}