First post, by Serious Callers Only
I'm doing a small patch to dosbox to use these from package install.
What i want is to be able to use the files by just specifying their filename (note: not path), like the built in shaders.
So i want to add another fallback after the 'currentdir/shader.glsl' and 'configdir/glshaders/shader.glsl'. Trouble is i don't understand the code very well.
This is the code:
char* shader_src = render.shader_src;
Prop_path *sh = section->Get_path("glshader");
f = (std::string)sh->GetValue();
if (f.empty() || f=="none") {
free(render.shader_src);
render.shader_src = NULL;
} else if (!RENDER_GetShader(sh->realpath)) {
std::string path;
Cross::GetPlatformConfigDir(path);
path = path + "glshaders" + CROSS_FILESPLIT + f;
if (!RENDER_GetShader(path) && (sh->realpath==f || !RENDER_GetShader(f))) {
sh->SetValue("none");
LOG_MSG("Shader file \"%s\" not found", f.c_str());
}
}
RENDER_GetShader gets the shader definition and returns true if it succeed. I was thinking of changing this code to add another dir fallback - remember this code only runs on the package install, so linux only, so i don't need to care about portable paths
My trouble is not understanding what's the difference between the 'f' from 'sh->getValue' and 'sh->realpath'. It appears that the fail condition is super complicated for no reason if those two are always equal like i suspect, and i could do :
std::string path;
std::string path2;
Cross::GetPlatformConfigDir(path);
path = path + "glshaders" + CROSS_FILESPLIT + f;
path2 = "/usr/share/dosbox/glshaders/"+f
if (! (RENDER_GetShader(path) || RENDER_GetShader(path2)) ) {
sh->SetValue("none");
LOG_MSG("Shader file \"%s\" not found", f.c_str());
}
Can sh->getValue here really be different from sh->realpath ? If so what's the difference, getValue is the filename and realpath the whole path?
[edit by Dominus: split this off some more shaders for SVN r4319 and later]