comparison render_sdl.c @ 1336:baaf05fd64c4

Make internal screenshot functionality completely ignore overscan settings rather than only doing it for the height
author Michael Pavone <pavone@retrodev.com>
date Sat, 29 Apr 2017 12:32:50 -0700
parents 70faad89d491
children 03cb4dd2499f
comparison
equal deleted inserted replaced
1335:26e72126f9d1 1336:baaf05fd64c4
562 { 562 {
563 static uint8_t last; 563 static uint8_t last;
564 uint32_t height = which <= FRAMEBUFFER_EVEN 564 uint32_t height = which <= FRAMEBUFFER_EVEN
565 ? (video_standard == VID_NTSC ? 243 : 294) - (overscan_top[video_standard] + overscan_bot[video_standard]) 565 ? (video_standard == VID_NTSC ? 243 : 294) - (overscan_top[video_standard] + overscan_bot[video_standard])
566 : 240; 566 : 240;
567 width -= overscan_left[video_standard] + overscan_right[video_standard];
568 FILE *screenshot_file = NULL; 567 FILE *screenshot_file = NULL;
569 uint32_t shot_height; 568 uint32_t shot_height, shot_width;
570 if (screenshot_path && which == FRAMEBUFFER_ODD) { 569 if (screenshot_path && which == FRAMEBUFFER_ODD) {
571 screenshot_file = fopen(screenshot_path, "wb"); 570 screenshot_file = fopen(screenshot_path, "wb");
572 if (screenshot_file) { 571 if (screenshot_file) {
573 info_message("Saving screenshot to %s\n", screenshot_path); 572 info_message("Saving screenshot to %s\n", screenshot_path);
574 } else { 573 } else {
575 warning("Failed to open screenshot file %s for writing\n", screenshot_path); 574 warning("Failed to open screenshot file %s for writing\n", screenshot_path);
576 } 575 }
577 free(screenshot_path); 576 free(screenshot_path);
578 screenshot_path = NULL; 577 screenshot_path = NULL;
579 shot_height = video_standard == VID_NTSC ? 243 : 294; 578 shot_height = video_standard == VID_NTSC ? 243 : 294;
580 } 579 shot_width = width;
580 }
581 width -= overscan_left[video_standard] + overscan_right[video_standard];
581 #ifndef DISABLE_OPENGL 582 #ifndef DISABLE_OPENGL
582 if (render_gl && which <= FRAMEBUFFER_EVEN) { 583 if (render_gl && which <= FRAMEBUFFER_EVEN) {
583 glBindTexture(GL_TEXTURE_2D, textures[which]); 584 glBindTexture(GL_TEXTURE_2D, textures[which]);
584 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]); 585 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]);
585 586
609 610
610 SDL_GL_SwapWindow(main_window); 611 SDL_GL_SwapWindow(main_window);
611 612
612 if (screenshot_file) { 613 if (screenshot_file) {
613 //properly supporting interlaced modes here is non-trivial, so only save the odd field for now 614 //properly supporting interlaced modes here is non-trivial, so only save the odd field for now
614 save_ppm(screenshot_file, texture_buf, width, shot_height, LINEBUF_SIZE*sizeof(uint32_t)); 615 save_ppm(screenshot_file, texture_buf, shot_width, shot_height, LINEBUF_SIZE*sizeof(uint32_t));
615 } 616 }
616 } else { 617 } else {
617 #endif 618 #endif
618 if (which <= FRAMEBUFFER_EVEN && last != which) { 619 if (which <= FRAMEBUFFER_EVEN && last != which) {
619 uint8_t *cur_dst = (uint8_t *)locked_pixels; 620 uint8_t *cur_dst = (uint8_t *)locked_pixels;
636 if (which == FRAMEBUFFER_EVEN) { 637 if (which == FRAMEBUFFER_EVEN) {
637 shot_height *= 2; 638 shot_height *= 2;
638 } else { 639 } else {
639 shot_pitch *= 2; 640 shot_pitch *= 2;
640 } 641 }
641 save_ppm(screenshot_file, locked_pixels, width, shot_height, shot_pitch); 642 save_ppm(screenshot_file, locked_pixels, shot_width, shot_height, shot_pitch);
642 } 643 }
643 SDL_UnlockTexture(sdl_textures[which]); 644 SDL_UnlockTexture(sdl_textures[which]);
644 SDL_Rect src_clip = { 645 SDL_Rect src_clip = {
645 .x = overscan_left[video_standard], 646 .x = overscan_left[video_standard],
646 .y = overscan_top[video_standard], 647 .y = overscan_top[video_standard],