From 0e4a860c5ed0830341ca1ebc5a9575b8bb615226 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Mar 2019 12:52:07 +0100 Subject: [PATCH] - fixed uninitialized screen flash color for savegame images in the software renderer. --- src/rendering/2d/v_draw.cpp | 25 +++++++++++++++++------ src/rendering/swrenderer/r_swrenderer.cpp | 3 +++ src/v_video.h | 3 ++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/rendering/2d/v_draw.cpp b/src/rendering/2d/v_draw.cpp index 8030ba4c7..fb66f4f5f 100644 --- a/src/rendering/2d/v_draw.cpp +++ b/src/rendering/2d/v_draw.cpp @@ -1351,12 +1351,13 @@ void DFrameBuffer::DrawBorder (FTextureID picnum, int x1, int y1, int x2, int y2 } } -///========================================================================== +//========================================================================== // // Draws a blend over the entire view // //========================================================================== -void DFrameBuffer::DrawBlend(sector_t * viewsector) + +FVector4 DFrameBuffer::CalcBlend(sector_t * viewsector) { float blend[4] = { 0,0,0,0 }; PalEntry blendv = 0; @@ -1376,7 +1377,7 @@ void DFrameBuffer::DrawBlend(sector_t * viewsector) // don't draw sector based blends when any fullbright screen effect is active. if (!fullbright) { - const auto &vpp = r_viewpoint.Pos; + const auto &vpp = r_viewpoint.Pos; if (!viewsector->e->XFloor.ffloors.Size()) { if (viewsector->GetHeightSec()) @@ -1452,7 +1453,7 @@ void DFrameBuffer::DrawBlend(sector_t * viewsector) if (in->IsKindOf(torchtype)) { // The software renderer already bakes the torch flickering into its output, so this must be omitted here. - float r = vid_rendermode < 4? 1.f : (0.8f + (7 - player->fixedlightlevel) / 70.0f); + float r = vid_rendermode < 4 ? 1.f : (0.8f + (7 - player->fixedlightlevel) / 70.0f); if (r > 1.0f) r = 1.0f; int rr = (int)(r * 255); int b = rr; @@ -1488,8 +1489,20 @@ void DFrameBuffer::DrawBlend(sector_t * viewsector) const float br = clamp(blend[0] * 255.f, 0.f, 255.f); const float bg = clamp(blend[1] * 255.f, 0.f, 255.f); const float bb = clamp(blend[2] * 255.f, 0.f, 255.f); - const PalEntry bcolor(255, uint8_t(br), uint8_t(bg), uint8_t(bb)); - screen->Dim(bcolor, blend[3], 0, 0, screen->GetWidth(), screen->GetHeight()); + return { br, bg, bb, blend[3] }; +} + +//========================================================================== +// +// Draws a blend over the entire view +// +//========================================================================== + +void DFrameBuffer::DrawBlend(sector_t * viewsector) +{ + auto blend = CalcBlend(viewsector); + const PalEntry bcolor(255, uint8_t(blend.X), uint8_t(blend.Y), uint8_t(blend.Z)); + screen->Dim(bcolor, blend.W, 0, 0, screen->GetWidth(), screen->GetHeight()); } diff --git a/src/rendering/swrenderer/r_swrenderer.cpp b/src/rendering/swrenderer/r_swrenderer.cpp index 93802f4c8..41b071517 100644 --- a/src/rendering/swrenderer/r_swrenderer.cpp +++ b/src/rendering/swrenderer/r_swrenderer.cpp @@ -230,6 +230,9 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi r_viewpoint = mScene.MainThread()->Viewport->viewpoint; r_viewwindow = mScene.MainThread()->Viewport->viewwindow; } + auto blend = screen->CalcBlend(r_viewpoint.sector); + const PalEntry bcolor(255, uint8_t(blend.X), uint8_t(blend.Y), uint8_t(blend.Z)); + screen->SetFlash(bcolor, int(blend.W * 256)); screen->GetFlashedPalette (palette); M_CreatePNG (file, pic.GetPixels(), palette, SS_PAL, width, height, pic.GetPitch(), Gamma); } diff --git a/src/v_video.h b/src/v_video.h index b56c4e727..6ac2aaf20 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -352,7 +352,7 @@ private: protected: int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1; - PalEntry Flash; // Only needed to support some cruft in the interface that only makes sense for the software renderer + PalEntry Flash = 0; // Only needed to support some cruft in the interface that only makes sense for the software renderer PalEntry SourcePalette[256]; // This is where unpaletted textures get their palette from public: @@ -502,6 +502,7 @@ public: // Dim part of the canvas void Dim(PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle *style = nullptr); void DoDim(PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle *style = nullptr); + FVector4 CalcBlend(sector_t * viewsector); void DrawBlend(sector_t * viewsector); // Fill an area with a texture