Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
1528:855210dca5b9 | 1534:c59adc305e46 |
---|---|
12 #include "blastem.h" | 12 #include "blastem.h" |
13 #include "genesis.h" | 13 #include "genesis.h" |
14 #include "io.h" | 14 #include "io.h" |
15 #include "util.h" | 15 #include "util.h" |
16 #include "ppm.h" | 16 #include "ppm.h" |
17 #include "png.h" | |
17 | 18 |
18 #ifndef DISABLE_OPENGL | 19 #ifndef DISABLE_OPENGL |
19 #include <GL/glew.h> | 20 #include <GL/glew.h> |
20 #endif | 21 #endif |
21 | 22 |
602 uint32_t height = which <= FRAMEBUFFER_EVEN | 603 uint32_t height = which <= FRAMEBUFFER_EVEN |
603 ? (video_standard == VID_NTSC ? 243 : 294) - (overscan_top[video_standard] + overscan_bot[video_standard]) | 604 ? (video_standard == VID_NTSC ? 243 : 294) - (overscan_top[video_standard] + overscan_bot[video_standard]) |
604 : 240; | 605 : 240; |
605 FILE *screenshot_file = NULL; | 606 FILE *screenshot_file = NULL; |
606 uint32_t shot_height, shot_width; | 607 uint32_t shot_height, shot_width; |
608 char *ext; | |
607 if (screenshot_path && which == FRAMEBUFFER_ODD) { | 609 if (screenshot_path && which == FRAMEBUFFER_ODD) { |
608 screenshot_file = fopen(screenshot_path, "wb"); | 610 screenshot_file = fopen(screenshot_path, "wb"); |
609 if (screenshot_file) { | 611 if (screenshot_file) { |
612 #ifndef DISABLE_ZLIB | |
613 ext = path_extension(screenshot_path); | |
614 #endif | |
610 info_message("Saving screenshot to %s\n", screenshot_path); | 615 info_message("Saving screenshot to %s\n", screenshot_path); |
611 } else { | 616 } else { |
612 warning("Failed to open screenshot file %s for writing\n", screenshot_path); | 617 warning("Failed to open screenshot file %s for writing\n", screenshot_path); |
613 } | 618 } |
614 free(screenshot_path); | 619 free(screenshot_path); |
623 glBindTexture(GL_TEXTURE_2D, textures[which]); | 628 glBindTexture(GL_TEXTURE_2D, textures[which]); |
624 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LINEBUF_SIZE, height, GL_BGRA, GL_UNSIGNED_BYTE, texture_buf + overscan_left[video_standard] + LINEBUF_SIZE * overscan_top[video_standard]); | 629 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LINEBUF_SIZE, height, GL_BGRA, GL_UNSIGNED_BYTE, texture_buf + overscan_left[video_standard] + LINEBUF_SIZE * overscan_top[video_standard]); |
625 | 630 |
626 if (screenshot_file) { | 631 if (screenshot_file) { |
627 //properly supporting interlaced modes here is non-trivial, so only save the odd field for now | 632 //properly supporting interlaced modes here is non-trivial, so only save the odd field for now |
628 save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); | 633 #ifndef DISABLE_ZLIB |
634 if (!strcasecmp(ext, "png")) { | |
635 free(ext); | |
636 save_png(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); | |
637 } else { | |
638 free(ext); | |
639 #endif | |
640 save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); | |
641 #ifndef DISABLE_ZLIB | |
642 } | |
643 #endif | |
629 } | 644 } |
630 } else { | 645 } else { |
631 #endif | 646 #endif |
632 if (which <= FRAMEBUFFER_EVEN && last != which) { | 647 if (which <= FRAMEBUFFER_EVEN && last != which) { |
633 uint8_t *cur_dst = (uint8_t *)locked_pixels; | 648 uint8_t *cur_dst = (uint8_t *)locked_pixels; |
650 if (which == FRAMEBUFFER_EVEN) { | 665 if (which == FRAMEBUFFER_EVEN) { |
651 shot_height *= 2; | 666 shot_height *= 2; |
652 } else { | 667 } else { |
653 shot_pitch *= 2; | 668 shot_pitch *= 2; |
654 } | 669 } |
655 save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); | 670 #ifndef DISABLE_ZLIB |
671 if (!strcasecmp(ext, "png")) { | |
672 free(ext); | |
673 save_png(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); | |
674 } else { | |
675 free(ext); | |
676 #endif | |
677 save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); | |
678 #ifndef DISABLE_ZLIB | |
679 } | |
680 #endif | |
656 } | 681 } |
657 SDL_UnlockTexture(sdl_textures[which]); | 682 SDL_UnlockTexture(sdl_textures[which]); |
658 #ifndef DISABLE_OPENGL | 683 #ifndef DISABLE_OPENGL |
659 } | 684 } |
660 #endif | 685 #endif |