From 5a72624d0293ca0881eea873490269cf61a5f762 Mon Sep 17 00:00:00 2001 From: Sam Moore Date: Thu, 17 Apr 2014 13:02:02 +0800 Subject: [PATCH] Fix colour in ScreenShot GL_RGBA -> GL_BGRA Although... should probably have a means to detect which it is supposed to be since it might be different on other machines? --- src/screen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/screen.cpp b/src/screen.cpp index 712bd26..683da4a 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -129,13 +129,13 @@ void Screen::ScreenShot(const char * filename) const int w = ViewportWidth(); int h = ViewportHeight(); - unsigned char * pixels = new unsigned char[w*h*4]; + unsigned char * pixels = new unsigned char[w*h*3]; if (pixels == NULL) - Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*4); + Fatal("Failed to allocate %d x %d x 4 = %d pixel array", w, h, w*h*3); - glReadPixels(0,0,w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + glReadPixels(0,0,w, h, GL_BGRA, GL_UNSIGNED_BYTE, pixels); - SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*4, w*4, 0,0,0,0); + SDL_Surface * surf = SDL_CreateRGBSurfaceFrom(pixels, w, h, 8*3, w*3, 0,0,0,0); if (surf == NULL) Fatal("Failed to create SDL_Surface from pixel data - %s", SDL_GetError()); -- 2.20.1