From: Sam Moore Date: Thu, 17 Apr 2014 06:31:36 +0000 (+0800) Subject: Merge branch 'master' of git.ucc.asn.au:/ipdf/code X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=029e93dad12c51c69e47aa74dcc39f84d315bca3;p=ipdf%2Fcode.git Merge branch 'master' of git.ucc.asn.au:/ipdf/code Conflicts: src/screen.cpp David's way is better. --- 029e93dad12c51c69e47aa74dcc39f84d315bca3 diff --cc src/main.h index 7cfa22c,9fcc26b..f1a0172 --- a/src/main.h +++ b/src/main.h @@@ -13,12 -13,11 +13,13 @@@ inline void OverlayBMP(Document & doc, { View view(doc, bounds, c); Screen scr; - //view.Render(); scr.RenderBMP(input); - scr.Present(); + view.Render(); - scr.Present(); - sleep(5); + sleep(1); scr.ScreenShot(output); ++ scr.Present(); ++ + sleep(1); } inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const Colour & c = Colour(0.f,0.f,0.f,1.f)) diff --cc src/screen.cpp index 5f32f0d,59d4334..01e7364 --- a/src/screen.cpp +++ b/src/screen.cpp @@@ -133,13 -139,16 +139,17 @@@ void Screen::ScreenShot(const char * fi if (pixels == NULL) Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*4); + - glReadBuffer(GL_FRONT); - glPixelStorei(GL_PACK_ALIGNMENT, 1); - - glReadPixels(0,0,w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels); + for (int y = 0; y < h; ++y) + { + glReadPixels(0,h-y-1,w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[y*w*4]); + } - SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0,0,0,0); + #if SDL_BYTEORDER == SDL_LIL_ENDIAN + SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0x000000ff,0x0000ff00,0x00ff0000,0xff000000); + #else + SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0xff000000,0x00ff0000,0x0000ff00,0x000000ff); + #endif if (surf == NULL) Fatal("Failed to create SDL_Surface from pixel data - %s", SDL_GetError());