From 222f82304d510905be732c89f0aa866a614c32e7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Sep 2020 01:11:32 +0200 Subject: [PATCH] - fixed savegame image generation. There were two errors: 1. The postprocessor was not run on the generated scene so that the target framebuffer never got set. 2. The generated PNG was not finalized and failed the integrity check of the savegame menu. Fixes #48 --- source/core/savegamehelp.cpp | 7 +++++++ source/glbackend/glbackend.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index b90fa3bfa..9a347f7dc 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -233,6 +233,13 @@ bool OpenSaveGameForWrite(const char* filename, const char *name) auto picfile = WriteSavegameChunk("savepic.png"); WriteSavePic(picfile, 240, 180); + mysnprintf(buf, countof(buf), GAMENAME " %s", GetVersionString()); + // put some basic info into the PNG so that this isn't lost when the image gets extracted. + M_AppendPNGText(picfile, "Software", buf); + M_AppendPNGText(picfile, "Title", name); + M_AppendPNGText(picfile, "Current Map", lev->labelName); + M_FinishPNG(picfile); + return true; } diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 1b243dfc2..da6ad6039 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -56,6 +56,7 @@ F2DDrawer twodpsp; static int BufferLock = 0; TArray matrixArray; +void Draw2D(F2DDrawer* drawer, FRenderState& state); FileReader GetResource(const char* fn) { @@ -344,8 +345,14 @@ void WriteSavePic(FileWriter* file, int width, int height) RenderState.SetPassType(NORMAL_PASS); RenderState.EnableDrawBuffers(1, true); + screen->SetViewportRects(&bounds); bool didit = gi->GenerateSavePic(); + float Brightness = 8.f / (r_scenebrightness + 8.f); + screen->PostProcessScene(false, 0, Brightness, []() { + Draw2D(&twodpsp, *screen->RenderState()); // draws the weapon sprites + }); + xdim = oldx; ydim = oldy; videoSetViewableArea(oldwindowxy1.x, oldwindowxy1.y, oldwindowxy2.x, oldwindowxy2.y); @@ -476,8 +483,6 @@ int32_t r_scenebrightness = 0; -void Draw2D(F2DDrawer* drawer, FRenderState& state); - void videoShowFrame(int32_t w) { if (gl_ssao)