mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-02-18 10:15:38 +00:00
Added Screenshot feature (ALT+S).
This commit is contained in:
parent
ca57659fcb
commit
981cdc33f5
|
@ -58,6 +58,7 @@ CInputs::CInputs(CInputSystem *system)
|
|||
uiToggleFrLimit = AddSwitchInput("UIToggleFrameLimit", "Toggle Frame Limiting", Game::INPUT_UI, "KEY_ALT+KEY_T");
|
||||
uiDumpInpState = AddSwitchInput("UIDumpInputState", "Dump Input State", Game::INPUT_UI, "KEY_ALT+KEY_U");
|
||||
uiDumpTimings = AddSwitchInput("UIDumpTimings", "Dump Frame Timings", Game::INPUT_UI, "KEY_ALT+KEY_O");
|
||||
uiScreenshot = AddSwitchInput("UIScreenShot", "Screenshot", Game::INPUT_UI, "KEY_ALT+KEY_S");
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
uiEnterDebugger = AddSwitchInput("UIEnterDebugger", "Enter Debugger", Game::INPUT_UI, "KEY_ALT+KEY_B");
|
||||
#endif
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
CSwitchInput *uiToggleFrLimit;
|
||||
CSwitchInput *uiDumpInpState;
|
||||
CSwitchInput *uiDumpTimings;
|
||||
CSwitchInput *uiScreenshot;
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
CSwitchInput *uiEnterDebugger;
|
||||
#endif
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "SDLIncludes.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "Util/BMPFile.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -413,6 +414,27 @@ static void DumpPPCRegisters(IBus *bus)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void SaveFrameBuffer(const std::string& file)
|
||||
{
|
||||
std::shared_ptr<uint8_t> pixels(new uint8_t[totalXRes * totalYRes * 4], std::default_delete<uint8_t[]>());
|
||||
glReadPixels(0, 0, totalXRes, totalYRes, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
|
||||
Util::WriteSurfaceToBMP<Util::RGBA8>(file, pixels.get(), totalXRes, totalYRes, true);
|
||||
}
|
||||
|
||||
void Screenshot()
|
||||
{
|
||||
// Make a screenshot
|
||||
char file[128];
|
||||
string info = "Screenshot created: ";
|
||||
time_t now = time(0);
|
||||
tm* ltm = localtime(&now);
|
||||
|
||||
sprintf(file, "Screenshot %.4d-%.2d-%.2d (%.2d-%.2d-%.2d).bmp", 1900 + ltm->tm_year, 1 + ltm->tm_mon, ltm->tm_mday, ltm->tm_hour, ltm->tm_min, ltm->tm_sec);
|
||||
|
||||
info += file;
|
||||
puts(info.c_str());
|
||||
SaveFrameBuffer(file);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Render State Analysis
|
||||
|
@ -421,17 +443,9 @@ static void DumpPPCRegisters(IBus *bus)
|
|||
#ifdef DEBUG
|
||||
|
||||
#include "Model3/Model3GraphicsState.h"
|
||||
#include "Util/BMPFile.h"
|
||||
#include "OSD/SDL/PolyAnalysis.h"
|
||||
#include <fstream>
|
||||
|
||||
static void SaveFrameBuffer(const std::string &file)
|
||||
{
|
||||
std::shared_ptr<uint8_t> pixels(new uint8_t[totalXRes*totalYRes*4], std::default_delete<uint8_t[]>());
|
||||
glReadPixels(0, 0, totalXRes, totalYRes, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
|
||||
Util::WriteSurfaceToBMP<Util::RGBA8>(file, pixels.get(), totalXRes, totalYRes, true);
|
||||
}
|
||||
|
||||
static std::string s_gfxStatePath;
|
||||
|
||||
static std::string GetFileBaseName(const std::string &file)
|
||||
|
@ -1175,6 +1189,11 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In
|
|||
s_runtime_config.Get("Throttle").SetValue(!s_runtime_config["Throttle"].ValueAs<bool>());
|
||||
printf("Frame limiting: %s\n", s_runtime_config["Throttle"].ValueAs<bool>() ? "On" : "Off");
|
||||
}
|
||||
else if (Inputs->uiScreenshot->Pressed())
|
||||
{
|
||||
// Make a screenshot
|
||||
Screenshot();
|
||||
}
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
else if (Debugger != NULL && Inputs->uiEnterDebugger->Pressed())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue