Mercurial > repos > blastem
diff render_sdl.c @ 1534:c59adc305e46 nuklear_ui
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 24 Mar 2018 22:18:23 -0700 |
parents | 855210dca5b9 b505083dcd87 |
children | ce1f93be0104 |
line wrap: on
line diff
--- a/render_sdl.c Tue Mar 13 22:18:20 2018 -0700 +++ b/render_sdl.c Sat Mar 24 22:18:23 2018 -0700 @@ -14,6 +14,7 @@ #include "io.h" #include "util.h" #include "ppm.h" +#include "png.h" #ifndef DISABLE_OPENGL #include <GL/glew.h> @@ -604,9 +605,13 @@ : 240; FILE *screenshot_file = NULL; uint32_t shot_height, shot_width; + char *ext; if (screenshot_path && which == FRAMEBUFFER_ODD) { screenshot_file = fopen(screenshot_path, "wb"); if (screenshot_file) { +#ifndef DISABLE_ZLIB + ext = path_extension(screenshot_path); +#endif info_message("Saving screenshot to %s\n", screenshot_path); } else { warning("Failed to open screenshot file %s for writing\n", screenshot_path); @@ -625,7 +630,17 @@ if (screenshot_file) { //properly supporting interlaced modes here is non-trivial, so only save the odd field for now - save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); +#ifndef DISABLE_ZLIB + if (!strcasecmp(ext, "png")) { + free(ext); + save_png(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); + } else { + free(ext); +#endif + save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); +#ifndef DISABLE_ZLIB + } +#endif } } else { #endif @@ -652,7 +667,17 @@ } else { shot_pitch *= 2; } - save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); +#ifndef DISABLE_ZLIB + if (!strcasecmp(ext, "png")) { + free(ext); + save_png(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); + } else { + free(ext); +#endif + save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); +#ifndef DISABLE_ZLIB + } +#endif } SDL_UnlockTexture(sdl_textures[which]); #ifndef DISABLE_OPENGL