mirror of
https://github.com/libretro/RetroArch
synced 2025-02-13 21:40:27 +00:00
(Cg/PS3) Embed menu shader
This commit is contained in:
parent
7a20cfa79c
commit
142c6335c9
@ -38,7 +38,6 @@ typedef struct
|
||||
char port_dir[MAXIMUM_PATH];
|
||||
char savestate_dir[MAXIMUM_PATH];
|
||||
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
|
||||
char menu_shader_file[MAXIMUM_PATH];
|
||||
char shader_file[MAXIMUM_PATH];
|
||||
char shader_dir[MAXIMUM_PATH];
|
||||
#endif
|
||||
|
@ -297,7 +297,6 @@ static void get_environment_settings(int argc, char *argv[])
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL)
|
||||
snprintf(default_paths.shader_dir, sizeof(default_paths.shader_dir), "%s/shaders", default_paths.core_dir);
|
||||
snprintf(default_paths.shader_file, sizeof(default_paths.shader_file), "%s/shaders/stock.cg", default_paths.core_dir);
|
||||
snprintf(default_paths.menu_shader_file, sizeof(default_paths.menu_shader_file), "%s/shaders/Borders/Menu/border-only-rarch.cg", default_paths.core_dir);
|
||||
#endif
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
|
5
gfx/gl.c
5
gfx/gl.c
@ -1891,11 +1891,6 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
gl->full_y = gl->win_height;
|
||||
}
|
||||
|
||||
#if defined(HAVE_RMENU) && defined(HAVE_CG)
|
||||
RARCH_LOG("Initializing CG menu shader ...\n");
|
||||
gl_cg_set_menu_shader(default_paths.menu_shader_file);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLSL
|
||||
gl_glsl_set_get_proc_address(gl->ctx_driver->get_proc_address);
|
||||
#endif
|
||||
|
@ -59,7 +59,37 @@ static const char *stock_cg_program =
|
||||
" return color * tex2D(s0, tex);"
|
||||
"}";
|
||||
|
||||
static char *menu_cg_program;
|
||||
static const char *menu_cg_program =
|
||||
"struct input"
|
||||
"{"
|
||||
"float2 video_size;"
|
||||
"float2 texture_size;"
|
||||
"float2 output_size;"
|
||||
"float frame_count;"
|
||||
"float frame_direction;"
|
||||
"float frame_rotation;"
|
||||
"};"
|
||||
"void main_vertex"
|
||||
"("
|
||||
"float4 position : POSITION,"
|
||||
"out float4 oPosition : POSITION,"
|
||||
"uniform float4x4 modelViewProj,"
|
||||
"float4 color : COLOR,"
|
||||
"out float4 oColor : COLOR,"
|
||||
"float2 tex_border : TEXCOORD1,"
|
||||
"out float2 otex_border : TEXCOORD1,"
|
||||
"uniform input IN"
|
||||
")"
|
||||
"{"
|
||||
"oPosition = mul(modelViewProj, position);"
|
||||
"oColor = color;"
|
||||
"otex_border = tex_border;"
|
||||
"}"
|
||||
"float4 main_fragment (float2 tex_border : TEXCOORD1, uniform sampler2D bg : TEXUNIT0, uniform input IN) : COLOR"
|
||||
"{"
|
||||
"float4 background = tex2D(bg, tex_border);"
|
||||
"return background;"
|
||||
"}";
|
||||
|
||||
#ifdef RARCH_CG_DEBUG
|
||||
static void cg_error_handler(CGcontext ctx, CGerror error, void *data)
|
||||
@ -371,12 +401,6 @@ static void gl_cg_deinit_state(void)
|
||||
// Final deinit.
|
||||
static void gl_cg_deinit_context_state(void)
|
||||
{
|
||||
if (menu_cg_program)
|
||||
{
|
||||
free(menu_cg_program);
|
||||
menu_cg_program = NULL;
|
||||
}
|
||||
|
||||
// Destroying context breaks on PS3 for some unknown reason.
|
||||
#ifndef __CELLOS_LV2__
|
||||
if (cgCtx)
|
||||
@ -502,7 +526,7 @@ static bool load_plain(const char *path)
|
||||
|
||||
static bool load_menu_shader(void)
|
||||
{
|
||||
return load_program(RARCH_CG_MENU_SHADER_INDEX, menu_cg_program, true);
|
||||
return load_program(RARCH_CG_MENU_SHADER_INDEX, menu_cg_program, false);
|
||||
}
|
||||
|
||||
#define print_buf(buf, ...) snprintf(buf, sizeof(buf), __VA_ARGS__)
|
||||
@ -846,7 +870,7 @@ bool gl_cg_init(const char *path)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (menu_cg_program && !load_menu_shader())
|
||||
if (!load_menu_shader())
|
||||
return false;
|
||||
|
||||
prg[0].mvp = cgGetNamedParameter(prg[0].vprg, "modelViewProj");
|
||||
@ -854,8 +878,7 @@ bool gl_cg_init(const char *path)
|
||||
for (unsigned i = 1; i <= cg_shader->passes; i++)
|
||||
set_program_attributes(i);
|
||||
|
||||
if (menu_cg_program)
|
||||
set_program_attributes(RARCH_CG_MENU_SHADER_INDEX);
|
||||
set_program_attributes(RARCH_CG_MENU_SHADER_INDEX);
|
||||
|
||||
cgGLBindProgram(prg[1].fprg);
|
||||
cgGLBindProgram(prg[1].vprg);
|
||||
@ -905,13 +928,6 @@ void gl_cg_shader_scale(unsigned index, struct gfx_fbo_scale *scale)
|
||||
scale->valid = false;
|
||||
}
|
||||
|
||||
void gl_cg_set_menu_shader(const char *path)
|
||||
{
|
||||
if (menu_cg_program)
|
||||
free(menu_cg_program);
|
||||
menu_cg_program = strdup(path);
|
||||
}
|
||||
|
||||
void gl_cg_set_compiler_args(const char **argv)
|
||||
{
|
||||
cg_arguments = argv;
|
||||
|
@ -48,7 +48,6 @@ bool gl_cg_set_coords(const struct gl_coords *coords);
|
||||
|
||||
#define RARCH_CG_MAX_SHADERS 16
|
||||
#define RARCH_CG_MENU_SHADER_INDEX (RARCH_CG_MAX_SHADERS - 1)
|
||||
void gl_cg_set_menu_shader(const char *path);
|
||||
void gl_cg_set_compiler_args(const char **argv);
|
||||
|
||||
bool gl_cg_load_shader(unsigned index, const char *path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user