Mercurial > repos > blastem
comparison render_sdl.c @ 2368:d6a207861cc8
Fix handling of overscan in internal screenshots
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 10 Nov 2023 13:45:23 -0800 |
parents | 0111c8344477 |
children | 6bcc2ab01ac6 |
comparison
equal
deleted
inserted
replaced
2367:48cc69b4c358 | 2368:d6a207861cc8 |
---|---|
1584 last_width = width; | 1584 last_width = width; |
1585 uint32_t height = which <= FRAMEBUFFER_EVEN | 1585 uint32_t height = which <= FRAMEBUFFER_EVEN |
1586 ? (video_standard == VID_PAL ? 294 : 243) - (overscan_top[video_standard] + overscan_bot[video_standard]) | 1586 ? (video_standard == VID_PAL ? 294 : 243) - (overscan_top[video_standard] + overscan_bot[video_standard]) |
1587 : 240; | 1587 : 240; |
1588 FILE *screenshot_file = NULL; | 1588 FILE *screenshot_file = NULL; |
1589 uint32_t shot_height, shot_width; | |
1590 char *ext; | 1589 char *ext; |
1590 width -= overscan_left[video_standard] + overscan_right[video_standard]; | |
1591 if (screenshot_path && which == FRAMEBUFFER_ODD) { | 1591 if (screenshot_path && which == FRAMEBUFFER_ODD) { |
1592 screenshot_file = fopen(screenshot_path, "wb"); | 1592 screenshot_file = fopen(screenshot_path, "wb"); |
1593 if (screenshot_file) { | 1593 if (screenshot_file) { |
1594 #ifndef DISABLE_ZLIB | 1594 #ifndef DISABLE_ZLIB |
1595 ext = path_extension(screenshot_path); | 1595 ext = path_extension(screenshot_path); |
1598 } else { | 1598 } else { |
1599 warning("Failed to open screenshot file %s for writing\n", screenshot_path); | 1599 warning("Failed to open screenshot file %s for writing\n", screenshot_path); |
1600 } | 1600 } |
1601 free(screenshot_path); | 1601 free(screenshot_path); |
1602 screenshot_path = NULL; | 1602 screenshot_path = NULL; |
1603 shot_height = height; | |
1604 shot_width = width; | |
1605 } | 1603 } |
1606 interlaced = last != which; | 1604 interlaced = last != which; |
1607 width -= overscan_left[video_standard] + overscan_right[video_standard]; | 1605 buffer += overscan_left[video_standard] + LINEBUF_SIZE * overscan_top[video_standard]; |
1608 #ifndef DISABLE_OPENGL | 1606 #ifndef DISABLE_OPENGL |
1609 if (render_gl && which <= FRAMEBUFFER_EVEN) { | 1607 if (render_gl && which <= FRAMEBUFFER_EVEN) { |
1610 SDL_GL_MakeCurrent(main_window, main_context); | 1608 SDL_GL_MakeCurrent(main_window, main_context); |
1611 glBindTexture(GL_TEXTURE_2D, textures[which]); | 1609 glBindTexture(GL_TEXTURE_2D, textures[which]); |
1612 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LINEBUF_SIZE, height, SRC_FORMAT, GL_UNSIGNED_BYTE, buffer + overscan_left[video_standard] + LINEBUF_SIZE * overscan_top[video_standard]); | 1610 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LINEBUF_SIZE, height, SRC_FORMAT, GL_UNSIGNED_BYTE, buffer); |
1613 | 1611 |
1614 if (screenshot_file) { | 1612 if (screenshot_file) { |
1615 //properly supporting interlaced modes here is non-trivial, so only save the odd field for now | 1613 //properly supporting interlaced modes here is non-trivial, so only save the odd field for now |
1616 #ifndef DISABLE_ZLIB | 1614 #ifndef DISABLE_ZLIB |
1617 if (!strcasecmp(ext, "png")) { | 1615 if (!strcasecmp(ext, "png")) { |
1618 free(ext); | 1616 free(ext); |
1619 save_png(screenshot_file, buffer, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); | 1617 save_png(screenshot_file, buffer, width, height, LINEBUF_SIZE*sizeof(uint32_t)); |
1620 } else { | 1618 } else { |
1621 free(ext); | 1619 free(ext); |
1622 #endif | 1620 #endif |
1623 save_ppm(screenshot_file, buffer, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); | 1621 save_ppm(screenshot_file, buffer, width, height, LINEBUF_SIZE*sizeof(uint32_t)); |
1624 #ifndef DISABLE_ZLIB | 1622 #ifndef DISABLE_ZLIB |
1625 } | 1623 } |
1626 #endif | 1624 #endif |
1627 } | 1625 } |
1628 #ifndef DISABLE_ZLIB | 1626 #ifndef DISABLE_ZLIB |
1629 if (apng_file) { | 1627 if (apng_file) { |
1630 if (!apng) { | 1628 if (!apng) { |
1631 //TODO: more precise frame rate | 1629 //TODO: more precise frame rate |
1632 apng = start_apng(apng_file, width, height, video_standard == VID_PAL ? 50.0 : 60.0); | 1630 apng = start_apng(apng_file, width, height, video_standard == VID_PAL ? 50.0 : 60.0); |
1633 } | 1631 } |
1634 save_png24_frame( | 1632 save_png24_frame(apng_file, buffer, apng, width, height, LINEBUF_SIZE*sizeof(uint32_t)); |
1635 apng_file, | |
1636 buffer + overscan_left[video_standard] + LINEBUF_SIZE * overscan_top[video_standard], | |
1637 apng, width, height, LINEBUF_SIZE*sizeof(uint32_t) | |
1638 ); | |
1639 } | 1633 } |
1640 #endif | 1634 #endif |
1641 } else { | 1635 } else { |
1642 #endif | 1636 #endif |
1637 uint32_t shot_height = height; | |
1643 //TODO: Support SYNC_AUDIO_THREAD/SYNC_EXTERNAL for render API framebuffers | 1638 //TODO: Support SYNC_AUDIO_THREAD/SYNC_EXTERNAL for render API framebuffers |
1644 if (which <= FRAMEBUFFER_EVEN && last != which) { | 1639 if (which <= FRAMEBUFFER_EVEN && last != which) { |
1645 uint8_t *cur_dst = (uint8_t *)locked_pixels; | 1640 uint8_t *cur_dst = (uint8_t *)locked_pixels; |
1646 uint8_t *cur_saved = (uint8_t *)texture_buf; | 1641 uint8_t *cur_saved = (uint8_t *)texture_buf; |
1647 uint32_t dst_off = which == FRAMEBUFFER_EVEN ? 0 : locked_pitch; | 1642 uint32_t dst_off = which == FRAMEBUFFER_EVEN ? 0 : locked_pitch; |
1665 shot_pitch *= 2; | 1660 shot_pitch *= 2; |
1666 } | 1661 } |
1667 #ifndef DISABLE_ZLIB | 1662 #ifndef DISABLE_ZLIB |
1668 if (!strcasecmp(ext, "png")) { | 1663 if (!strcasecmp(ext, "png")) { |
1669 free(ext); | 1664 free(ext); |
1670 save_png(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); | 1665 save_png(screenshot_file, locked_pixels, width, shot_height, shot_pitch); |
1671 } else { | 1666 } else { |
1672 free(ext); | 1667 free(ext); |
1673 #endif | 1668 #endif |
1674 save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch); | 1669 save_ppm(screenshot_file, locked_pixels, width, shot_height, shot_pitch); |
1675 #ifndef DISABLE_ZLIB | 1670 #ifndef DISABLE_ZLIB |
1676 } | 1671 } |
1677 #endif | 1672 #endif |
1678 } | 1673 } |
1679 SDL_UnlockTexture(sdl_textures[which]); | 1674 SDL_UnlockTexture(sdl_textures[which]); |