mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-01 01:03:11 +00:00
Add helper function to replace Cg shaders on-the-fly.
This commit is contained in:
parent
1cfc4c6cc0
commit
230f47d00c
@ -1160,3 +1160,42 @@ void gl_cg_set_compiler_args(const char **argv)
|
||||
cg_arguments = argv;
|
||||
}
|
||||
|
||||
bool gl_cg_load_shader(unsigned index, const char *path)
|
||||
{
|
||||
if (!cg_active)
|
||||
return false;
|
||||
|
||||
if (index == 0)
|
||||
return false;
|
||||
|
||||
if (prg[index].fprg)
|
||||
{
|
||||
cgGLUnbindProgram(cgFProf);
|
||||
|
||||
if (prg[0].fprg != prg[index].fprg)
|
||||
cgDestroyProgram(prg[index].fprg);
|
||||
}
|
||||
|
||||
if (prg[index].vprg)
|
||||
{
|
||||
cgGLUnbindProgram(cgVProf);
|
||||
|
||||
if (prg[0].vprg != prg[index].vprg)
|
||||
cgDestroyProgram(prg[index].vprg);
|
||||
}
|
||||
|
||||
memset(&prg[index], 0, sizeof(prg[index]));
|
||||
|
||||
if (load_program(index, path, true))
|
||||
{
|
||||
set_program_attributes(index);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always make sure we have a valid shader.
|
||||
memcpy(&prg[index], &prg[0], sizeof(prg[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,4 +52,6 @@ void gl_cg_shader_scale(unsigned index, struct gl_fbo_scale *scale);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user