summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-02-27 12:52:19 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-27 13:09:38 +0100
commitef4cec9382f7992d625f4c37daec20b63643ec05 (patch)
tree5218fb518fa17432553bd5922114a0ed71145a04 /src
parent54fb4c04e39a988fe47c22c950d46527f857e077 (diff)
downloadopenttd-ef4cec9382f7992d625f4c37daec20b63643ec05.tar.xz
Fix #8750: [OpenGL] Line drawing did not set proper RGB/mask colours.
Diffstat (limited to 'src')
-rw-r--r--src/blitter/40bpp_anim.cpp18
-rw-r--r--src/blitter/40bpp_anim.hpp1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/blitter/40bpp_anim.cpp b/src/blitter/40bpp_anim.cpp
index 2cc3be5be..aaca817fc 100644
--- a/src/blitter/40bpp_anim.cpp
+++ b/src/blitter/40bpp_anim.cpp
@@ -14,6 +14,7 @@
#include "../settings_type.h"
#include "../video/video_driver.hpp"
#include "40bpp_anim.hpp"
+#include "common.hpp"
#include "../table/sprites.h"
@@ -64,6 +65,23 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colou
} while (--height);
}
+void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash)
+{
+ if (_screen_disable_anim) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
+ Blitter_32bppOptimized::DrawLine(video, x, y, x2, y2, screen_width, screen_height, colour, width, dash);
+ return;
+ }
+
+ assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr);
+ uint8 *anim = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer();
+
+ this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) {
+ *((Colour *)video + x + y * _screen.pitch) = _black_colour;
+ *(anim + x + y * _screen.pitch) = colour;
+ });
+}
+
/**
* Draws a sprite to a (screen) buffer. It is templated to allow faster operation.
*
diff --git a/src/blitter/40bpp_anim.hpp b/src/blitter/40bpp_anim.hpp
index 8d7e6ce32..c0bea15ae 100644
--- a/src/blitter/40bpp_anim.hpp
+++ b/src/blitter/40bpp_anim.hpp
@@ -23,6 +23,7 @@ public:
// void *MoveTo(void *video, int x, int y) override;
void SetPixel(void *video, int x, int y, uint8 colour) override;
void DrawRect(void *video, int width, int height, uint8 colour) override;
+ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override;
void CopyFromBuffer(void *video, const void *src, int width, int height) override;
void CopyToBuffer(const void *video, void *dst, int width, int height) override;
void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override;