Create video_texture_unload

This commit is contained in:
twinaphex 2015-10-25 02:33:23 +01:00
parent 74b7e13ba9
commit 5bd555ca50
5 changed files with 19 additions and 22 deletions

View File

@ -121,3 +121,10 @@ unsigned video_texture_load(void *data,
return video_texture_png_load(data, type, filter_type); 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;
}

View File

@ -33,6 +33,8 @@ unsigned video_texture_load(void *data,
enum texture_backend_type type, enum texture_backend_type type,
enum texture_filter_type filter_type); enum texture_filter_type filter_type);
void video_texture_unload(uintptr_t *id);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -680,16 +680,11 @@ static void glui_free(void *data)
static void glui_context_bg_destroy(glui_handle_t *glui) static void glui_context_bg_destroy(glui_handle_t *glui)
{ {
if (glui) if (!glui)
{ return;
if (glui->textures.bg.id)
glDeleteTextures(1, (const GLuint*)&glui->textures.bg.id);
if (glui->textures.white)
glDeleteTextures(1, (const GLuint*)&glui->textures.white);
glui->textures.bg.id = 0; video_texture_unload((uintptr_t*)&glui->textures.bg.id);
glui->textures.white = 0; video_texture_unload((uintptr_t*)&glui->textures.white);
}
} }
static void glui_context_destroy(void) static void glui_context_destroy(void)

View File

@ -1971,8 +1971,7 @@ static void xmb_free(void *data)
static void xmb_context_bg_destroy(xmb_handle_t *xmb) static void xmb_context_bg_destroy(xmb_handle_t *xmb)
{ {
if (xmb->textures.bg.id) video_texture_unload((uintptr_t*)&xmb->textures.bg.id);
glDeleteTextures(1, (const GLuint*)&xmb->textures.bg.id);
} }
static bool xmb_load_image(void *data, menu_image_type_t type) 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) if (!node)
continue; continue;
glDeleteTextures(1, (const GLuint*)&node->icon); video_texture_unload((uintptr_t*)&node->icon);
glDeleteTextures(1, (const GLuint*)&node->content_icon); video_texture_unload((uintptr_t*)&node->content_icon);
} }
} }
@ -2567,7 +2566,7 @@ static void xmb_context_destroy(void)
return; return;
for (i = 0; i < XMB_TEXTURE_LAST; i++) 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); xmb_context_destroy_horizontal_list(xmb, menu);

View File

@ -1023,14 +1023,8 @@ static void zarch_free(void *data)
static void zarch_context_bg_destroy(zui_t *zarch) static void zarch_context_bg_destroy(zui_t *zarch)
{ {
if (zarch->textures.bg.id) video_texture_unload((uintptr_t*)&zarch->textures.bg.id);
glDeleteTextures(1, (const GLuint*)&zarch->textures.bg.id); video_texture_unload((uintptr_t*)&zarch->textures.white);
if (zarch->textures.white)
glDeleteTextures(1, (const GLuint*)&zarch->textures.white);
zarch->textures.bg.id = 0;
zarch->textures.white = 0;
} }
static void zarch_context_destroy(void) static void zarch_context_destroy(void)