summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/openglscreenshothelper.cpp14
-rw-r--r--src/resources/openglscreenshothelper.h12
-rw-r--r--src/resources/screenshothelper.h8
-rw-r--r--src/resources/sdlscreenshothelper.cpp11
-rw-r--r--src/resources/sdlscreenshothelper.h12
5 files changed, 27 insertions, 30 deletions
diff --git a/src/resources/openglscreenshothelper.cpp b/src/resources/openglscreenshothelper.cpp
index ec561476e..9d0edd80e 100644
--- a/src/resources/openglscreenshothelper.cpp
+++ b/src/resources/openglscreenshothelper.cpp
@@ -44,18 +44,18 @@ OpenGLScreenshotHelper::~OpenGLScreenshotHelper()
{
}
-void OpenGLScreenshotHelper::prepare(const int width,
- const int height)
+void OpenGLScreenshotHelper::prepare()
{
if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(width, height, &mFbo);
+ graphicsManager.createFBO(mainGraphics->mWidth,
+ mainGraphics->mHeight,
+ &mFbo);
}
-SDL_Surface *OpenGLScreenshotHelper::getScreenshot(const int width,
- const int height)
+SDL_Surface *OpenGLScreenshotHelper::getScreenshot()
{
- const int h = height;
- const int w = width - (width % 4);
+ const int h = mainGraphics->mHeight;
+ const int w = mainGraphics->mWidth - (mainGraphics->mWidth % 4);
GLint pack = 1;
SDL_Surface *const screenshot = MSDL_CreateRGBSurface(
diff --git a/src/resources/openglscreenshothelper.h b/src/resources/openglscreenshothelper.h
index fe9a7cfeb..ef4501cde 100644
--- a/src/resources/openglscreenshothelper.h
+++ b/src/resources/openglscreenshothelper.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RESOURCES_SDL2IMAGEHELPER_H
-#define RESOURCES_SDL2IMAGEHELPER_H
+#ifndef RESOURCES_OPENGLSCREENSHOTHELPER_H
+#define RESOURCES_OPENGLSCREENSHOTHELPER_H
#ifdef USE_OPENGL
@@ -40,15 +40,13 @@ class OpenGLScreenshotHelper final : public ScreenshotHelper
~OpenGLScreenshotHelper();
- void prepare(const int width,
- const int height) override final;
+ void prepare() override final;
- SDL_Surface *getScreenshot(const int width,
- const int height) override final;
+ SDL_Surface *getScreenshot() override final;
private:
FBOInfo mFbo;
};
#endif // USE_OPENGL
-#endif // RESOURCES_SDL2IMAGEHELPER_H
+#endif // RESOURCES_OPENGLSCREENSHOTHELPER_H
diff --git a/src/resources/screenshothelper.h b/src/resources/screenshothelper.h
index bde76c15a..5c5545387 100644
--- a/src/resources/screenshothelper.h
+++ b/src/resources/screenshothelper.h
@@ -38,11 +38,11 @@ class ScreenshotHelper notfinal
virtual ~ScreenshotHelper()
{ }
- virtual void prepare(const int width,
- const int height) = 0;
+ virtual void prepare() = 0;
- virtual SDL_Surface *getScreenshot(const int width,
- const int height) = 0;
+ virtual SDL_Surface *getScreenshot() = 0;
};
+extern ScreenshotHelper *screenshortHelper;
+
#endif // RESOURCES_SCREENSHOTHELPER_H
diff --git a/src/resources/sdlscreenshothelper.cpp b/src/resources/sdlscreenshothelper.cpp
index f194f93ed..eff32e303 100644
--- a/src/resources/sdlscreenshothelper.cpp
+++ b/src/resources/sdlscreenshothelper.cpp
@@ -39,14 +39,15 @@ SdlScreenshotHelper::~SdlScreenshotHelper()
{
}
-void SdlScreenshotHelper::prepare(const int width A_UNUSED,
- const int height A_UNUSED)
+void SdlScreenshotHelper::prepare()
{
}
-SDL_Surface *SdlScreenshotHelper::getScreenshot(const int width,
- const int height)
+SDL_Surface *SdlScreenshotHelper::getScreenshot()
{
+ if (!mainGraphics)
+ return nullptr;
+
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const int rmask = 0xff000000;
const int gmask = 0x00ff0000;
@@ -59,7 +60,7 @@ SDL_Surface *SdlScreenshotHelper::getScreenshot(const int width,
const int amask = 0x00000000;
SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- width, height,
+ mainGraphics->mWidth, mainGraphics->mHeight,
24,
rmask, gmask, bmask, amask);
diff --git a/src/resources/sdlscreenshothelper.h b/src/resources/sdlscreenshothelper.h
index 2f873937d..ff0989cd6 100644
--- a/src/resources/sdlscreenshothelper.h
+++ b/src/resources/sdlscreenshothelper.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RESOURCES_SDL2IMAGEHELPER_H
-#define RESOURCES_SDL2IMAGEHELPER_H
+#ifndef RESOURCES_SDLSCREENSHOTHELPER_H
+#define RESOURCES_SDLSCREENSHOTHELPER_H
#include "resources/screenshothelper.h"
@@ -36,11 +36,9 @@ class SdlScreenshotHelper final : public ScreenshotHelper
~SdlScreenshotHelper();
- void prepare(const int width,
- const int height) override final;
+ void prepare() override final;
- SDL_Surface *getScreenshot(const int width,
- const int height) override final;
+ SDL_Surface *getScreenshot() override final;
};
-#endif // RESOURCES_SDL2IMAGEHELPER_H
+#endif // RESOURCES_SDLSCREENSHOTHELPER_H