mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Screenshot capability of Software rasterizer for feature completness.
This commit is contained in:
parent
23c84c220f
commit
e8a4cc0f71
@ -1810,7 +1810,7 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
|||||||
{
|
{
|
||||||
u32 W = back_rc.GetWidth();
|
u32 W = back_rc.GetWidth();
|
||||||
u32 H = back_rc.GetHeight();
|
u32 H = back_rc.GetHeight();
|
||||||
u8 *data = (u8 *)malloc((sizeof(u8) * 4 * W * H));
|
u8 *data = new u8[W * 4 * H];
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
@ -1825,7 +1825,6 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
|||||||
|
|
||||||
// Turn image upside down
|
// Turn image upside down
|
||||||
FlipImageData(data, W, H, 4);
|
FlipImageData(data, W, H, 4);
|
||||||
|
|
||||||
return TextureToPng(data, W*4, filename.c_str(), W, H, false);
|
return TextureToPng(data, W*4, filename.c_str(), W, H, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "../../OGL/Src/GLUtil.h"
|
#include "../../OGL/Src/GLUtil.h"
|
||||||
|
#include "ImageWrite.h"
|
||||||
|
#include "ImageWrite.h"
|
||||||
#include "RasterFont.h"
|
#include "RasterFont.h"
|
||||||
#include "SWRenderer.h"
|
#include "SWRenderer.h"
|
||||||
#include "SWStatistics.h"
|
#include "SWStatistics.h"
|
||||||
@ -17,6 +19,11 @@ static GLint attr_pos = -1, attr_tex = -1;
|
|||||||
static GLint uni_tex = -1;
|
static GLint uni_tex = -1;
|
||||||
static GLuint program;
|
static GLuint program;
|
||||||
|
|
||||||
|
static volatile bool s_bScreenshot;
|
||||||
|
static std::mutex s_criticalScreenshot;
|
||||||
|
static std::string s_sScreenshotName;
|
||||||
|
|
||||||
|
|
||||||
// Rasterfont isn't compatible with GLES
|
// Rasterfont isn't compatible with GLES
|
||||||
// degasus: I think it does, but I can't test it
|
// degasus: I think it does, but I can't test it
|
||||||
#ifndef USE_GLES
|
#ifndef USE_GLES
|
||||||
@ -25,6 +32,7 @@ RasterFont* s_pfont = NULL;
|
|||||||
|
|
||||||
void SWRenderer::Init()
|
void SWRenderer::Init()
|
||||||
{
|
{
|
||||||
|
s_bScreenshot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SWRenderer::Shutdown()
|
void SWRenderer::Shutdown()
|
||||||
@ -80,6 +88,13 @@ void SWRenderer::Prepare()
|
|||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SWRenderer::SetScreenshot(const char *_szFilename)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
|
s_sScreenshotName = _szFilename;
|
||||||
|
s_bScreenshot = true;
|
||||||
|
}
|
||||||
|
|
||||||
void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
|
void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
|
||||||
{
|
{
|
||||||
#ifndef USE_GLES
|
#ifndef USE_GLES
|
||||||
@ -124,6 +139,17 @@ void SWRenderer::DrawDebugText()
|
|||||||
|
|
||||||
void SWRenderer::DrawTexture(u8 *texture, int width, int height)
|
void SWRenderer::DrawTexture(u8 *texture, int width, int height)
|
||||||
{
|
{
|
||||||
|
// Save screenshot
|
||||||
|
if (s_bScreenshot)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
|
u8 *data = new u8[width * 4 * height];
|
||||||
|
memcpy(data, texture, sizeof(u8) * 4 * width * height);
|
||||||
|
TextureToPng(data, width*4, s_sScreenshotName.c_str(), width, height, false);
|
||||||
|
// Reset settings
|
||||||
|
s_sScreenshotName.clear();
|
||||||
|
s_bScreenshot = false;
|
||||||
|
}
|
||||||
GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();
|
GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();
|
||||||
GLsizei glHeight = (GLsizei)GLInterface->GetBackBufferHeight();
|
GLsizei glHeight = (GLsizei)GLInterface->GetBackBufferHeight();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define _RENDERER_H_
|
#define _RENDERER_H_
|
||||||
|
|
||||||
#include "CommonTypes.h"
|
#include "CommonTypes.h"
|
||||||
|
#include "Thread.h"
|
||||||
|
|
||||||
namespace SWRenderer
|
namespace SWRenderer
|
||||||
{
|
{
|
||||||
@ -13,6 +14,7 @@ namespace SWRenderer
|
|||||||
void Prepare();
|
void Prepare();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
|
void SetScreenshot(const char *_szFilename);
|
||||||
void RenderText(const char* pstr, int left, int top, u32 color);
|
void RenderText(const char* pstr, int left, int top, u32 color);
|
||||||
void DrawDebugText();
|
void DrawDebugText();
|
||||||
|
|
||||||
|
@ -236,7 +236,8 @@ u32 VideoSoftware::Video_GetQueryResult(PerfQueryType type)
|
|||||||
|
|
||||||
bool VideoSoftware::Video_Screenshot(const char *_szFilename)
|
bool VideoSoftware::Video_Screenshot(const char *_szFilename)
|
||||||
{
|
{
|
||||||
return false;
|
SWRenderer::SetScreenshot(_szFilename);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user