- fixed uninitialized screen flash color for savegame images in the software renderer.

This commit is contained in:
Christoph Oelckers 2019-03-09 12:52:07 +01:00
parent 2fa5a88701
commit 0e4a860c5e
3 changed files with 24 additions and 7 deletions

View file

@ -1351,12 +1351,13 @@ void DFrameBuffer::DrawBorder (FTextureID picnum, int x1, int y1, int x2, int y2
} }
} }
///========================================================================== //==========================================================================
// //
// Draws a blend over the entire view // 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 }; float blend[4] = { 0,0,0,0 };
PalEntry blendv = 0; PalEntry blendv = 0;
@ -1452,7 +1453,7 @@ void DFrameBuffer::DrawBlend(sector_t * viewsector)
if (in->IsKindOf(torchtype)) if (in->IsKindOf(torchtype))
{ {
// The software renderer already bakes the torch flickering into its output, so this must be omitted here. // 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; if (r > 1.0f) r = 1.0f;
int rr = (int)(r * 255); int rr = (int)(r * 255);
int b = rr; 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 br = clamp(blend[0] * 255.f, 0.f, 255.f);
const float bg = clamp(blend[1] * 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 float bb = clamp(blend[2] * 255.f, 0.f, 255.f);
const PalEntry bcolor(255, uint8_t(br), uint8_t(bg), uint8_t(bb)); return { br, bg, bb, blend[3] };
screen->Dim(bcolor, blend[3], 0, 0, screen->GetWidth(), screen->GetHeight()); }
//==========================================================================
//
// 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());
} }

View file

@ -230,6 +230,9 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi
r_viewpoint = mScene.MainThread()->Viewport->viewpoint; r_viewpoint = mScene.MainThread()->Viewport->viewpoint;
r_viewwindow = mScene.MainThread()->Viewport->viewwindow; 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); screen->GetFlashedPalette (palette);
M_CreatePNG (file, pic.GetPixels(), palette, SS_PAL, width, height, pic.GetPitch(), Gamma); M_CreatePNG (file, pic.GetPixels(), palette, SS_PAL, width, height, pic.GetPitch(), Gamma);
} }

View file

@ -352,7 +352,7 @@ private:
protected: protected:
int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1; 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 PalEntry SourcePalette[256]; // This is where unpaletted textures get their palette from
public: public:
@ -502,6 +502,7 @@ public:
// Dim part of the canvas // Dim part of the canvas
void Dim(PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle *style = nullptr); 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); 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); void DrawBlend(sector_t * viewsector);
// Fill an area with a texture // Fill an area with a texture