diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 5805268363..8bf8c3e69a 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ January 12, 2008 (Changes by Graf Zahl) +- Moved renderer dependent part of savegame pic creation into DFrameBuffer + as a virtual function so that it can be overridden. - Fixed: M_SaveBitmap::prior was too small. It must be 3 bytes per pixel, not 1. - Replaced INVGEM** graphics with PNG versions so that they have the diff --git a/src/g_game.cpp b/src/g_game.cpp index 0581ca5827..012728bbb0 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1969,17 +1969,8 @@ static void PutSavePic (FILE *file, int width, int height) } else { - DCanvas *pic = new DSimpleCanvas (width, height); - PalEntry palette[256]; - - // Take a snapshot of the player's view - pic->Lock (); P_CheckPlayerSprites(); - R_RenderViewToCanvas (players[consoleplayer].mo, pic, 0, 0, width, height); - screen->GetFlashedPalette (palette); - M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch()); - pic->Unlock (); - delete pic; + screen->WriteSavePic(&players[consoleplayer], file, width, height); } } diff --git a/src/v_video.cpp b/src/v_video.cpp index 0117051406..e071c1edd1 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -61,6 +61,7 @@ #include "hardware.h" #include "r_translate.h" #include "f_wipe.h" +#include "m_png.h" IMPLEMENT_ABSTRACT_CLASS (DCanvas) IMPLEMENT_ABSTRACT_CLASS (DFrameBuffer) @@ -1310,6 +1311,7 @@ void DFrameBuffer::CopyPixelData(BYTE * buffer, int texpitch, int texheight, int // Render the view // //=========================================================================== + void DFrameBuffer::RenderView(player_t *player) { R_RenderActorView (player->mo); @@ -1318,6 +1320,26 @@ void DFrameBuffer::RenderView(player_t *player) FCanvasTextureInfo::UpdateAll (); } +//=========================================================================== +// +// Render the view to a savegame picture +// +//=========================================================================== + +void DFrameBuffer::WriteSavePic (player_t *player, FILE *file, int width, int height) +{ + DCanvas *pic = new DSimpleCanvas (width, height); + PalEntry palette[256]; + + // Take a snapshot of the player's view + pic->Lock (); + R_RenderViewToCanvas (player->mo, pic, 0, 0, width, height); + GetFlashedPalette (palette); + M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch()); + pic->Unlock (); + delete pic; +} + FNativePalette::~FNativePalette() diff --git a/src/v_video.h b/src/v_video.h index 70051d824b..aa0198142c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -346,6 +346,9 @@ public: // render 3D view virtual void RenderView(player_t *player); + // renders view to a savegame picture + virtual void WriteSavePic (player_t *player, FILE *file, int width, int height); + bool Accel2D; // If true, 2D drawing can be accelerated. // Begin 2D drawing operations. This is like Update, but it doesn't end