+@@ -644,36 +728,42 @@
+ {
+ // [Christoph] TODO: Yes, this method also takes care of the actual disk I/O. Split it?
+
+- // create surface to hold screenshot
+- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
+- SDL_Surface* shot_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 24, 0x00FF0000, 0x0000FF00, 0x000000FF, 0);
+- #else
+- SDL_Surface* shot_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
+- #endif
+- if (!shot_surf) {
+- log_warning << "Could not create RGB Surface to contain screenshot" << std::endl;
+- return;
+- }
++ SDL_Surface *shot_surf;
++ if(config->use_opengl) {
++ // create surface to hold screenshot
++ #if SDL_BYTEORDER == SDL_BIG_ENDIAN
++ shot_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 24, 0x00FF0000, 0x0000FF00, 0x000000FF, 0);
++ #else
++ shot_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
++ #endif
++ if (!shot_surf) {
++ log_warning << "Could not create RGB Surface to contain screenshot" << std::endl;
++ return;
++ }
+
+- // read pixels into array
+- char* pixels = new char[3 * SCREEN_WIDTH * SCREEN_HEIGHT];
+- if (!pixels) {
+- log_warning << "Could not allocate memory to store screenshot" << std::endl;
+- SDL_FreeSurface(shot_surf);
+- return;
+- }
+- glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
++ // read pixels into array
++ char* pixels = new char[3 * SCREEN_WIDTH * SCREEN_HEIGHT];
++ if (!pixels) {
++ log_warning << "Could not allocate memory to store screenshot" << std::endl;
++ SDL_FreeSurface(shot_surf);
++ return;
++ }
++ glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
+
+- // copy array line-by-line
+- for (int i = 0; i < SCREEN_HEIGHT; i++) {
+- char* src = pixels + (3 * SCREEN_WIDTH * (SCREEN_HEIGHT - i - 1));
+- char* dst = ((char*)shot_surf->pixels) + i * shot_surf->pitch;
+- memcpy(dst, src, 3 * SCREEN_WIDTH);
++ // copy array line-by-line
++ for (int i = 0; i < SCREEN_HEIGHT; i++) {
++ char* src = pixels + (3 * SCREEN_WIDTH * (SCREEN_HEIGHT - i - 1));
++ char* dst = ((char*)shot_surf->pixels) + i * shot_surf->pitch;
++ memcpy(dst, src, 3 * SCREEN_WIDTH);
++ }
++
++ // free array
++ delete[](pixels);
++ } else {
++ shot_surf = SDL_GetVideoSurface();
++ shot_surf->refcount++;
+ }
+
+- // free array
+- delete[](pixels);
+-
+ // save screenshot
+ static const std::string writeDir = PHYSFS_getWriteDir();
+ static const std::string dirSep = PHYSFS_getDirSeparator();