From e2ba3b52ee0b745497fba2f7c47d95d807801d78 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 Dec 2011 23:35:34 +0100 Subject: Restore GL_PACK_ALIGNMENT after creating screenshots in OpenGL mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Yohann Ferreira --- src/openglgraphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2