diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-12-26 01:35:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-12-26 01:35:34 +0300 |
commit | cf542c3602eae931066d8b6e46d90109c8b2c13e (patch) | |
tree | 9e12421ad033cb0247a30b170487732fd2db2cb6 | |
parent | 1f3217e483d05d4af612e8192598d7a0c111f93c (diff) | |
download | plus-cf542c3602eae931066d8b6e46d90109c8b2c13e.tar.gz plus-cf542c3602eae931066d8b6e46d90109c8b2c13e.tar.bz2 plus-cf542c3602eae931066d8b6e46d90109c8b2c13e.tar.xz plus-cf542c3602eae931066d8b6e46d90109c8b2c13e.zip |
Restore GL_PACK_ALIGNMENT after creating screenshots in opengl modes.
-rw-r--r-- | src/opengl1graphics.cpp | 4 | ||||
-rw-r--r-- | src/openglgraphics.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index 1f1a0231d..e8c972522 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -474,6 +474,7 @@ SDL_Surface* OpenGL1Graphics::getScreenshot() { int h = mTarget->h; int w = mTarget->w; + GLint pack = 1; SDL_Surface *screenshot = SDL_CreateRGBSurface( SDL_SWSURFACE, @@ -484,6 +485,7 @@ SDL_Surface* OpenGL1Graphics::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); @@ -505,6 +507,8 @@ SDL_Surface* OpenGL1Graphics::getScreenshot() free(buf); + glPixelStorei(GL_PACK_ALIGNMENT, pack); + if (SDL_MUSTLOCK(screenshot)) SDL_UnlockSurface(screenshot); diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index f5e9f8107..a8eb5d010 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -1020,6 +1020,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot() { int h = mTarget->h; int w = mTarget->w; + GLint pack = 1; SDL_Surface *screenshot = SDL_CreateRGBSurface( SDL_SWSURFACE, @@ -1033,6 +1034,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); @@ -1054,6 +1056,8 @@ SDL_Surface* OpenGLGraphics::getScreenshot() free(buf); + glPixelStorei(GL_PACK_ALIGNMENT, pack); + if (SDL_MUSTLOCK(screenshot)) SDL_UnlockSurface(screenshot); |