Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[linux] add #ifdef _WIN32 // Screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
q4a committed Jun 6, 2022
1 parent a7f2f68 commit 686a796
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libs/renderer/src/s_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace
{
constexpr auto kKeyTakeScreenshot = "TakeScreenshot";

#ifdef _WIN32 // Screenshot
D3DXIMAGE_FILEFORMAT GetScreenshotFormat(const std::string &fmt)
{
if (fmt == "bmp")
Expand Down Expand Up @@ -79,6 +80,7 @@ D3DXIMAGE_FILEFORMAT GetScreenshotFormat(const std::string &fmt)

return D3DXIFF_FORCE_DWORD;
}
#endif

void InvokeEntitiesLostRender()
{
Expand Down Expand Up @@ -494,12 +496,14 @@ bool DX9RENDER::Init()
screenshotExt = str;
std::ranges::transform(screenshotExt, screenshotExt.begin(),
[](const unsigned char c) { return std::tolower(c); });
#ifdef _WIN32 // Screenshot
screenshotFormat = GetScreenshotFormat(str);
if (screenshotFormat == D3DXIFF_FORCE_DWORD)
{
screenshotExt = "jpg";
screenshotFormat = D3DXIFF_JPG;
}
#endif

bShowFps = ini->GetInt(nullptr, "show_fps", 0) == 1;
bShowExInfo = ini->GetInt(nullptr, "show_exinfo", 0) == 1;
Expand Down Expand Up @@ -3282,7 +3286,9 @@ void DX9RENDER::MakeScreenShot()
screenshot_path.replace_filename(screenshot_base_filename + "_" + std::to_string(i));
screenshot_path.replace_extension(screenshotExt);
}
#ifdef _WIN32 // Screenshot
D3DXSaveSurfaceToFile(screenshot_path.c_str(), screenshotFormat, surface, nullptr, nullptr);
#endif

surface->Release();
renderTarget->Release();
Expand Down
2 changes: 2 additions & 0 deletions src/libs/renderer/src/s_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ class DX9RENDER : public VDX9RENDER

std::stack<RenderTarget> stRenderTarget;

#ifdef _WIN32 // Screenshot
D3DXIMAGE_FILEFORMAT screenshotFormat;
#endif
std::string screenshotExt;

bool TextureLoad(int32_t texid);
Expand Down

0 comments on commit 686a796

Please sign in to comment.