diff --git a/src/graphics/Pixel.h b/src/graphics/Pixel.h index cce7336a9..43b90b4b6 100644 --- a/src/graphics/Pixel.h +++ b/src/graphics/Pixel.h @@ -64,6 +64,16 @@ struct alignas(alignof(uint32_t) > alignof(T) ? alignof(uint32_t) : alignof(T)) ); } + template>> + constexpr RGB AddFire(RGB other, int fireAlpha) const + { + return RGB( + std::min(0xFF, Red + (fireAlpha * other.Red) / 0xFF), + std::min(0xFF, Green + (fireAlpha * other.Green) / 0xFF), + std::min(0xFF, Blue + (fireAlpha * other.Blue) / 0xFF) + ); + } + // Decrement each component that is nonzero. template>> constexpr RGB Decay() const diff --git a/src/graphics/RasterDrawMethods.h b/src/graphics/RasterDrawMethods.h index 2172f8084..ee1060f8a 100644 --- a/src/graphics/RasterDrawMethods.h +++ b/src/graphics/RasterDrawMethods.h @@ -13,6 +13,7 @@ struct RasterDrawMethods void DrawPixel(Vec2, RGB); void BlendPixel(Vec2, RGBA); void AddPixel(Vec2, RGBA); + void AddFirePixel(Vec2, RGB, int fireAlpha); void XorPixel(Vec2); void DrawLine(Vec2, Vec2, RGB); diff --git a/src/graphics/RasterDrawMethodsImpl.h b/src/graphics/RasterDrawMethodsImpl.h index eb39f0d88..1621cc096 100644 --- a/src/graphics/RasterDrawMethodsImpl.h +++ b/src/graphics/RasterDrawMethodsImpl.h @@ -55,6 +55,16 @@ inline void RasterDrawMethods::AddPixel(Vec2 pos, RGBA co } } +template +inline void RasterDrawMethods::AddFirePixel(Vec2 pos, RGB colour, int fireAlpha) +{ + if (clipRect().Contains(pos)) + { + pixel &px = (static_cast(*this).video)[pos]; + px = RGB::Unpack(px).AddFire(colour, fireAlpha).Pack(); + } +} + template inline void RasterDrawMethods::XorPixel(Vec2 pos) { diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 9e9a5742e..1f47d9452 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -1161,7 +1161,7 @@ void Renderer::render_fire() a = fire_alpha[y+CELL][x+CELL]; if (findingElement) a /= 2; - AddPixel({ i*CELL+x, j*CELL+y }, RGBA(r, g, b, a)); + AddFirePixel({ i*CELL+x, j*CELL+y }, RGB(r, g, b), a); } r *= 8; g *= 8;