From 312154d1101493e0805e694dedb8db9872ff1b18 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 16 Jun 2013 13:44:07 +0200 Subject: [PATCH] Use common rarch_take_screenshot in RGUI. Adds GPU screenshot support from RGUI by rendering a clean frame then taking screenshot. Should also fix screenshot crash when using GL cores. Always uses g_settings.screenshot_directory path. I didn't see the purpose of the RARCH_CONSOLE #ifdef. Probably a Wii hack from way back ... --- frontend/menu/rgui.c | 28 +++++++++------------------- general.h | 1 + retroarch.c | 4 ++-- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 928337e84d..7ea5275d83 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -993,25 +993,15 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r case RGUI_SETTINGS_SCREENSHOT: if (action == RGUI_ACTION_OK) { - const void *data = g_extern.frame_cache.data; - unsigned width = g_extern.frame_cache.width; - unsigned height = g_extern.frame_cache.height; - int pitch = g_extern.frame_cache.pitch; - -#ifdef RARCH_CONSOLE - const char *screenshot_dir = default_paths.port_dir; -#else - const char *screenshot_dir = g_settings.screenshot_directory; -#endif - - // Negative pitch is needed as screenshot takes bottom-up, - // but we use top-down. - bool r = screenshot_dump(screenshot_dir, - (const uint8_t*)data + (height - 1) * pitch, - width, height, -pitch, false); - - msg_queue_push(g_extern.msg_queue, - r ? "Screenshot saved." : "Screenshot failed to save.", 1, 90); + // Render a clean frame to avoid taking screnshot of RGUI. + if (g_settings.video.gpu_screenshot) + { + if (driver.video_poke && driver.video_poke->set_texture_enable) + driver.video_poke->set_texture_enable(driver.video_data, false, false); + if (driver.video) + rarch_render_cached_frame(); + } + rarch_take_screenshot(); } break; #endif diff --git a/general.h b/general.h index 66b4ba0da8..11016128a4 100644 --- a/general.h +++ b/general.h @@ -680,6 +680,7 @@ void rarch_disk_control_set_index(unsigned index); void rarch_disk_control_append_image(const char *path); void rarch_init_autosave(void); void rarch_deinit_autosave(void); +void rarch_take_screenshot(void); void rarch_load_state(void); void rarch_save_state(void); diff --git a/retroarch.c b/retroarch.c index e0e1cc92d0..9b51570073 100644 --- a/retroarch.c +++ b/retroarch.c @@ -119,7 +119,7 @@ static bool take_screenshot_raw(void) width, height, -pitch, false); } -static void take_screenshot(void) +void rarch_take_screenshot(void) { if (!(*g_settings.screenshot_directory)) return; @@ -2540,7 +2540,7 @@ static void check_screenshot(void) static bool old_pressed; bool pressed = input_key_pressed_func(RARCH_SCREENSHOT); if (pressed && !old_pressed) - take_screenshot(); + rarch_take_screenshot(); old_pressed = pressed; }