X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fscreen.cpp;h=5f32f0d3bc546acf5c61dd1fee34ea097caa242f;hp=683da4a6322aa03c3e9725198054534deb2d7607;hb=4f0feb025e48aaaa0ffe0226c5135e116d1cb986;hpb=5a72624d0293ca0881eea873490269cf61a5f762 diff --git a/src/screen.cpp b/src/screen.cpp index 683da4a..5f32f0d 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -129,13 +129,17 @@ void Screen::ScreenShot(const char * filename) const int w = ViewportWidth(); int h = ViewportHeight(); - unsigned char * pixels = new unsigned char[w*h*3]; + unsigned char * pixels = new unsigned char[w*h*4]; if (pixels == NULL) - Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*3); + 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); - SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*3, w*3, 0,0,0,0); + SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0,0,0,0); if (surf == NULL) Fatal("Failed to create SDL_Surface from pixel data - %s", SDL_GetError());