diff --git a/gfx/video_texture.c b/gfx/video_texture.c index 80ecf923f0..9caf01ea8f 100644 --- a/gfx/video_texture.c +++ b/gfx/video_texture.c @@ -121,3 +121,10 @@ unsigned video_texture_load(void *data, return video_texture_png_load(data, type, filter_type); } + +void video_texture_unload(uintptr_t *id) +{ + if (id) + glDeleteTextures(1, (const GLuint*)id); + *id = 0; +} diff --git a/gfx/video_texture.h b/gfx/video_texture.h index 9531207a1c..fd082cd34f 100644 --- a/gfx/video_texture.h +++ b/gfx/video_texture.h @@ -33,6 +33,8 @@ unsigned video_texture_load(void *data, enum texture_backend_type type, enum texture_filter_type filter_type); +void video_texture_unload(uintptr_t *id); + #ifdef __cplusplus } #endif diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 71ef219791..7b8fdd1efb 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -680,16 +680,11 @@ static void glui_free(void *data) static void glui_context_bg_destroy(glui_handle_t *glui) { - if (glui) - { - if (glui->textures.bg.id) - glDeleteTextures(1, (const GLuint*)&glui->textures.bg.id); - if (glui->textures.white) - glDeleteTextures(1, (const GLuint*)&glui->textures.white); + if (!glui) + return; - glui->textures.bg.id = 0; - glui->textures.white = 0; - } + video_texture_unload((uintptr_t*)&glui->textures.bg.id); + video_texture_unload((uintptr_t*)&glui->textures.white); } static void glui_context_destroy(void) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bd00dd26e3..92e212336d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1971,8 +1971,7 @@ static void xmb_free(void *data) static void xmb_context_bg_destroy(xmb_handle_t *xmb) { - if (xmb->textures.bg.id) - glDeleteTextures(1, (const GLuint*)&xmb->textures.bg.id); + video_texture_unload((uintptr_t*)&xmb->textures.bg.id); } static bool xmb_load_image(void *data, menu_image_type_t type) @@ -2547,8 +2546,8 @@ static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb, if (!node) continue; - glDeleteTextures(1, (const GLuint*)&node->icon); - glDeleteTextures(1, (const GLuint*)&node->content_icon); + video_texture_unload((uintptr_t*)&node->icon); + video_texture_unload((uintptr_t*)&node->content_icon); } } @@ -2567,7 +2566,7 @@ static void xmb_context_destroy(void) return; for (i = 0; i < XMB_TEXTURE_LAST; i++) - glDeleteTextures(1, (const GLuint*)&xmb->textures.list[i].id); + video_texture_unload((uintptr_t*)&xmb->textures.list[i].id); xmb_context_destroy_horizontal_list(xmb, menu); diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 0079dd5978..a70c6e7b54 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1023,14 +1023,8 @@ static void zarch_free(void *data) static void zarch_context_bg_destroy(zui_t *zarch) { - if (zarch->textures.bg.id) - glDeleteTextures(1, (const GLuint*)&zarch->textures.bg.id); - - if (zarch->textures.white) - glDeleteTextures(1, (const GLuint*)&zarch->textures.white); - - zarch->textures.bg.id = 0; - zarch->textures.white = 0; + video_texture_unload((uintptr_t*)&zarch->textures.bg.id); + video_texture_unload((uintptr_t*)&zarch->textures.white); } static void zarch_context_destroy(void)