summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Software
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2013-11-15 22:07:08 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2013-11-15 22:08:08 -0600
commite8a4cc0f711b9b9c6f39bc281bc6a82ea36d2060 (patch)
treea4b9e638f400455ba684b3b56dc8b2cf7f331ab8 /Source/Core/VideoBackends/Software
parent23c84c220f396c53731360dd90acaf278d212422 (diff)
Screenshot capability of Software rasterizer for feature completness.
Diffstat (limited to 'Source/Core/VideoBackends/Software')
-rw-r--r--Source/Core/VideoBackends/Software/Src/SWRenderer.cpp26
-rw-r--r--Source/Core/VideoBackends/Software/Src/SWRenderer.h6
-rw-r--r--Source/Core/VideoBackends/Software/Src/SWmain.cpp3
3 files changed, 32 insertions, 3 deletions
diff --git a/Source/Core/VideoBackends/Software/Src/SWRenderer.cpp b/Source/Core/VideoBackends/Software/Src/SWRenderer.cpp
index 1d894b18da..c2d9b626f7 100644
--- a/Source/Core/VideoBackends/Software/Src/SWRenderer.cpp
+++ b/Source/Core/VideoBackends/Software/Src/SWRenderer.cpp
@@ -5,6 +5,8 @@
#include "Common.h"
#include "../../OGL/Src/GLUtil.h"
+#include "ImageWrite.h"
+#include "ImageWrite.h"
#include "RasterFont.h"
#include "SWRenderer.h"
#include "SWStatistics.h"
@@ -17,6 +19,11 @@ static GLint attr_pos = -1, attr_tex = -1;
static GLint uni_tex = -1;
static GLuint program;
+static volatile bool s_bScreenshot;
+static std::mutex s_criticalScreenshot;
+static std::string s_sScreenshotName;
+
+
// Rasterfont isn't compatible with GLES
// degasus: I think it does, but I can't test it
#ifndef USE_GLES
@@ -25,6 +32,7 @@ RasterFont* s_pfont = NULL;
void SWRenderer::Init()
{
+ s_bScreenshot = false;
}
void SWRenderer::Shutdown()
@@ -80,6 +88,13 @@ void SWRenderer::Prepare()
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)
{
#ifndef USE_GLES
@@ -124,6 +139,17 @@ void SWRenderer::DrawDebugText()
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 glHeight = (GLsizei)GLInterface->GetBackBufferHeight();
diff --git a/Source/Core/VideoBackends/Software/Src/SWRenderer.h b/Source/Core/VideoBackends/Software/Src/SWRenderer.h
index ba856936cb..80a93ea203 100644
--- a/Source/Core/VideoBackends/Software/Src/SWRenderer.h
+++ b/Source/Core/VideoBackends/Software/Src/SWRenderer.h
@@ -6,13 +6,15 @@
#define _RENDERER_H_
#include "CommonTypes.h"
+#include "Thread.h"
namespace SWRenderer
-{
+{
void Init();
void Prepare();
void Shutdown();
-
+
+ void SetScreenshot(const char *_szFilename);
void RenderText(const char* pstr, int left, int top, u32 color);
void DrawDebugText();
diff --git a/Source/Core/VideoBackends/Software/Src/SWmain.cpp b/Source/Core/VideoBackends/Software/Src/SWmain.cpp
index 939dd4553a..074b6bc38b 100644
--- a/Source/Core/VideoBackends/Software/Src/SWmain.cpp
+++ b/Source/Core/VideoBackends/Software/Src/SWmain.cpp
@@ -236,7 +236,8 @@ u32 VideoSoftware::Video_GetQueryResult(PerfQueryType type)
bool VideoSoftware::Video_Screenshot(const char *_szFilename)
{
- return false;
+ SWRenderer::SetScreenshot(_szFilename);
+ return true;
}
// -------------------------------