mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-02-04 07:31:20 +00:00
more strict shader dir checking
This commit is contained in:
parent
67647ac470
commit
e179e2b4a4
1 changed files with 18 additions and 4 deletions
|
@ -404,9 +404,20 @@ void WINAPI QERApp_ReloadShaders(){
|
||||||
|
|
||||||
int WINAPI QERApp_LoadShadersFromDir( const char *path ){
|
int WINAPI QERApp_LoadShadersFromDir( const char *path ){
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
// some code adds a trailing slash
|
||||||
|
gchar* keyword = g_strdup(path);
|
||||||
|
if ( g_str_has_suffix( keyword, "/" ) ) {
|
||||||
|
keyword[ strlen(keyword) -1 ] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar* around = g_strconcat("/", keyword, ".", NULL);
|
||||||
|
gchar* prefix = g_strconcat("textures/", keyword, "/", NULL);
|
||||||
|
|
||||||
// scan g_Shaders, and call QERApp_Shader_ForName for each in the given path
|
// scan g_Shaders, and call QERApp_Shader_ForName for each in the given path
|
||||||
// this will load the texture if needed and will set it in use..
|
// this will load the texture if needed and will set it in use..
|
||||||
int nSize = g_Shaders.GetSize();
|
int nSize = g_Shaders.GetSize();
|
||||||
|
|
||||||
for ( int i = 0; i < nSize; i++ )
|
for ( int i = 0; i < nSize; i++ )
|
||||||
{
|
{
|
||||||
CShader *pShader = reinterpret_cast < CShader * >( g_Shaders[i] );
|
CShader *pShader = reinterpret_cast < CShader * >( g_Shaders[i] );
|
||||||
|
@ -418,9 +429,7 @@ int WINAPI QERApp_LoadShadersFromDir( const char *path ){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is basically doing:
|
if ( strstr( pShader->getShaderFileName(), around ) != NULL || g_str_has_prefix( pShader->getName(), prefix ) ) {
|
||||||
// if path in ["scripts/eerie.shader", "textures/eerie/blackness"]
|
|
||||||
if ( strstr( pShader->getShaderFileName(), path ) || strstr( pShader->getName(), path ) ) {
|
|
||||||
count++;
|
count++;
|
||||||
// request the shader, this will load the texture if needed and set "inuse"
|
// request the shader, this will load the texture if needed and set "inuse"
|
||||||
//++timo FIXME: should we put an Activate member on CShader?
|
//++timo FIXME: should we put an Activate member on CShader?
|
||||||
|
@ -437,6 +446,11 @@ int WINAPI QERApp_LoadShadersFromDir( const char *path ){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(keyword);
|
||||||
|
g_free(around);
|
||||||
|
g_free(prefix);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +460,7 @@ bool WINAPI QERApp_IsDirContainingShaders( const char *path ){
|
||||||
// they will not be displayed and are not applicable to surfaces
|
// they will not be displayed and are not applicable to surfaces
|
||||||
// exclude shaders from other paths,
|
// exclude shaders from other paths,
|
||||||
// they are not the ones we are looking for
|
// they are not the ones we are looking for
|
||||||
gchar* prefix = g_strconcat("textures/", path, NULL);
|
gchar* prefix = g_strconcat("textures/", path, "/", NULL);
|
||||||
for ( int i = 0; i < nSize; i++ )
|
for ( int i = 0; i < nSize; i++ )
|
||||||
{
|
{
|
||||||
CShader *pShader = reinterpret_cast < CShader * >( g_Shaders[i] );
|
CShader *pShader = reinterpret_cast < CShader * >( g_Shaders[i] );
|
||||||
|
|
Loading…
Reference in a new issue