int I_ScreenShot (const char *fname) { #ifdef GL_DOOM if (V_GetMode() == VID_MODEGL) { int result = -1; unsigned char *pixel_data = gld_ReadScreen(); if (pixel_data) { SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( pixel_data, SCREENWIDTH, SCREENHEIGHT, 24, SCREENWIDTH*3, 0x000000ff, 0x0000ff00, 0x00ff0000, 0); if (surface) { result = SAVE_PNG_OR_BMP(surface, fname); SDL_FreeSurface(surface); } free(pixel_data); } return result; } else #endif return SAVE_PNG_OR_BMP(SDL_GetVideoSurface(), fname); }
static int screenshot_gl(png_struct *png_ptr, png_info *info_ptr) { unsigned char *pixel_data = gld_ReadScreen(); if (pixel_data) { int y; png_write_info(png_ptr, info_ptr); for (y = 0; y < SCREENHEIGHT; y++) png_write_row(png_ptr, pixel_data + y*SCREENWIDTH*3); png_write_end(png_ptr, info_ptr); free(pixel_data); return 0; } else return -1; }