summaryrefslogtreecommitdiff
path: root/src/openglgraphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-12-25 23:35:34 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-16 19:06:04 +0100
commite2ba3b52ee0b745497fba2f7c47d95d807801d78 (patch)
tree3e8375bceb0a5a785eea1e44a1e25199562acf15 /src/openglgraphics.cpp
parent76c4c74f1ea3e03d4617de6504c3cb72572f31f4 (diff)
downloadmana-e2ba3b52ee0b745497fba2f7c47d95d807801d78.tar.gz
mana-e2ba3b52ee0b745497fba2f7c47d95d807801d78.tar.bz2
mana-e2ba3b52ee0b745497fba2f7c47d95d807801d78.tar.xz
mana-e2ba3b52ee0b745497fba2f7c47d95d807801d78.zip
Restore GL_PACK_ALIGNMENT after creating screenshots in OpenGL mode
Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/openglgraphics.cpp')
-rw-r--r--src/openglgraphics.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index 84f499a4..e2fd9397 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -660,6 +660,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot()
{
int h = mTarget->h;
int w = mTarget->w;
+ GLint pack = 1;
SDL_Surface *screenshot = SDL_CreateRGBSurface(
SDL_SWSURFACE,
@@ -670,6 +671,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot()
SDL_LockSurface(screenshot);
// Grap the pixel buffer and write it to the SDL surface
+ glGetIntegerv(GL_PACK_ALIGNMENT, &pack);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels);
@@ -689,6 +691,8 @@ SDL_Surface* OpenGLGraphics::getScreenshot()
free(buf);
+ glPixelStorei(GL_PACK_ALIGNMENT, pack);
+
if (SDL_MUSTLOCK(screenshot))
SDL_UnlockSurface(screenshot);