From 78fb544aeb8761e8d554487487bc27e610822e2d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 16 Dec 2015 01:03:19 +0300 Subject: Use screenshort helpers for creating screenshots --- src/render/mobileopengl2graphics.cpp | 57 ------------------------------------ 1 file changed, 57 deletions(-) (limited to 'src/render/mobileopengl2graphics.cpp') diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp index 979d17224..9db0f07f4 100644 --- a/src/render/mobileopengl2graphics.cpp +++ b/src/render/mobileopengl2graphics.cpp @@ -860,63 +860,6 @@ void MobileOpenGL2Graphics::endDraw() popClipArea(); } -void MobileOpenGL2Graphics::prepareScreenshot() -{ - if (config.getBoolValue("usefbo")) - graphicsManager.createFBO(mRect.w, mRect.h, &mFbo); -} - -SDL_Surface* MobileOpenGL2Graphics::getScreenshot() -{ - const int h = mRect.h; - const int w = mRect.w - (mRect.w % 4); - GLint pack = 1; - - SDL_Surface *const screenshot = MSDL_CreateRGBSurface( - SDL_SWSURFACE, w, h, 24, - 0xff0000, 0x00ff00, 0x0000ff, 0x000000); - - if (!screenshot) - return nullptr; - - if (SDL_MUSTLOCK(screenshot)) - SDL_LockSurface(screenshot); - - const size_t lineSize = 3 * w; - GLubyte *const buf = new GLubyte[lineSize]; - - // Grap the pixel buffer and write it to the SDL surface - mglGetIntegerv(GL_PACK_ALIGNMENT, &pack); - mglPixelStorei(GL_PACK_ALIGNMENT, 1); - mglReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels); - - // Flip the screenshot, as OpenGL has 0,0 in bottom left - const int h2 = h / 2; - for (int i = 0; i < h2; i++) - { - GLubyte *const top = static_cast( - screenshot->pixels) + lineSize * i; - GLubyte *const bot = static_cast( - screenshot->pixels) + lineSize * (h - 1 - i); - - memcpy(buf, top, lineSize); - memcpy(top, bot, lineSize); - memcpy(bot, buf, lineSize); - } - - delete [] buf; - - if (config.getBoolValue("usefbo")) - graphicsManager.deleteFBO(&mFbo); - - mglPixelStorei(GL_PACK_ALIGNMENT, pack); - - if (SDL_MUSTLOCK(screenshot)) - SDL_UnlockSurface(screenshot); - - return screenshot; -} - void MobileOpenGL2Graphics::pushClipArea(const Rect &area) { Graphics::pushClipArea(area); -- cgit v1.2.3-60-g2f50