From c0deb826de0f955e6b18a40a4c69607351b78a38 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 16 Apr 2013 01:27:43 +0200 Subject: [PATCH] (RMenu) Backport shader_manager_init to RMenu --- frontend/menu/rmenu.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 850fb2599e..009bfccab3 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -3290,6 +3290,53 @@ int rmenu_iterate(rmenu_handle_t *rmenu, uint8_t menu_type, uint64_t input) return -1; } +#ifdef HAVE_SHADER_MANAGER +static void shader_manager_init(rmenu_handle_t *rgui) +{ + config_file_t *conf = NULL; + char cgp_path[PATH_MAX]; + + const char *ext = path_get_extension(g_settings.video.shader_path); + if (strcmp(ext, "glslp") == 0 || strcmp(ext, "cgp") == 0) + { + conf = config_file_new(g_settings.video.shader_path); + if (conf) + { + if (gfx_shader_read_conf_cgp(conf, &rgui->shader)) + gfx_shader_resolve_relative(&rgui->shader, g_settings.video.shader_path); + config_file_free(conf); + } + } + else if (strcmp(ext, "glsl") == 0 || strcmp(ext, "cg") == 0) + { + strlcpy(rgui->shader.pass[0].source.cg, g_settings.video.shader_path, + sizeof(rgui->shader.pass[0].source.cg)); + rgui->shader.passes = 1; + } + else + { + const char *shader_dir = *g_settings.video.shader_dir ? + g_settings.video.shader_dir : g_settings.system_directory; + + fill_pathname_join(cgp_path, shader_dir, "rgui.glslp", sizeof(cgp_path)); + conf = config_file_new(cgp_path); + + if (!conf) + { + fill_pathname_join(cgp_path, shader_dir, "rgui.cgp", sizeof(cgp_path)); + conf = config_file_new(cgp_path); + } + + if (conf) + { + if (gfx_shader_read_conf_cgp(conf, &rgui->shader)) + gfx_shader_resolve_relative(&rgui->shader, cgp_path); + config_file_free(conf); + } + } +} +#endif + rmenu_handle_t *rmenu_init(void) { rmenu_handle_t *rmenu = (rmenu_handle_t*)calloc(1, sizeof(*rmenu)); @@ -3303,6 +3350,10 @@ rmenu_handle_t *rmenu_init(void) filebrowser_iterate(rmenu->browser, FILEBROWSER_ACTION_RESET); +#ifdef HAVE_SHADER_MANAGER + shader_manager_init(rmenu); +#endif + return rmenu; }