mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Have XMB and GLUI reuse same menu_texture code
This commit is contained in:
parent
4186d97281
commit
04022926bc
@ -525,7 +525,8 @@ static void glui_context_reset(void *data)
|
||||
fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath));
|
||||
|
||||
if (path_file_exists(bgpath))
|
||||
glui->bg = (GLuint)menu_texture_load(bgpath, TEXTURE_BACKEND_OPENGL);
|
||||
glui->bg = (GLuint)menu_texture_load(bgpath, TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_FILTER_DEFAULT);
|
||||
}
|
||||
|
||||
static void glui_navigation_clear(void *data, bool pending_push)
|
||||
|
@ -22,13 +22,15 @@
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_input.h"
|
||||
#include "../menu_animation.h"
|
||||
#include "../menu_texture.h"
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include "../../gfx/gl_common.h"
|
||||
#include "../../gfx/video_thread_wrapper.h"
|
||||
#include <compat/posix_string.h>
|
||||
|
||||
#include "shared.h"
|
||||
#include "../menu_animation.h"
|
||||
|
||||
#ifndef XMB_THEME
|
||||
#define XMB_THEME "monochrome"
|
||||
@ -575,63 +577,6 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current)
|
||||
xmb->old_depth = xmb->depth;
|
||||
}
|
||||
|
||||
static GLuint xmb_png_texture_load_(const char * file_name)
|
||||
{
|
||||
struct texture_image ti = {0};
|
||||
GLuint texture = 0;
|
||||
|
||||
if (! path_file_exists(file_name))
|
||||
return 0;
|
||||
|
||||
texture_image_load(&ti, file_name);
|
||||
|
||||
/* Generate the OpenGL texture object */
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ?
|
||||
GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
|
||||
ti.width, ti.height, 0,
|
||||
driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
RARCH_GL_FORMAT32, ti.pixels);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
free(ti.pixels);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
static int xmb_png_texture_load_wrap(void *data)
|
||||
{
|
||||
const char *filename = (const char*)data;
|
||||
|
||||
if (!filename)
|
||||
return 0;
|
||||
return xmb_png_texture_load_(filename);
|
||||
}
|
||||
|
||||
static GLuint xmb_png_texture_load(const char* file_name)
|
||||
{
|
||||
if (g_settings.video.threaded
|
||||
&& !g_extern.system.hw_render_callback.context_type)
|
||||
{
|
||||
thread_video_t *thr = (thread_video_t*)driver.video_data;
|
||||
|
||||
if (!thr)
|
||||
return 0;
|
||||
|
||||
thr->cmd_data.custom_command.method = xmb_png_texture_load_wrap;
|
||||
thr->cmd_data.custom_command.data = (void*)file_name;
|
||||
thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND);
|
||||
thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND);
|
||||
|
||||
return thr->cmd_data.custom_command.return_value;
|
||||
}
|
||||
|
||||
return xmb_png_texture_load_(file_name);
|
||||
}
|
||||
|
||||
static xmb_node_t* xmb_node_for_core(int i)
|
||||
{
|
||||
core_info_t *info = NULL;
|
||||
@ -1408,7 +1353,8 @@ static void xmb_context_reset(void *data)
|
||||
"clock.png", sizeof(xmb->textures[XMB_TEXTURE_CLOCK].path));
|
||||
|
||||
for (k = 0; k < XMB_TEXTURE_LAST; k++)
|
||||
xmb->textures[k].id = xmb_png_texture_load(xmb->textures[k].path);
|
||||
xmb->textures[k].id = menu_texture_load(xmb->textures[k].path,
|
||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP);
|
||||
|
||||
xmb->settings_node.icon = xmb->textures[XMB_TEXTURE_SETTINGS].id;
|
||||
xmb->settings_node.alpha = xmb->c_active_alpha;
|
||||
@ -1453,8 +1399,11 @@ static void xmb_context_reset(void *data)
|
||||
|
||||
node->alpha = 0;
|
||||
node->zoom = xmb->c_passive_zoom;
|
||||
node->icon = xmb_png_texture_load(texturepath);
|
||||
node->content_icon = xmb_png_texture_load(content_texturepath);
|
||||
node->icon = menu_texture_load(texturepath,
|
||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP);
|
||||
node->content_icon = menu_texture_load(content_texturepath,
|
||||
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP);
|
||||
|
||||
|
||||
if (i == xmb->active_category)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../gfx/gl_common.h"
|
||||
|
||||
static void menu_texture_png_load_gl(struct texture_image *ti,
|
||||
enum texture_filter_type filter_type,
|
||||
unsigned *id)
|
||||
{
|
||||
/* Generate the OpenGL texture object */
|
||||
@ -34,13 +35,29 @@ static void menu_texture_png_load_gl(struct texture_image *ti,
|
||||
driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
|
||||
RARCH_GL_FORMAT32, ti->pixels);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
switch (filter_type)
|
||||
{
|
||||
case TEXTURE_FILTER_MIPMAP:
|
||||
glTexParameterf(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
break;
|
||||
case TEXTURE_FILTER_DEFAULT:
|
||||
default:
|
||||
glTexParameterf(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned menu_texture_png_load(const char *path,
|
||||
enum texture_backend_type type)
|
||||
enum texture_backend_type type,
|
||||
enum texture_filter_type filter_type)
|
||||
{
|
||||
unsigned id = 0;
|
||||
struct texture_image ti = {0};
|
||||
@ -53,7 +70,7 @@ static unsigned menu_texture_png_load(const char *path,
|
||||
{
|
||||
case TEXTURE_BACKEND_OPENGL:
|
||||
#ifdef HAVE_OPENGL
|
||||
menu_texture_png_load_gl(&ti, &id);
|
||||
menu_texture_png_load_gl(&ti, filter_type, &id);
|
||||
#endif
|
||||
break;
|
||||
case TEXTURE_BACKEND_DEFAULT:
|
||||
@ -71,7 +88,17 @@ static int menu_texture_png_load_wrap(void *data)
|
||||
const char *filename = (const char*)data;
|
||||
if (!filename)
|
||||
return 0;
|
||||
return menu_texture_png_load(filename, TEXTURE_BACKEND_DEFAULT);
|
||||
return menu_texture_png_load(filename, TEXTURE_BACKEND_DEFAULT,
|
||||
TEXTURE_FILTER_DEFAULT);
|
||||
}
|
||||
|
||||
static int menu_texture_png_load_wrap_gl_mipmap(void *data)
|
||||
{
|
||||
const char *filename = (const char*)data;
|
||||
if (!filename)
|
||||
return 0;
|
||||
return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_FILTER_MIPMAP);
|
||||
}
|
||||
|
||||
static int menu_texture_png_load_wrap_gl(void *data)
|
||||
@ -79,11 +106,13 @@ static int menu_texture_png_load_wrap_gl(void *data)
|
||||
const char *filename = (const char*)data;
|
||||
if (!filename)
|
||||
return 0;
|
||||
return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL);
|
||||
return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL,
|
||||
TEXTURE_FILTER_DEFAULT);
|
||||
}
|
||||
|
||||
unsigned menu_texture_load(const char *path,
|
||||
enum texture_backend_type type)
|
||||
enum texture_backend_type type,
|
||||
enum texture_filter_type filter_type)
|
||||
{
|
||||
if (g_settings.video.threaded
|
||||
&& !g_extern.system.hw_render_callback.context_type)
|
||||
@ -96,7 +125,10 @@ unsigned menu_texture_load(const char *path,
|
||||
switch (type)
|
||||
{
|
||||
case TEXTURE_BACKEND_OPENGL:
|
||||
thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl;
|
||||
if (filter_type == TEXTURE_FILTER_MIPMAP)
|
||||
thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl_mipmap;
|
||||
else
|
||||
thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl;
|
||||
break;
|
||||
case TEXTURE_BACKEND_DEFAULT:
|
||||
default:
|
||||
@ -112,5 +144,5 @@ unsigned menu_texture_load(const char *path,
|
||||
return thr->cmd_data.custom_command.return_value;
|
||||
}
|
||||
|
||||
return menu_texture_png_load(path, type);
|
||||
return menu_texture_png_load(path, type, filter_type);
|
||||
}
|
||||
|
@ -23,12 +23,19 @@ enum texture_backend_type
|
||||
TEXTURE_BACKEND_OPENGL,
|
||||
};
|
||||
|
||||
enum texture_filter_type
|
||||
{
|
||||
TEXTURE_FILTER_DEFAULT = 0,
|
||||
TEXTURE_FILTER_MIPMAP,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned menu_texture_load(const char *path,
|
||||
enum texture_backend_type type);
|
||||
enum texture_backend_type type,
|
||||
enum texture_filter_type filter_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user