mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 11:18:25 +00:00
(GLUI) Hookup load_wallpaper - and also free background image
at exit
This commit is contained in:
parent
e58c1491a2
commit
f3315c256e
@ -38,7 +38,14 @@ typedef struct glui_handle
|
||||
unsigned term_width;
|
||||
unsigned term_height;
|
||||
char box_message[PATH_MAX_LENGTH];
|
||||
GLuint bg;
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
GLuint id;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
} bg;
|
||||
} textures;
|
||||
} glui_handle_t;
|
||||
|
||||
static int glui_entry_iterate(menu_handle_t *menu, unsigned action)
|
||||
@ -124,10 +131,10 @@ static void glui_render_background(gl_t *gl, glui_handle_t *glui,
|
||||
if ((g_settings.menu.pause_libretro
|
||||
|| !g_extern.main_is_init || g_extern.libretro_dummy)
|
||||
&& !force_transparency
|
||||
&& glui->bg)
|
||||
&& glui->textures.bg.id)
|
||||
{
|
||||
coords.color = color;
|
||||
glBindTexture(GL_TEXTURE_2D, glui->bg);
|
||||
glBindTexture(GL_TEXTURE_2D, glui->textures.bg.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -445,7 +452,7 @@ static void *glui_init(void)
|
||||
goto error;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
glui->bg = 0;
|
||||
glui->textures.bg.id = 0;
|
||||
|
||||
return menu;
|
||||
error:
|
||||
@ -466,9 +473,9 @@ static void glui_free(void *data)
|
||||
}
|
||||
|
||||
|
||||
static void glui_context_reset(menu_handle_t *menu)
|
||||
|
||||
static void glui_context_destroy(menu_handle_t *menu)
|
||||
{
|
||||
char bgpath[PATH_MAX_LENGTH];
|
||||
glui_handle_t *glui = NULL;
|
||||
|
||||
if (!menu)
|
||||
@ -479,18 +486,60 @@ static void glui_context_reset(menu_handle_t *menu)
|
||||
if (!glui)
|
||||
return;
|
||||
|
||||
fill_pathname_join(bgpath, g_settings.assets_directory,
|
||||
"glui", sizeof(bgpath));
|
||||
if (glui->textures.bg.id)
|
||||
glDeleteTextures(1, &glui->textures.bg.id);
|
||||
}
|
||||
|
||||
static bool glui_load_wallpaper(menu_handle_t *menu, const char *path)
|
||||
{
|
||||
glui_handle_t *glui = NULL;
|
||||
|
||||
if (!menu)
|
||||
return false;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
return false;
|
||||
if (!path)
|
||||
return false;
|
||||
|
||||
if (glui->textures.bg.id)
|
||||
glDeleteTextures(1, &glui->textures.bg.id);
|
||||
|
||||
strlcpy(glui->textures.bg.path, path, sizeof(glui->textures.bg.path));
|
||||
|
||||
glui->textures.bg.id = menu_texture_load(glui->textures.bg.path,
|
||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void glui_context_reset(menu_handle_t *menu)
|
||||
{
|
||||
glui_handle_t *glui = NULL;
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
return;
|
||||
|
||||
fill_pathname_join(glui->textures.bg.path, g_settings.assets_directory,
|
||||
"glui", sizeof(glui->textures.bg.path));
|
||||
|
||||
if (*g_settings.menu.wallpaper)
|
||||
strlcpy(bgpath, g_settings.menu.wallpaper, sizeof(bgpath));
|
||||
strlcpy(glui->textures.bg.path,
|
||||
g_settings.menu.wallpaper, sizeof(glui->textures.bg.path));
|
||||
else
|
||||
fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath));
|
||||
fill_pathname_join(glui->textures.bg.path,
|
||||
glui->textures.bg.path, "bg.png",
|
||||
sizeof(glui->textures.bg.path));
|
||||
|
||||
if (path_file_exists(bgpath))
|
||||
glui->bg = (GLuint)menu_texture_load(bgpath,
|
||||
TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_FILTER_LINEAR);
|
||||
if (path_file_exists(glui->textures.bg.path))
|
||||
glui_load_wallpaper(driver.menu, glui->textures.bg.path);
|
||||
}
|
||||
|
||||
static void glui_navigation_clear(menu_handle_t *menu, bool pending_push)
|
||||
@ -548,7 +597,7 @@ menu_ctx_driver_t menu_ctx_glui = {
|
||||
glui_init,
|
||||
glui_free,
|
||||
glui_context_reset,
|
||||
NULL,
|
||||
glui_context_destroy,
|
||||
NULL,
|
||||
NULL,
|
||||
glui_navigation_clear,
|
||||
@ -564,6 +613,6 @@ menu_ctx_driver_t menu_ctx_glui = {
|
||||
NULL,
|
||||
NULL,
|
||||
glui_entry_iterate,
|
||||
NULL,
|
||||
glui_load_wallpaper,
|
||||
"glui",
|
||||
};
|
||||
|
@ -1284,7 +1284,7 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver,
|
||||
font_path, xmb_font_size);
|
||||
}
|
||||
|
||||
static bool xmb_load_background(menu_handle_t *menu, const char *path)
|
||||
static bool xmb_load_wallpaper(menu_handle_t *menu, const char *path)
|
||||
{
|
||||
xmb_handle_t *xmb = NULL;
|
||||
|
||||
@ -1398,7 +1398,7 @@ static void xmb_context_reset(menu_handle_t *menu)
|
||||
xmb->textures.list[k].id = menu_texture_load(xmb->textures.list[k].path,
|
||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
||||
|
||||
xmb_load_background(driver.menu, xmb->textures.bg.path);
|
||||
xmb_load_wallpaper(driver.menu, xmb->textures.bg.path);
|
||||
|
||||
xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id;
|
||||
xmb->settings_node.alpha = xmb->categories.active.alpha;
|
||||
@ -1692,6 +1692,6 @@ menu_ctx_driver_t menu_ctx_xmb = {
|
||||
xmb_list_cache,
|
||||
NULL,
|
||||
xmb_entry_iterate,
|
||||
xmb_load_background,
|
||||
xmb_load_wallpaper,
|
||||
"xmb",
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user