- 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
//
//==========================================================================
void DFrameBuffer::DrawBlend(sector_t * viewsector)
FVector4 DFrameBuffer::CalcBlend(sector_t * viewsector)
{
float blend[4] = { 0,0,0,0 };
PalEntry blendv = 0;
@ -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());
}

View File

@ -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);
}

View File

@ -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